28 use,
intrinsic :: ieee_exceptions
30 use,
intrinsic :: iso_fortran_env
165 real(real64) function sfmin()
167 real(real64) function dlamch(cmach)
170 character(1),
intent(in) :: cmach
177 subroutine lalg_dgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
178 character(1),
intent(in) :: jobvl, jobvr
179 integer,
intent(in) :: n, lda, ldvl, ldvr, lwork
180 real(real64),
contiguous,
intent(inout) :: a(:, :)
181 complex(real64),
contiguous,
intent(out) :: w(:)
182 real(real64),
contiguous,
intent(out) :: vl(:, :), vr(:, :)
183 real(real64),
contiguous,
intent(out) :: work(:)
184 real(real64),
contiguous,
intent(out) :: rwork(:)
185 integer,
intent(out) :: info
187 real(real64),
allocatable :: wr(:), wi(:)
189 logical :: halting_mode(size(ieee_all))
194 safe_allocate(wr(1:n))
195 safe_allocate(wi(1:n))
201 call ieee_get_halting_mode(ieee_all, halting_mode)
202 call ieee_set_halting_mode(ieee_all, .false.)
204 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)
206 call ieee_set_halting_mode(ieee_all, halting_mode)
208 w(1:n) = cmplx(wr(1:n), wi(1:n), real64)
210 safe_deallocate_a(wr)
211 safe_deallocate_a(wi)
216 subroutine lalg_zgeev(jobvl, jobvr, n, a, lda, w, vl, ldvl, vr, ldvr, work, lwork, rwork, info)
217 character(1),
intent(in) :: jobvl, jobvr
218 integer,
intent(in) :: n, lda, ldvl, ldvr, lwork
219 complex(real64),
contiguous,
intent(inout) :: a(:, :)
220 complex(real64),
contiguous,
intent(out) :: w(:)
221 complex(real64),
contiguous,
intent(out) :: vl(:, :), vr(:, :)
222 real(real64),
contiguous,
intent(out) :: rwork(:)
223 complex(real64),
contiguous,
intent(out) :: work(:)
224 integer,
intent(out) :: info
228 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)
250 subroutine zlalg_exp(nn, pp, aa, ex, hermitian)
251 integer,
intent(in) :: nn
252 complex(real64),
intent(in) :: pp
253 complex(real64),
contiguous,
intent(in) :: aa(:, :)
254 complex(real64),
contiguous,
intent(inout) :: ex(:, :)
255 logical,
intent(in) :: hermitian
257 complex(real64),
allocatable :: evectors(:, :), zevalues(:)
258 real(real64),
allocatable :: evalues(:)
264 safe_allocate(evectors(1:nn, 1:nn))
267 safe_allocate(evalues(1:nn))
268 safe_allocate(zevalues(1:nn))
270 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
274 zevalues(1:nn) =
exp(pp*evalues(1:nn))
277 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
280 ex(:, :) = matmul(evectors(:, :), ex(:, :))
282 safe_deallocate_a(evalues)
283 safe_deallocate_a(zevalues)
285 safe_allocate(zevalues(1:nn))
287 evectors(1:nn, 1:nn) = aa(1:nn, 1:nn)
291 zevalues(1:nn) =
exp(pp*zevalues(1:nn))
293 ex(1:nn, 1:nn) = evectors(1:nn, 1:nn)
298 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
301 ex(:, :) = matmul(ex(:, :), evectors(:, :))
303 safe_deallocate_a(zevalues)
306 safe_deallocate_a(evectors)
328 subroutine zlalg_phi(nn, pp, aa, ex, hermitian)
329 integer,
intent(in) :: nn
330 complex(real64),
intent(in) :: pp
331 complex(real64),
contiguous,
intent(in) :: aa(:, :)
332 complex(real64),
contiguous,
intent(inout) :: ex(:, :)
333 logical,
intent(in) :: hermitian
335 complex(real64),
allocatable :: evectors(:, :), zevalues(:)
336 real(real64),
allocatable :: evalues(:)
342 safe_allocate(evectors(1:nn, 1:nn))
345 safe_allocate(evalues(1:nn))
346 safe_allocate(zevalues(1:nn))
348 evectors(:, :) = aa(:, :)
353 zevalues(ii) = (
exp(pp*evalues(ii)) - m_z1) / (pp*evalues(ii))
357 ex(1:nn, ii) = zevalues(1:nn)*conjg(evectors(ii, 1:nn))
360 ex(:, :) = matmul(evectors(:, :), ex(:, :))
362 safe_deallocate_a(evalues)
363 safe_deallocate_a(zevalues)
365 safe_allocate(zevalues(1:nn))
367 evectors(:, :) = aa(:, :)
372 zevalues(ii) = (
exp(pp*zevalues(ii)) - m_z1) / (pp*zevalues(ii))
375 ex(:, :) = evectors(:, :)
380 evectors(1:nn, ii) = zevalues(1:nn)*evectors(1:nn, ii)
383 ex(:, :) = matmul(ex(:, :), evectors(:, :))
385 safe_deallocate_a(zevalues)
391 complex(real64) function lalg_zdni(eigenvec, alpha, beta)
392 integer,
intent(in) :: alpha, beta
393 complex(real64),
intent(in) :: eigenvec(2)
394 lalg_zdni = conjg(eigenvec(alpha)) * eigenvec(beta)
397 complex(real64) function lalg_zduialpha(eigenvec, mmatrix, alpha, gamma, delta)
398 integer,
intent(in) :: alpha, gamma, delta
399 complex(real64),
intent(in) :: eigenvec(2), mmatrix(2, 2)
403 complex(real64) function lalg_zd2ni(eigenvec, mmatrix, alpha, beta, gamma, delta)
404 integer,
intent(in) :: alpha, beta, gamma, delta
405 complex(real64),
intent(in) :: eigenvec(2), mmatrix(2, 2)
406 lalg_zd2ni = conjg(mmatrix(alpha, delta) * eigenvec(gamma)) * eigenvec(beta) + &
407 conjg(eigenvec(alpha)) * mmatrix(beta, gamma) * eigenvec(delta)
416 integer,
intent(in) :: m, n
417 real(real64),
contiguous,
intent(in) :: sg_values(:)
418 tol = m_epsilon * m * n * maxval(sg_values)
428 integer,
intent(in) :: n
429 real(real64),
intent(in) :: a(1:n, 1:n)
430 real(real64) :: p(1:n, 1:n)
432 real(real64) :: ata(1:n, 1:n)
436 ata = matmul(transpose(a), a)
448 integer,
intent(in) :: n
449 complex(real64),
intent(in) :: t(:, :)
451 complex(real64) function fun(z)
453 complex(real64),
intent(in) :: z
456 complex(real64),
intent(in) :: factor
457 complex(real64),
intent(inout) :: col(:)
458 complex(real64),
optional,
intent(in) :: factor2
459 complex(real64),
optional,
intent(inout) :: col2(:)
461 real(real64),
allocatable :: evectors(:, :), evalues(:)
466 safe_allocate(evectors(1:n, 1:n))
467 safe_allocate(evalues(1:n))
471 evectors(i, i) = real(t(i, i), real64)
472 if (i > 1) evectors(i - 1, i) = real(t(i - 1, i), real64)
476 col(1:n) = matmul(evectors, [(fun(factor*evalues(i))*evectors(1, i), i = 1, n)])
477 if (
present(col2))
then
478 col2(1:n) = matmul(evectors, [(fun(factor2*evalues(i))*evectors(1, i), i = 1, n)])
481 safe_deallocate_a(evectors)
482 safe_deallocate_a(evalues)
493 integer,
intent(in) :: n
494 complex(real64),
intent(in) :: h(:, :)
496 complex(real64) function fun(z)
498 complex(real64),
intent(in) :: z
501 complex(real64),
intent(in) :: factor
502 complex(real64),
intent(inout) :: col(:)
503 complex(real64),
optional,
intent(in) :: factor2
504 complex(real64),
optional,
intent(inout) :: col2(:)
506 complex(real64),
allocatable :: evectors(:, :), evalues(:), rhs(:, :), y(:, :)
507 real(real64),
parameter :: tol_defective = 1e-12
513 safe_allocate(evectors(1:n, 1:n))
514 safe_allocate(evalues(1:n))
515 safe_allocate(rhs(1:n, 1:1))
516 safe_allocate(y(1:n, 1:1))
518 evectors(1:n, 1:n) = h(1:n, 1:n)
523 if (maxval(abs(evalues)) > tol_defective) tol = tol * maxval(abs(evalues))
525 if (abs(evalues(i+1) - evalues(i)) < tol)
then
526 message(1) =
"Potential defective case detected (repeated eigenvalues)."
527 write(message(2),
'(a,i3,a)')
"Eigenvalue ", i,
" is repeated within tolerance."
528 call messages_warning(2)
537 col(1:n) = matmul(evectors, [(fun(factor*evalues(i))*y(i, 1), i = 1, n)])
538 if (
present(col2))
then
539 col2(1:n) = matmul(evectors, [(fun(factor2*evalues(i))*y(i, 1), i = 1, n)])
542 safe_deallocate_a(evectors)
543 safe_deallocate_a(evalues)
544 safe_deallocate_a(rhs)
551#include "complex.F90"
552#include "lalg_adv_lapack_inc.F90"
556#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://www....
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.
subroutine dqr_factorization(A, jpvt, tau, info, bof)
Compute a QR factorization with column pivoting of matrix A: A*P = Q*R.
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, public lalg_hessenberg_function_first_column(n, h, fun, factor, col, factor2, col2)
First column of fun(factor*H) for a diagonalizable complex upper Hessenberg matrix H.
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.
subroutine zqr_factorization(A, jpvt, tau, info, bof)
Compute a QR factorization with column pivoting of matrix A: A*P = Q*R.
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, public lalg_tridiagonal_function_first_column(n, t, fun, factor, col, factor2, col2)
First column of fun(factor*T) for a real symmetric tridiagonal matrix T.
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 (pseudo-)inverse of a square N 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 (pseudo-)inverse of a square N 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.
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
This module contains interfaces for ScaLAPACK routines Interfaces are from http://www....
This module is intended to contain "only mathematical" functions and procedures.
This module is intended to contain simple general-purpose utility functions and procedures.