rgsl/eigen.rs
1//
2// A rust binding for the GSL library by Guillaume Gomez (guillaume1.gomez@gmail.com)
3//
4
5/*!
6## References and Further Reading
7
8Further information on the algorithms described in this section can be found in the following book,
9
10G. H. Golub, C. F. Van Loan, Matrix Computations (3rd Ed, 1996), Johns Hopkins University Press, ISBN 0-8018-5414-8.
11Further information on the generalized eigensystems QZ algorithm can be found in this paper,
12
13C. Moler, G. Stewart, “An Algorithm for Generalized Matrix Eigenvalue Problems”, SIAM J. Numer. Anal., Vol 10, No 2, 1973.
14Eigensystem routines for very large matrices can be found in the Fortran library LAPACK. The LAPACK library is described in,
15
16LAPACK Users’ Guide (Third Edition, 1999), Published by SIAM, ISBN 0-89871-447-8.
17http://www.netlib.org/lapack
18
19The LAPACK source code can be found at the website above along with an online copy of the users guide.
20!*/
21
22use crate::Value;
23use ffi::FFI;
24use types::{MatrixComplexF64, MatrixF64, VectorComplexF64, VectorF64};
25
26/// This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding real eigenvectors stored in the columns
27/// of the matrix evec into ascending or descending order according to the value of the parameter sort_type
28#[doc(alias = "gsl_eigen_symmv_sort")]
29pub fn symmv_sort(
30 eval: &mut VectorF64,
31 evec: &mut MatrixF64,
32 sort_type: ::EigenSort,
33) -> Result<(), Value> {
34 let ret = unsafe {
35 sys::gsl_eigen_symmv_sort(eval.unwrap_unique(), evec.unwrap_unique(), sort_type.into())
36 };
37 result_handler!(ret, ())
38}
39
40/// This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding complex eigenvectors stored in the columns
41/// of the matrix evec into ascending or descending order according to the value of the parameter sort_type.
42#[doc(alias = "gsl_eigen_hermv_sort")]
43pub fn hermv_sort(
44 eval: &mut VectorF64,
45 evec: &mut MatrixComplexF64,
46 sort_type: ::EigenSort,
47) -> Result<(), Value> {
48 let ret = unsafe {
49 sys::gsl_eigen_hermv_sort(eval.unwrap_unique(), evec.unwrap_unique(), sort_type.into())
50 };
51 result_handler!(ret, ())
52}
53
54/// This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding complex eigenvectors stored in the columns
55/// of the matrix evec into ascending or descending order according to the value of the parameter sort_type. Only EigenSort::AbsAsc and
56/// EigenSort::AbsDesc are supported due to the eigenvalues being complex.
57#[doc(alias = "gsl_eigen_nonsymmv_sort")]
58pub fn nonsymmv_sort(
59 eval: &mut VectorComplexF64,
60 evec: &mut MatrixComplexF64,
61 sort_type: ::EigenSort,
62) -> Result<(), Value> {
63 let ret = unsafe {
64 sys::gsl_eigen_nonsymmv_sort(eval.unwrap_unique(), evec.unwrap_unique(), sort_type.into())
65 };
66 result_handler!(ret, ())
67}
68
69/// This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding real eigenvectors stored in the columns
70/// of the matrix evec into ascending or descending order according to the value of the parameter sort_type.
71#[doc(alias = "gsl_eigen_gensymmv_sort")]
72pub fn gensymmv_sort(
73 eval: &mut VectorF64,
74 evec: &mut MatrixF64,
75 sort_type: ::EigenSort,
76) -> Result<(), Value> {
77 let ret = unsafe {
78 sys::gsl_eigen_gensymmv_sort(eval.unwrap_unique(), evec.unwrap_unique(), sort_type.into())
79 };
80 result_handler!(ret, ())
81}
82
83/// This function simultaneously sorts the eigenvalues stored in the vector eval and the corresponding complex eigenvectors stored in the
84/// columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type.
85#[doc(alias = "gsl_eigen_genhermv_sort")]
86pub fn genhermv_sort(
87 eval: &mut VectorF64,
88 evec: &mut MatrixComplexF64,
89 sort_type: ::EigenSort,
90) -> Result<(), Value> {
91 let ret = unsafe {
92 sys::gsl_eigen_genhermv_sort(eval.unwrap_unique(), evec.unwrap_unique(), sort_type.into())
93 };
94 result_handler!(ret, ())
95}
96
97/// This function simultaneously sorts the eigenvalues stored in the vectors (alpha, beta) and the corresponding complex eigenvectors stored
98/// in the columns of the matrix evec into ascending or descending order according to the value of the parameter sort_type. Only
99/// EigenSort::AbsAsc and EigenSort::AbsDesc are supported due to the eigenvalues being complex.
100#[doc(alias = "gsl_eigen_genv_sort")]
101pub fn genv_sort(
102 alpha: &mut VectorComplexF64,
103 beta: &mut VectorF64,
104 evec: &mut MatrixComplexF64,
105 sort_type: ::EigenSort,
106) -> Result<(), Value> {
107 let ret = unsafe {
108 sys::gsl_eigen_genv_sort(
109 alpha.unwrap_unique(),
110 beta.unwrap_unique(),
111 evec.unwrap_unique(),
112 sort_type.into(),
113 )
114 };
115 result_handler!(ret, ())
116}