Octopus
lalg_adv_oct_m Module Reference

Data Types

interface  lalg_cholesky
 
interface  lalg_determinant
 Note that lalg_determinant and lalg_inverse are just wrappers over the same routine. More...
 
interface  lalg_eigensolve
 
interface  lalg_eigensolve_nonh
 
interface  lalg_eigensolve_parallel
 
interface  lalg_eigensolve_tridiagonal
 
interface  lalg_geneigensolve
 
interface  lalg_inverse
 
interface  lalg_least_squares
 
interface  lalg_linsyssolve
 
interface  lalg_lowest_eigensolve
 
interface  lalg_lowest_geneigensolve
 
interface  lalg_matrix_function
 
interface  lalg_matrix_rank_svd
 
interface  lalg_pseudo_inverse
 
interface  lalg_singular_value_decomp
 
interface  lalg_svd_inverse
 
interface  lapack_geev
 

Functions/Subroutines

real(real64) function sfmin ()
 Auxiliary function. More...
 
subroutine lalg_dgeev (jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
 
subroutine lalg_zgeev (jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
 
subroutine, public zlalg_exp (nn, pp, aa, ex, hermitian)
 
subroutine, public zlalg_phi (nn, pp, aa, ex, hermitian)
 
complex(real64) function, public lalg_zdni (eigenvec, alpha, beta)
 
complex(real64) function, public lalg_zduialpha (eigenvec, mmatrix, alpha, gamma, delta)
 
complex(real64) function, public lalg_zd2ni (eigenvec, mmatrix, alpha, beta, gamma, delta)
 
pure real(real64) function pseudoinverse_default_tolerance (m, n, sg_values)
 Computes the default Moore-Penrose pseudoinverse tolerance for zeroing. More...
 
real(real64) function, dimension(1:n, 1:n), public lalg_remove_rotation (n, A)
 Remove rotation from affine transformation A by computing the polar decomposition and discarding the rotational part. The polar decomposition of A is given by A = U P with P = sqrt(A^T A), where U is a rotation matrix and P is a scaling matrix. This function returns P. More...
 
subroutine zcholesky (n, a, bof, err_code)
 Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a, dim(a) = n x n. On return a = u^T u with u upper triangular matrix. More...
 
subroutine zgeneigensolve (n, a, b, e, preserve_mat, bof, err_code)
 Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form \( Ax=\lambda Bx \). B is also positive definite. More...
 
subroutine zeigensolve_nonh (n, a, e, err_code, side, sort_eigenvectors)
 Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) eigenproblem, of the form A*x=(lambda)*x. More...
 
subroutine zlowest_geneigensolve (k, n, a, b, e, v, preserve_mat, bof, err_code)
 Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form A*x=(lambda)*B*x. B is also positive definite. More...
 
subroutine zeigensolve (n, a, e, bof, err_code)
 Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A. More...
 
subroutine zeigensolve_tridiagonal (n, a, e, bof, err_code)
 Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian case, the matrix is assumed to be real symmetric (even if stored in complex) More...
 
subroutine zlowest_eigensolve (k, n, a, e, v, preserve_mat)
 Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem, of the form A*x=(lambda)*x. Here A is assumed to be symmetric. More...
 
complex(real64) function zdeterminant (n, a, preserve_mat)
 Invert a real symmetric or complex Hermitian square matrix a. More...
 
subroutine zdirect_inverse (n, a, det)
 Invert a real symmetric or complex Hermitian square matrix a. More...
 
subroutine zsym_inverse (uplo, n, a)
 Invert a real/complex symmetric square matrix a. More...
 
subroutine zlinsyssolve (n, nrhs, a, b, x)
 compute the solution to a complex system of linear equations A*X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices. More...
 
subroutine zsingular_value_decomp (m, n, a, u, vt, sg_values, preserve_mat)
 Computes the singular value decomposition of a complex MxN matrix a. More...
 
subroutine zsvd_inverse (m, n, a, threshold)
 Computes inverse of a complex MxN matrix, a, using the SVD decomposition. More...
 
subroutine zlalg_pseudo_inverse (a, threshold)
 Invert a matrix with the Moore-Penrose pseudo-inverse. More...
 
integer function zmatrix_rank_svd (a, preserve_mat, tol)
 Compute the rank of the matrix A using SVD. More...
 
subroutine zupper_triangular_inverse (n, a)
 Calculate the inverse of a real/complex upper triangular matrix (in unpacked storage). (lower triangular would be a trivial variant of this) More...
 
subroutine zleast_squares_vec (nn, aa, bb, xx, preserve_mat)
 
subroutine zeigensolve_parallel (n, a, e, bof, err_code)
 Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenproblem in parallel using ScaLAPACK or ELPA on all processors n: dimension of matrix a: input matrix, on exit: contains eigenvectors e: eigenvalues. More...
 
subroutine zinverse (n, a, method, det, threshold, uplo)
 An interface to different method to invert a matrix. More...
 
subroutine, public zlalg_matrix_function (n, factor, a, fun_a, fun, hermitian, tridiagonal)
 This routine calculates a function of a matrix by using an eigenvalue decomposition. More...
 
subroutine dcholesky (n, a, bof, err_code)
 Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a, dim(a) = n x n. On return a = u^T u with u upper triangular matrix. More...
 
subroutine dgeneigensolve (n, a, b, e, preserve_mat, bof, err_code)
 Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form \( Ax=\lambda Bx \). B is also positive definite. More...
 
subroutine deigensolve_nonh (n, a, e, err_code, side, sort_eigenvectors)
 Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) eigenproblem, of the form A*x=(lambda)*x. More...
 
