A basic libary for calculating matrix eigen-decompositions and inverses
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | long | = | kind(int(1)) | |
integer, | public, | parameter | :: | float | = | kind(1.e0) | |
integer, | public, | parameter | :: | double | = | kind(1.d0) | |
real(kind=double), | public, | parameter | :: | ONE | = | 1.d0 | |
real(kind=double), | public, | parameter | :: | TWO | = | 2.d0 | |
real(kind=double), | public, | parameter | :: | ZERO | = | 0.d0 | |
real(kind=double), | public, | parameter | :: | XMACH_EPS | = | 2.22d-16 | |
integer, | public, | parameter | :: | MAXIT | = | 50 |
Calculates absolute value of a complex number a
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double) | :: | ar | Real part of |
|||
real(kind=double) | :: | ai | Imaginary part of |
Absolute value of a
Calculates outer product
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double), | intent(in), | dimension(:) | :: | a | ||
real(kind=double), | intent(in), | dimension(:) | :: | b |
Swaps values a
and b
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double) | :: | a | ||||
real(kind=double) | :: | b |
Balances the matrix so that the rows with zero entries off the diagonal are isolated and the remaining columns and rows are resized to have one norm close to 1.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | Dimension of |
||
real(kind=double) | :: | mat(0:n-1,0:n-1) |
|
|||
real(kind=double) | :: | scal(0:n-1) | Contains isolated eigenvalue in the positions 0- |
|||
integer, | intent(out) | :: | low | |||
integer, | intent(out) | :: | high |
Reverses the balancing of balance for the eigenvectors
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | Dimension of matrix |
||
integer, | intent(in) | :: | low | First nonzero row |
||
integer, | intent(in) | :: | high | Last nonzero row |
||
real(kind=double), | intent(in) | :: | scal(0:n-1) | Scaling data from balance |
||
real(kind=double), | intent(inout) | :: | eivec(0:n-1,0:n-1) |
Transforms the matrix mat
to upper Hessenberg form.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | Dimension of |
||
integer, | intent(in) | :: | low | First nonzero row |
||
integer, | intent(in) | :: | high | Last nonzero row |
||
real(kind=double), | intent(inout) | :: | mat(0:n-1,0:n-1) | is stored in the lower triangle |
||
integer, | intent(out) | :: | perm(0:n-1) | Permutation vector for elmtrans |
Elmtrans copies the Hessenberg matrix stored in mat
to h
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | Dimension of mat |
||
integer, | intent(in) | :: | low | First nonzero row |
||
integer, | intent(in) | :: | high | Last nonzero row |
||
real(kind=double), | intent(in) | :: | mat(0:n-1,0:n-1) |
|
||
integer, | intent(in) | :: | perm(0:n-1) | Permutation data from elmhes |
||
real(kind=double), | intent(out) | :: | h(0:n-1,0:n-1) | Hessenberg matrix |
Performs complex division c
= a
/ b
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double) | :: | ar | Real part of numerator |
|||
real(kind=double) | :: | ai | Imaginary part of numerator |
|||
real(kind=double) | :: | br | Real part of denominator |
|||
real(kind=double) | :: | bi | Imaginary part of denominator |
|||
real(kind=double) | :: | cr | Real part of quotient |
|||
real(kind=double) | :: | ci | Imaginary part of quotient |
|||
integer | :: | rc | return code |
Computes the eigenvectors for the eigenvalues found in hqr2
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
integer, | intent(in) | :: | low | |||
integer, | intent(in) | :: | high | |||
real(kind=double) | :: | h(0:n-1,0:n-1) | ||||
real(kind=double), | intent(in) | :: | wr(0:n-1) | |||
real(kind=double), | intent(in) | :: | wi(0:n-1) | |||
real(kind=double), | intent(out) | :: | eivec(0:n-1,0:n-1) | |||
integer | :: | rc |
Computes the eigenvalues and (if vec = True) the eigenvectors of an n * n upper Hessenberg matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
integer, | intent(in) | :: | low | |||
integer, | intent(in) | :: | high | |||
real(kind=double), | intent(out) | :: | h(0:n-1,0:n-1) | |||
real(kind=double), | intent(out) | :: | wr(0:n-1) | |||
real(kind=double), | intent(out) | :: | wi(0:n-1) | |||
real(kind=double), | intent(out) | :: | eivec(0:n-1,0:n-1) | |||
integer, | intent(out) | :: | cnt(0:n-1) | |||
integer, | intent(out) | :: | rc |
The subroutine eigen determines all eigenvalues and (if desired) all eigenvectors of a real square n * n matrix via the QR method in the version of Martin, Parlett, Peters, Reinsch and Wilkinson.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real(kind=double), | intent(in), | dimension(n,n) | :: | matrix | ||
real(kind=double), | intent(out), | dimension(n,n) | :: | eigvec | ||
real(kind=double), | intent(out), | dimension(n) | :: | eigval |
Swap arrays a
and b
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double), | intent(inout), | dimension(:) | :: | a | ||
real(kind=double), | intent(inout), | dimension(:) | :: | b |
Calculates LU decomposition
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double), | intent(inout), | dimension(:,:) | :: | a | ||
integer, | intent(out), | dimension(:) | :: | indx | ||
real(kind=double), | intent(out) | :: | d |
Does LU back substitution
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double), | intent(in), | dimension(:,:) | :: | a | ||
integer, | intent(in), | dimension(:) | :: | indx | ||
real(kind=double), | intent(inout), | dimension(:) | :: | b |
Matrix inversion with LU-decomposition
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=double), | intent(in), | dimension(:,:) | :: | a | ||
real(kind=double), | intent(out), | dimension(:,:) | :: | b |