28 use,
intrinsic :: ieee_exceptions
30 use,
intrinsic :: iso_fortran_env
160 real(real64) function sfmin()
162 real(real64) function dlamch(cmach)
165 character(1),
intent(in) :: cmach
172 subroutine lalg_dgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
173 character(1),
intent(in) :: jobvl, jobvr
174 integer,
intent(in) :: n, lda, ldvl, ldvr, lwork
175 real(real64),
intent(inout) :: a(:, :)
176 complex(real64),
intent(out) :: w(:)
177 real(real64),
intent(out) :: vl(:, :), vr(:, :)
178 real(real64),
intent(out) :: work(:)
179 real(real64),
intent(out) :: rwork(:)
180 integer,
intent(out) :: info
182 real(real64),
allocatable :: wr(:), wi(:)
184 logical :: halting_mode(size(ieee_all))
189 safe_allocate(wr(1:n))
190 safe_allocate(wi(1:n))
196 call ieee_get_halting_mode(ieee_all, halting_mode)
197 call ieee_set_halting_mode(ieee_all, .false.)
199 call dgeev(jobvl, jobvr, n, a(1, 1), lda, wr(1), wi(1), vl(1, 1), ldvl, vr(1, 1), ldvr, work(1), lwork, info)
201 call ieee_set_halting_mode(ieee_all, halting_mode)
203 w(1:n) = cmplx(wr(1:n), wi(1:n), real64)
205 safe_deallocate_a(wr)
206 safe_deallocate_a(wi)
211 subroutine lalg_zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
212 character(1),
intent(in) :: jobvl, jobvr
213 integer,
intent(in) :: n, lda, ldvl, ldvr, lwork
214 complex(real64),
intent(inout) :: a(:, :)
215 complex(real64),
intent(out) :: w(:)
216 complex(real64),
intent(out) :: vl(:, :), vr(:, :)
217 real(real64),
intent(out) :: rwork(:)
218 complex(real64),
intent(out) :: work(:)
219 integer,
intent(out) :: info
223 call zgeev(jobvl, jobvr, n, a(1, 1), lda, w(1), vl(1, 1), ldvl, vr(1, 1), ldvr, work(1), lwork, rwork(1), info)
245 subroutine zlalg_exp(nn, pp, aa, ex, hermitian)
246 integer,
intent(in) :: nn
247 complex(real64),
intent(in) :: pp
248 complex(real64),
intent(in) :: aa(:, :)
249 complex(real64),
intent(inout) :: ex(:, :)
250 logical,
intent(in) :: hermitian
252 complex(real64),
allocatable :: evectors(:, :), zevalues(:)
253 real(real64),
allocatable :: evalues(:)
259 safe_allocate(evectors(1:nn, 1:nn))
262 safe_allocate(evalues(1:nn))
263 safe_allocate(zevalues(1:nn))
265 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
269 zevalues(1:nn) =
exp(pp*evalues(1:nn))
272 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
275 ex(:, :) = matmul(evectors(:, :), ex(:, :))
277 safe_deallocate_a(evalues)
278 safe_deallocate_a(zevalues)
280 safe_allocate(zevalues(1:nn))
282 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
286 zevalues(1:nn) =
exp(pp*zevalues(1:nn))
288 ex(1:nn, 1:nn) = evectors(1:nn, 1:nn)
293 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
296 ex(:, :) = matmul(ex(:, :), evectors(:, :))
298 safe_deallocate_a(zevalues)
301 safe_deallocate_a(evectors)
323 subroutine zlalg_phi(nn, pp, aa, ex, hermitian)
324 integer,
intent(in) :: nn
325 complex(real64),
intent(in) :: pp
326 complex(real64),
intent(in) :: aa(:, :)
327 complex(real64),
intent(inout) :: ex(:, :)
328 logical,
intent(in) :: hermitian
330 complex(real64),
allocatable :: evectors(:, :), zevalues(:)
331 real(real64),
allocatable :: evalues(:)
337 safe_allocate(evectors(1:nn, 1:nn))
340 safe_allocate(evalues(1:nn))
341 safe_allocate(zevalues(1:nn))
343 evectors(:, :) = aa(:, :)
348 zevalues(ii) = (
exp(pp*evalues(ii)) - m_z1) / (pp*evalues(ii))
352 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
355 ex(:, :) = matmul(evectors(:, :), ex(:, :))
357 safe_deallocate_a(evalues)
358 safe_deallocate_a(zevalues)
360 safe_allocate(zevalues(1:nn))
362 evectors(:, :) = aa(:, :)
367 zevalues(ii) = (
exp(pp*zevalues(ii)) - m_z1) / (pp*zevalues(ii))
370 ex(:, :) = evectors(:, :)
375 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
378 ex(:, :) = matmul(ex(:, :), evectors(:, :))
380 safe_deallocate_a(zevalues)
386 complex(real64) function lalg_zdni(eigenvec, alpha, beta)
387 integer,
intent(in) :: alpha, beta
388 complex(real64),
intent(in) :: eigenvec(2)
389 lalg_zdni = conjg(eigenvec(alpha)) * eigenvec(beta)
392 complex(real64) function lalg_zduialpha(eigenvec, mmatrix, alpha, gamma, delta)
393 integer,
intent(in) :: alpha, gamma, delta
394 complex(real64),
intent(in) :: eigenvec(2), mmatrix(2, 2)
398 complex(real64) function lalg_zd2ni(eigenvec, mmatrix, alpha, beta, gamma, delta)
399 integer,
intent(in) :: alpha, beta, gamma, delta
400 complex(real64),
intent(in) :: eigenvec(2), mmatrix(2, 2)
401 lalg_zd2ni = conjg(mmatrix(alpha, delta) * eigenvec(gamma)) * eigenvec(beta) + &
402 conjg(eigenvec(alpha)) * mmatrix(beta, gamma) * eigenvec(delta)
411 integer,
intent(in) :: m, n
412 real(real64),
intent(in) :: sg_values(:)
413 tol = m_epsilon * m * n * maxval(sg_values)
423 integer,
intent(in) :: n
424 real(real64),
intent(in) :: a(1:n, 1:n)
425 real(real64) :: p(1:n, 1:n)
427 real(real64) :: ata(1:n, 1:n)
431 ata = matmul(transpose(a), a)
438#include "complex.F90"
439#include "lalg_adv_lapack_inc.F90"
443#include "lalg_adv_lapack_inc.F90"
Note that lalg_determinant and lalg_inverse are just wrappers over the same routine.
double exp(double __x) __attribute__((__nothrow__
This module contains interfaces for BLACS routines Interfaces are from http:
This module provides the BLACS processor grid.
This module contains interfaces for BLAS routines You should not use these routines directly....
complex(real64) function, public lalg_zd2ni(eigenvec, mmatrix, alpha, beta, gamma, delta)
integer function zmatrix_rank_svd(a, preserve_mat, tol)
Compute the rank of the matrix A using SVD.
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 gener...
complex(real64) function zdeterminant(n, a, preserve_mat)
Invert a real symmetric or complex Hermitian square matrix a.
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) e...
subroutine zlinsyssolve(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 ...
subroutine, public zlalg_exp(nn, pp, aa, ex, hermitian)
pure real(real64) function, public pseudoinverse_default_tolerance(m, n, sg_values)
Computes the default Moore-Penrose pseudoinverse tolerance for zeroing.
subroutine deigensolve_parallel(n, a, e, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenprobl...
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 generalize...
subroutine zlalg_pseudo_inverse(a, threshold)
Invert a matrix with the Moore-Penrose pseudo-inverse.
subroutine zeigensolve(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.
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.
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) e...
subroutine deigensolve_tridiagonal(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian c...
subroutine zinverse(n, a, method, det, threshold, uplo)
An interface to different method to invert a matrix.
real(real64) function sfmin()
Auxiliary function.
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 ...
subroutine zsingular_value_decomp(m, n, a, u, vt, sg_values, preserve_mat)
Computes the singular value decomposition of a real M x N matrix a.
subroutine dcholesky(n, a, bof, err_code)
Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a,...
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.
subroutine deigensolve(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric or hermitian square matrix A.
subroutine dcholesky_pivoted(A, piv, rank, tol, work, UL, bof, info)
Compute the Cholesky factorization with complete pivoting of a real symmetric or complex Hermitian po...
subroutine zeigensolve_tridiagonal(n, a, e, bof, err_code)
Computes all eigenvalues and eigenvectors of a real symmetric tridiagonal matrix. For the Hermitian c...
subroutine zlowest_eigensolve(k, n, a, e, v, preserve_mat)
Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem,...
complex(real64) function, public lalg_zduialpha(eigenvec, mmatrix, alpha, gamma, delta)
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 generalize...
subroutine dleast_squares_vec(nn, aa, bb, xx, preserve_mat)
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 gener...
subroutine zcholesky(n, a, bof, err_code)
Compute the Cholesky decomposition of real symmetric or complex Hermitian positive definite matrix a,...
complex(real64) function, public lalg_zdni(eigenvec, alpha, beta)
subroutine zleast_squares_vec(nn, aa, bb, xx, preserve_mat)
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 ...
subroutine lalg_zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
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.
integer function dmatrix_rank_svd(a, preserve_mat, tol)
Compute the rank of the matrix A using SVD.
subroutine dinverse(n, a, method, det, threshold, uplo)
An interface to different method to invert a matrix.
subroutine zeigensolve_parallel(n, a, e, bof, err_code)
Computes all the eigenvalues and the eigenvectors of a real symmetric or complex Hermitian eigenprobl...
real(real64) function ddeterminant(n, a, preserve_mat)
Invert a real symmetric or complex Hermitian square matrix a.
subroutine lalg_dgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
subroutine dlowest_eigensolve(k, n, a, e, v, preserve_mat)
Computes the k lowest eigenvalues and the eigenvectors of a standard symmetric-definite eigenproblem,...
subroutine dsvd_inverse(m, n, a, threshold)
Computes the inverse of a real M x N matrix, a, using the SVD decomposition.
subroutine, public zlalg_phi(nn, pp, aa, ex, hermitian)
subroutine zcholesky_pivoted(A, piv, rank, tol, work, UL, bof, info)
Compute the Cholesky factorization with complete pivoting of a real symmetric or complex Hermitian po...
subroutine dlalg_pseudo_inverse(a, threshold)
Invert a matrix with the Moore-Penrose pseudo-inverse.
subroutine zsvd_inverse(m, n, a, threshold)
Computes the inverse of a real M x N matrix, a, using the SVD decomposition.
This module contains interfaces for LAPACK routines.
This module is intended to contain "only mathematical" functions and procedures.
This module contains interfaces for ScaLAPACK routines Interfaces are from http:
This module is intended to contain "only mathematical" functions and procedures.
This module is intended to contain simple general-purpose utility functions and procedures.