subroutine dlowest_geneigensolve (k, n, a, b, e, v, preserve_mat, bof, err_code)
 Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form A*x=(lambda)*B*x. B is also positive definite. More...
 
subroutine deigensolve (n, a, e, bof, err_code)
 Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A. More...
 
subroutine deigensolve_tridiagonal (n, a, e, bof, err_code)
 Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian case, the matrix is assumed to be real symmetric (even if stored in complex) More...
 
subroutine dlowest_eigensolve (k, n, a, e, v, preserve_mat)
 Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem, of the form A*x=(lambda)*x. Here A is assumed to be symmetric. More...
 
real(real64) function ddeterminant (n, a, preserve_mat)
 Invert a real symmetric or complex Hermitian square matrix a. More...
 
subroutine ddirect_inverse (n, a, det)
 Invert a real symmetric or complex Hermitian square matrix a. More...
 
subroutine dsym_inverse (uplo, n, a)
 Invert a real/complex symmetric square matrix a. More...
 
subroutine dlinsyssolve (n, nrhs, a, b, x)
 compute the solution to a real system of linear equations A*X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices. More...
 
subroutine dsingular_value_decomp (m, n, a, u, vt, sg_values, preserve_mat)
 Computes the singular value decomposition of a real M x N matrix a. More...
 
subroutine dsvd_inverse (m, n, a, threshold)
 Computes the inverse of a real M x N matrix, a, using the SVD decomposition. More...
 
subroutine dlalg_pseudo_inverse (a, threshold)
 Invert a matrix with the Moore-Penrose pseudo-inverse. More...
 
integer function dmatrix_rank_svd (a, preserve_mat, tol)
 Compute the rank of the matrix A using SVD. More...
 
subroutine dupper_triangular_inverse (n, a)
 Calculate the inverse of a real/complex upper triangular matrix (in unpacked storage). (lower triangular would be a trivial variant of this) More...
 
subroutine dleast_squares_vec (nn, aa, bb, xx, preserve_mat)
 
subroutine deigensolve_parallel (n, a, e, bof, err_code)
 Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenproblem in parallel using ScaLAPACK or ELPA on all processors n: dimension of matrix a: input matrix, on exit: contains eigenvectors e: eigenvalues. More...
 
subroutine dinverse (n, a, method, det, threshold, uplo)
 An interface to different method to invert a matrix. More...
 
subroutine dlalg_matrix_function (n, factor, a, fun_a, fun, hermitian, tridiagonal)
 This routine calculates a function of a matrix by using an eigenvalue decomposition. More...
 

Function/Subroutine Documentation

◆ sfmin()

real(real64) function lalg_adv_oct_m::sfmin
private

Auxiliary function.

Definition at line 244 of file lalg_adv.F90.

◆ lalg_dgeev()

subroutine lalg_adv_oct_m::lalg_dgeev ( character(1), intent(in)  jobvl,
character(1), intent(in)  jobvr,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout)  a,
integer, intent(in)  lda,
complex(real64), dimension(:), intent(out)  w,
real(real64), dimension(:, :), intent(out)  vl,
integer, intent(in)  ldvl,
real(real64), dimension(:, :), intent(out)  vr,
integer, intent(in)  ldvr,
real(real64), dimension(:), intent(out)  work,
integer, intent(in)  lwork,
real(real64), dimension(:), intent(out)  rwork,
integer, intent(out)  info 
)
private
Parameters
[in,out]aa(lda,n)
[out]ww(n)
[out]vrvl(ldvl,n), vl(ldvr,n)
[out]rworkrwork(max(1,2n))
[out]workwork(lwork)

Definition at line 256 of file lalg_adv.F90.

◆ lalg_zgeev()

subroutine lalg_adv_oct_m::lalg_zgeev ( character(1), intent(in)  jobvl,
character(1), intent(in)  jobvr,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout)  a,
integer, intent(in)  lda,
complex(real64), dimension(:), intent(out)  w,
complex(real64), dimension(:, :), intent(out)  vl,
integer, intent(in)  ldvl,
complex(real64), dimension(:, :), intent(out)  vr,
integer, intent(in)  ldvr,
complex(real64), dimension(:), intent(out)  work,
integer, intent(in)  lwork,
real(real64), dimension(:), intent(out)  rwork,
integer, intent(out)  info 
)
private
Parameters
[in,out]aa(lda,n)
[out]ww(n)
[out]vrvl(ldvl,n), vl(ldvr,n)
[out]rworkrwork(max(1,2n))
[out]workwork(lwork)

Definition at line 283 of file lalg_adv.F90.

◆ zlalg_exp()

subroutine, public lalg_adv_oct_m::zlalg_exp ( integer, intent(in)  nn,
complex(real64), intent(in)  pp,
complex(real64), dimension(:, :), intent(in)  aa,
complex(real64), dimension(:, :), intent(inout)  ex,
logical, intent(in)  hermitian 
)

This routine calculates the exponential of a matrix by using an eigenvalue decomposition.

For the hermitian case:

A = V D V^T => exp(A) = V exp(D) V^T

and in general

A = V D V^-1 => exp(A) = V exp(D) V^-1

This is slow but it is simple to implement, and for the moment it does not affect performance.


Definition at line 317 of file lalg_adv.F90.

◆ zlalg_phi()

subroutine, public lalg_adv_oct_m::zlalg_phi ( integer, intent(in)  nn,
complex(real64), intent(in)  pp,
complex(real64), dimension(:, :), intent(in)  aa,
complex(real64), dimension(:, :), intent(inout)  ex,
logical, intent(in)  hermitian 
)

This routine calculates phi(pp*A), where A is a matrix, pp is any complex number, and phi is the function:

phi(x) = (e^x - 1)/x

For the Hermitian case, for any function f:

A = V D V^T => f(A) = V f(D) V^T

and in general

A = V D V^-1 => f(A) = V f(D) V^-1


Definition at line 395 of file lalg_adv.F90.

◆ lalg_zdni()

complex(real64) function, public lalg_adv_oct_m::lalg_zdni ( complex(real64), dimension(2)  eigenvec,
integer, intent(in)  alpha,
integer, intent(in)  beta 
)

Definition at line 458 of file lalg_adv.F90.

◆ lalg_zduialpha()

complex(real64) function, public lalg_adv_oct_m::lalg_zduialpha ( complex(real64), dimension(2)  eigenvec,
complex(real64), dimension(2, 2)  mmatrix,
integer, intent(in)  alpha,
integer, intent(in)  gamma,
integer, intent(in)  delta 
)

Definition at line 464 of file lalg_adv.F90.

◆ lalg_zd2ni()

complex(real64) function, public lalg_adv_oct_m::lalg_zd2ni ( complex(real64), dimension(2)  eigenvec,
complex(real64), dimension(2, 2)  mmatrix,
integer, intent(in)  alpha,
integer, intent(in)  beta,
integer, intent(in)  gamma,
integer, intent(in)  delta 
)

Definition at line 470 of file lalg_adv.F90.

◆ pseudoinverse_default_tolerance()

pure real(real64) function lalg_adv_oct_m::pseudoinverse_default_tolerance ( integer, intent(in)  m,
integer, intent(in)  n,
real(real64), dimension(:), intent(in)  sg_values 
)
private

Computes the default Moore-Penrose pseudoinverse tolerance for zeroing.

We use here the value suggested here https:

Definition at line 482 of file lalg_adv.F90.

◆ lalg_remove_rotation()

real(real64) function, dimension(1:n, 1:n), public lalg_adv_oct_m::lalg_remove_rotation ( integer, intent(in)  n,
real(real64), dimension(1:n, 1:n), intent(in)  A 
)

Remove rotation from affine transformation A by computing the polar decomposition and discarding the rotational part. The polar decomposition of A is given by A = U P with P = sqrt(A^T A), where U is a rotation matrix and P is a scaling matrix. This function returns P.

Definition at line 494 of file lalg_adv.F90.

◆ zcholesky()

subroutine lalg_adv_oct_m::zcholesky ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a, dim(a) = n x n. On return a = u^T u with u upper triangular matrix.

Parameters
[in,out]a(n,n)
[in,out]bofBomb on failure.

Definition at line 579 of file lalg_adv.F90.

◆ zgeneigensolve()

subroutine lalg_adv_oct_m::zgeneigensolve ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:, :), intent(inout), contiguous  b,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(in)  preserve_mat,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form \( Ax=\lambda Bx \). B is also positive definite.

For optimal performances, this uses the divide and conquer algoritm

Parameters
[in,out]a(n,n)
[in,out]b(n,n)
[out]e(n)
[in]preserve_matIf true, the matrix a and b on exit are the same
[in,out]bofBomb on failure.

Definition at line 634 of file lalg_adv.F90.

◆ zeigensolve_nonh()

subroutine lalg_adv_oct_m::zeigensolve_nonh ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:), intent(out), contiguous  e,
integer, intent(out), optional  err_code,
character(1), intent(in), optional  side,
logical, intent(in), optional  sort_eigenvectors 
)
private

Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) eigenproblem, of the form A*x=(lambda)*x.

Parameters
[in,out]a(n,n)
[out]e(n)
[in]sidewhich eigenvectors ('L' or 'R')
[in]sort_eigenvectorsonly applies to complex version, sorts by real part

Definition at line 745 of file lalg_adv.F90.

◆ zlowest_geneigensolve()

subroutine lalg_adv_oct_m::zlowest_geneigensolve ( integer, intent(in)  k,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:, :), intent(inout), contiguous  b,
real(real64), dimension(:), intent(out), contiguous  e,
complex(real64), dimension(:, :), intent(out), contiguous  v,
logical, intent(in)  preserve_mat,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form A*x=(lambda)*B*x. B is also positive definite.

Parameters
[in,out]a(n, n)
[in,out]b(n, n)
[out]e(n)
[out]v(n, n)
[in]preserve_matIf true, the matrix a and b on exit are the same
[in,out]bofBomb on failure.

Definition at line 864 of file lalg_adv.F90.

◆ zeigensolve()

subroutine lalg_adv_oct_m::zeigensolve ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 983 of file lalg_adv.F90.

◆ zeigensolve_tridiagonal()

subroutine lalg_adv_oct_m::zeigensolve_tridiagonal ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian case, the matrix is assumed to be real symmetric (even if stored in complex)

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 1053 of file lalg_adv.F90.

◆ zlowest_eigensolve()

subroutine lalg_adv_oct_m::zlowest_eigensolve ( integer, intent(in)  k,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
complex(real64), dimension(:, :), intent(out), contiguous  v,
logical, intent(in)  preserve_mat 
)
private

Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem, of the form A*x=(lambda)*x. Here A is assumed to be symmetric.

Parameters
[in]kNumber of eigenvalues requested
[in]nDimensions of a
[in,out]a(n, n)
[out]e(n) The first k elements contain the selected eigenvalues in ascending order.
[out]v(n, k)
[in]preserve_matIf true, the matrix a and b on exit are the same

Definition at line 1132 of file lalg_adv.F90.

◆ zdeterminant()

complex(real64) function lalg_adv_oct_m::zdeterminant ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), target, contiguous  a,
logical, intent(in)  preserve_mat 
)
private

Invert a real symmetric or complex Hermitian square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 1223 of file lalg_adv.F90.

◆ zdirect_inverse()

subroutine lalg_adv_oct_m::zdirect_inverse ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), intent(out), optional  det 
)
private

Invert a real symmetric or complex Hermitian square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 1270 of file lalg_adv.F90.

◆ zsym_inverse()

subroutine lalg_adv_oct_m::zsym_inverse ( character(1), intent(in)  uplo,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a 
)
private

Invert a real/complex symmetric square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 1329 of file lalg_adv.F90.

◆ zlinsyssolve()

subroutine lalg_adv_oct_m::zlinsyssolve ( integer, intent(in)  n,
integer, intent(in)  nrhs,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:, :), intent(inout), contiguous  b,
complex(real64), dimension(:, :), intent(out), contiguous  x 
)
private

compute the solution to a complex system of linear equations A*X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices.

Parameters
[in,out]a(n, n)
[in,out]b(n, nrhs)
[out]x(n, nrhs)

Definition at line 1380 of file lalg_adv.F90.

◆ zsingular_value_decomp()

subroutine lalg_adv_oct_m::zsingular_value_decomp ( integer, intent(in)  m,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:, :), intent(out), contiguous  u,
complex(real64), dimension(:, :), intent(out), contiguous  vt,
real(real64), dimension(:), intent(out), contiguous  sg_values,
logical, intent(in), optional  preserve_mat 
)
private

Computes the singular value decomposition of a complex MxN matrix a.

Parameters
[in,out]a(m,n)
[out]vt(n,n) and (m,m)
[out]sg_values(n)

Definition at line 1458 of file lalg_adv.F90.

◆ zsvd_inverse()

subroutine lalg_adv_oct_m::zsvd_inverse ( integer, intent(in)  m,
integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), intent(in), optional  threshold 
)
private

Computes inverse of a complex MxN matrix, a, using the SVD decomposition.

Parameters
[in,out]aInput (m,n)

Definition at line 1541 of file lalg_adv.F90.

◆ zlalg_pseudo_inverse()

subroutine lalg_adv_oct_m::zlalg_pseudo_inverse ( complex(real64), dimension(:, :), intent(inout), allocatable  a,
real(real64), intent(in), optional  threshold 
)
private

Invert a matrix with the Moore-Penrose pseudo-inverse.

SVD is used to find the U, V and Sigma matrices:

\[ A = U \Sigma V^\dagger \]

Diagonal terms in Sigma <= threshold are set to zero, and the inverse is constructed as:

\[] A^{-1} \approx V \Sigma U^\dagger \]

Parameters
[in,out]aInput: (m, n)

Definition at line 1607 of file lalg_adv.F90.

◆ zmatrix_rank_svd()

integer function lalg_adv_oct_m::zmatrix_rank_svd ( complex(real64), dimension(:, :), intent(inout)  a,
logical, intent(in), optional  preserve_mat,
real(real64), intent(in), optional  tol 
)
private

Compute the rank of the matrix A using SVD.

The rank is equal to the number of non-zero singular values in the diagonal matrix of the SVD decomposition.

Parameters
[in,out]aInput: (m, n)
[in]preserve_matPreserve input A
[in]tolTolerance defining
Returns
Rank of matrix A

Definition at line 1673 of file lalg_adv.F90.

◆ zupper_triangular_inverse()

subroutine lalg_adv_oct_m::zupper_triangular_inverse ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a 
)
private

Calculate the inverse of a real/complex upper triangular matrix (in unpacked storage). (lower triangular would be a trivial variant of this)

Parameters
[in,out]a(n,n)

Definition at line 1714 of file lalg_adv.F90.

◆ zleast_squares_vec()

subroutine lalg_adv_oct_m::zleast_squares_vec ( integer, intent(in)  nn,
complex(real64), dimension(:, :), intent(inout), target, contiguous  aa,
complex(real64), dimension(:), intent(in), contiguous  bb,
complex(real64), dimension(:), intent(out), contiguous  xx,
logical, intent(in)  preserve_mat 
)
private

Definition at line 1762 of file lalg_adv.F90.

◆ zeigensolve_parallel()

subroutine lalg_adv_oct_m::zeigensolve_parallel ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenproblem in parallel using ScaLAPACK or ELPA on all processors n: dimension of matrix a: input matrix, on exit: contains eigenvectors e: eigenvalues.

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 1837 of file lalg_adv.F90.

◆ zinverse()

subroutine lalg_adv_oct_m::zinverse ( integer, intent(in)  n,
complex(real64), dimension(:, :), intent(inout), contiguous  a,
character(len=3), intent(in)  method,
complex(real64), intent(out), optional  det,
real(real64), intent(in), optional  threshold,
character(len=1), intent(in), optional  uplo 
)
private

An interface to different method to invert a matrix.

The possible methods are: svd, dir, sym, upp For the SVD, an optional argument threshold an be specified For the direct inverse, an optional output determinant can be obtained For the symmetric matrix case, the optional argument uplo must be specified

Parameters
[in,out]a(n,n)
[out]detDeterminant of the matrix. Direct inversion only
[in]thresholdThreshold for the SVD pseudoinverse
[in]uploIs the symmetric matrix stored in the upper or lower part?

Definition at line 1860 of file lalg_adv.F90.

◆ zlalg_matrix_function()

subroutine, public lalg_adv_oct_m::zlalg_matrix_function ( integer, intent(in)  n,
complex(real64), intent(in)  factor,
complex(real64), dimension(:, :), intent(in)  a,
complex(real64), dimension(:, :), intent(inout)  fun_a,
  fun,
logical, intent(in)  hermitian,
logical, intent(in), optional  tridiagonal 
)

This routine calculates a function of a matrix by using an eigenvalue decomposition.

For the hermitian case:

\[ A = V D V^T \implies fun(A) = V fun(D) V^T \]

and in general

\[ A = V D V^-1 \implies fun(A) = V fun(D) V^-1 \]

where \(V\) are the eigenvectors, and \(D\) is a diagonal matrix containing the eigenvalues.

In addition, this function can compute \(fun(factor*A)\) for a complex factor.

This is slow but it is simple to implement, and for the moment it does not affect performance.

Parameters
[in]ndimension of the matrix A
[in]factorcomplex factor
[in]amatrix A
[in,out]fun_afun(A)
[in]hermitianis the matrix hermitian?
[in]tridiagonalis the matrix tridiagonal?

Definition at line 1908 of file lalg_adv.F90.

◆ dcholesky()

subroutine lalg_adv_oct_m::dcholesky ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a, dim(a) = n x n. On return a = u^T u with u upper triangular matrix.

Parameters
[in,out]a(n,n)
[in,out]bofBomb on failure.

Definition at line 2090 of file lalg_adv.F90.

◆ dgeneigensolve()

subroutine lalg_adv_oct_m::dgeneigensolve ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:, :), intent(inout), contiguous  b,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(in)  preserve_mat,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form \( Ax=\lambda Bx \). B is also positive definite.

For optimal performances, this uses the divide and conquer algoritm

Parameters
[in,out]a(n,n)
[in,out]b(n,n)
[out]e(n)
[in]preserve_matIf true, the matrix a and b on exit are the same
[in,out]bofBomb on failure.

Definition at line 2145 of file lalg_adv.F90.

◆ deigensolve_nonh()

subroutine lalg_adv_oct_m::deigensolve_nonh ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
complex(real64), dimension(:), intent(out), contiguous  e,
integer, intent(out), optional  err_code,
character(1), intent(in), optional  side,
logical, intent(in), optional  sort_eigenvectors 
)
private

Computes all the eigenvalues and the right (left) eigenvectors of a real or complex (non-Hermitian) eigenproblem, of the form A*x=(lambda)*x.

Parameters
[in,out]a(n,n)
[out]e(n)
[in]sidewhich eigenvectors ('L' or 'R')
[in]sort_eigenvectorsonly applies to complex version, sorts by real part

Definition at line 2251 of file lalg_adv.F90.

◆ dlowest_geneigensolve()

subroutine lalg_adv_oct_m::dlowest_geneigensolve ( integer, intent(in)  k,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:, :), intent(inout), contiguous  b,
real(real64), dimension(:), intent(out), contiguous  e,
real(real64), dimension(:, :), intent(out), contiguous  v,
logical, intent(in)  preserve_mat,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes the k lowest eigenvalues and the eigenvectors of a real symmetric or complex Hermitian generalized definite eigenproblem, of the form A*x=(lambda)*B*x. B is also positive definite.

Parameters
[in,out]a(n, n)
[in,out]b(n, n)
[out]e(n)
[out]v(n, n)
[in]preserve_matIf true, the matrix a and b on exit are the same
[in,out]bofBomb on failure.

Definition at line 2370 of file lalg_adv.F90.

◆ deigensolve()

subroutine lalg_adv_oct_m::deigensolve ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 2490 of file lalg_adv.F90.

◆ deigensolve_tridiagonal()

subroutine lalg_adv_oct_m::deigensolve_tridiagonal ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian case, the matrix is assumed to be real symmetric (even if stored in complex)

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 2560 of file lalg_adv.F90.

◆ dlowest_eigensolve()

subroutine lalg_adv_oct_m::dlowest_eigensolve ( integer, intent(in)  k,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
real(real64), dimension(:, :), intent(out), contiguous  v,
logical, intent(in)  preserve_mat 
)
private

Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem, of the form A*x=(lambda)*x. Here A is assumed to be symmetric.

Parameters
[in]kNumber of eigenvalues requested
[in]nDimensions of a
[in,out]a(n, n)
[out]e(n) The first k elements contain the selected eigenvalues in ascending order.
[out]v(n, k)
[in]preserve_matIf true, the matrix a and b on exit are the same

Definition at line 2639 of file lalg_adv.F90.

◆ ddeterminant()

real(real64) function lalg_adv_oct_m::ddeterminant ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), target, contiguous  a,
logical, intent(in)  preserve_mat 
)
private

Invert a real symmetric or complex Hermitian square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 2728 of file lalg_adv.F90.

◆ ddirect_inverse()

subroutine lalg_adv_oct_m::ddirect_inverse ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), intent(out), optional  det 
)
private

Invert a real symmetric or complex Hermitian square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 2775 of file lalg_adv.F90.

◆ dsym_inverse()

subroutine lalg_adv_oct_m::dsym_inverse ( character(1), intent(in)  uplo,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a 
)
private

Invert a real/complex symmetric square matrix a.

Parameters
[in,out]a(n,n)

Definition at line 2834 of file lalg_adv.F90.

◆ dlinsyssolve()

subroutine lalg_adv_oct_m::dlinsyssolve ( integer, intent(in)  n,
integer, intent(in)  nrhs,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:, :), intent(inout), contiguous  b,
real(real64), dimension(:, :), intent(out), contiguous  x 
)
private

compute the solution to a real system of linear equations A*X = B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices.

Parameters
[in,out]a(n, n)
[in,out]b(n, nrhs)
[out]x(n, nrhs)

Definition at line 2885 of file lalg_adv.F90.

◆ dsingular_value_decomp()

subroutine lalg_adv_oct_m::dsingular_value_decomp ( integer, intent(in)  m,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:, :), intent(out), contiguous  u,
real(real64), dimension(:, :), intent(out), contiguous  vt,
real(real64), dimension(:), intent(out), contiguous  sg_values,
logical, intent(in), optional  preserve_mat 
)
private

Computes the singular value decomposition of a real M x N matrix a.

Parameters
[in,out]a(m,n)
[out]vt(m,m) (n,n)
[out]sg_values(min(m,n))

Definition at line 2963 of file lalg_adv.F90.

◆ dsvd_inverse()

subroutine lalg_adv_oct_m::dsvd_inverse ( integer, intent(in)  m,
integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), intent(in), optional  threshold 
)
private

Computes the inverse of a real M x N matrix, a, using the SVD decomposition.

Parameters
[in,out]aInput (m,n)

Definition at line 3042 of file lalg_adv.F90.

◆ dlalg_pseudo_inverse()

subroutine lalg_adv_oct_m::dlalg_pseudo_inverse ( real(real64), dimension(:, :), intent(inout), allocatable  a,
real(real64), intent(in), optional  threshold 
)
private

Invert a matrix with the Moore-Penrose pseudo-inverse.

SVD is used to find the U, V and Sigma matrices:

\[ A = U \Sigma V^\dagger \]

Diagonal terms in Sigma <= threshold are set to zero, and the inverse is constructed as:

\[] A^{-1} \approx V \Sigma U^\dagger \]

Parameters
[in,out]aInput: (m, n)

Definition at line 3108 of file lalg_adv.F90.

◆ dmatrix_rank_svd()

integer function lalg_adv_oct_m::dmatrix_rank_svd ( real(real64), dimension(:, :), intent(inout)  a,
logical, intent(in), optional  preserve_mat,
real(real64), intent(in), optional  tol 
)
private

Compute the rank of the matrix A using SVD.

The rank is equal to the number of non-zero singular values in the diagonal matrix of the SVD decomposition.

Parameters
[in,out]aInput: (m, n)
[in]preserve_matPreserve input A
[in]tolTolerance defining
Returns
Rank of matrix A

Definition at line 3174 of file lalg_adv.F90.

◆ dupper_triangular_inverse()

subroutine lalg_adv_oct_m::dupper_triangular_inverse ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a 
)
private

Calculate the inverse of a real/complex upper triangular matrix (in unpacked storage). (lower triangular would be a trivial variant of this)

Parameters
[in,out]a(n,n)

Definition at line 3215 of file lalg_adv.F90.

◆ dleast_squares_vec()

subroutine lalg_adv_oct_m::dleast_squares_vec ( integer, intent(in)  nn,
real(real64), dimension(:, :), intent(inout), target, contiguous  aa,
real(real64), dimension(:), intent(in), contiguous  bb,
real(real64), dimension(:), intent(out), contiguous  xx,
logical, intent(in)  preserve_mat 
)
private

Definition at line 3263 of file lalg_adv.F90.

◆ deigensolve_parallel()

subroutine lalg_adv_oct_m::deigensolve_parallel ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
real(real64), dimension(:), intent(out), contiguous  e,
logical, intent(inout), optional  bof,
integer, intent(out), optional  err_code 
)
private

Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenproblem in parallel using ScaLAPACK or ELPA on all processors n: dimension of matrix a: input matrix, on exit: contains eigenvectors e: eigenvalues.

Parameters
[in,out]a(n,n)
[out]e(n)
[in,out]bofBomb on failure.

Definition at line 3335 of file lalg_adv.F90.

◆ dinverse()

subroutine lalg_adv_oct_m::dinverse ( integer, intent(in)  n,
real(real64), dimension(:, :), intent(inout), contiguous  a,
character(len=3), intent(in)  method,
real(real64), intent(out), optional  det,
real(real64), intent(in), optional  threshold,
character(len=1), intent(in), optional  uplo 
)
private

An interface to different method to invert a matrix.

The possible methods are: svd, dir, sym, upp For the SVD, an optional argument threshold an be specified For the direct inverse, an optional output determinant can be obtained For the symmetric matrix case, the optional argument uplo must be specified

Parameters
[in,out]a(n,n)
[out]detDeterminant of the matrix. Direct inversion only
[in]thresholdThreshold for the SVD pseudoinverse
[in]uploIs the symmetric matrix stored in the upper or lower part?

Definition at line 3358 of file lalg_adv.F90.

◆ dlalg_matrix_function()

subroutine lalg_adv_oct_m::dlalg_matrix_function ( integer, intent(in)  n,
real(real64), intent(in)  factor,
real(real64), dimension(:, :), intent(in)  a,
real(real64), dimension(:, :), intent(inout)  fun_a,
  fun,
logical, intent(in)  hermitian,
logical, intent(in), optional  tridiagonal 
)
private

This routine calculates a function of a matrix by using an eigenvalue decomposition.

For the hermitian case:

\[ A = V D V^T \implies fun(A) = V fun(D) V^T \]

and in general

\[ A = V D V^-1 \implies fun(A) = V fun(D) V^-1 \]

where \(V\) are the eigenvectors, and \(D\) is a diagonal matrix containing the eigenvalues.

In addition, this function can compute \(fun(factor*A)\) for a complex factor.

This is slow but it is simple to implement, and for the moment it does not affect performance.

Parameters
[in]ndimension of the matrix A
[in]factorcomplex factor
[in]amatrix A
[in,out]fun_afun(A)
[in]hermitianis the matrix hermitian?
[in]tridiagonalis the matrix tridiagonal?

Definition at line 3406 of file lalg_adv.F90.