56#if defined (__HAS_IEEE_EXCEPTIONS)
57 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
58 ieee_set_halting_mode, &
61#include "../base/base_uses.f90"
66 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_cfm_diag'
74 LOGICAL :: generalized = .false.
75 COMPLEX(KIND=dp),
ALLOCATABLE :: work(:)
76 REAL(kind=
dp),
ALLOCATABLE :: evals(:), rwork(:)
77 INTEGER,
ALLOCATABLE :: iwork(:)
95 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
96 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
98 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd'
102 CALL timeset(routinen, handle)
123 CALL cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
129 CALL timestop(handle)
142 SUBROUTINE cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
144 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
145 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
147 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd_base'
149 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: work
150 COMPLEX(KIND=dp),
DIMENSION(:, :), &
152 INTEGER :: handle, info, liwork, &
154 INTEGER,
DIMENSION(:),
POINTER :: iwork
155 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rwork
156#if defined(__parallel)
157 INTEGER,
DIMENSION(9) :: descm, descv
158 COMPLEX(KIND=dp),
DIMENSION(:, :), &
161#if defined (__HAS_IEEE_EXCEPTIONS)
162 LOGICAL,
DIMENSION(5) :: halt
165 CALL timeset(routinen, handle)
167 n = matrix%matrix_struct%nrow_global
168 m => matrix%local_data
169 ALLOCATE (iwork(1), rwork(1), work(1))
175#if defined(__parallel)
176 v => eigenvectors%local_data
177 descm(:) = matrix%matrix_struct%descriptor(:)
178 descv(:) = eigenvectors%matrix_struct%descriptor(:)
179 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
180 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
183 lwork = ceiling(real(work(1), kind=
dp)) + 1000
185 lrwork = ceiling(rwork(1)) + 1000000
188 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
189 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
190 lwork = ceiling(real(work(1), kind=
dp))
191 lrwork = ceiling(rwork(1))
195 DEALLOCATE (iwork, rwork, work)
196 ALLOCATE (iwork(liwork), rwork(lrwork), work(lwork))
200#if defined (__HAS_IEEE_EXCEPTIONS)
201 CALL ieee_get_halting_mode(ieee_all, halt)
202 CALL ieee_set_halting_mode(ieee_all, .false.)
204#if defined(__parallel)
205 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
206 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
208 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
209 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
210 eigenvectors%local_data = matrix%local_data
212#if defined (__HAS_IEEE_EXCEPTIONS)
213 CALL ieee_set_halting_mode(ieee_all, halt)
216 DEALLOCATE (iwork, rwork, work)
217 IF (info /= 0) cpabort(
"Diagonalisation of a complex matrix failed")
219 CALL timestop(handle)
221 END SUBROUTINE cp_cfm_heevd_base
238 SUBROUTINE cp_cfm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
240 TYPE(
cp_cfm_type),
INTENT(INOUT),
OPTIONAL,
TARGET :: work
241 REAL(kind=
dp),
INTENT(IN) :: exponent, threshold
242 INTEGER,
INTENT(OUT),
OPTIONAL :: n_dependent
243 LOGICAL,
INTENT(IN),
OPTIONAL :: verbose
244 REAL(kind=
dp),
DIMENSION(2),
INTENT(OUT),
OPTIONAL :: eigvals
246 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_cfm_power'
248 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalue_scales
249 INTEGER :: handle, i, ncol_global, ndep, nrow_global
250 LOGICAL :: my_verbose
251 REAL(kind=
dp) :: condition_number, sqrt_power_eval
252 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues
256 CALL timeset(routinen, handle)
258 CALL cp_cfm_get_info(matrix, nrow_global=nrow_global, ncol_global=ncol_global)
259 cpassert(nrow_global == ncol_global)
260 cpassert(threshold >= 0.0_dp)
261 IF (
PRESENT(work))
THEN
264 CALL cp_cfm_create(local_work, matrix%matrix_struct, set_zero=.true.)
265 cfm_work => local_work
267 ALLOCATE (eigenvalues(nrow_global), eigenvalue_scales(nrow_global))
270 IF (
PRESENT(eigvals)) eigvals = [eigenvalues(1), eigenvalues(nrow_global)]
275 DO i = 1, nrow_global
277 IF (eigenvalues(i) < threshold .OR. eigenvalues(i) <= 0.0_dp)
THEN
278 sqrt_power_eval = 0.0_dp
281 sqrt_power_eval = eigenvalues(i)**(0.5_dp*exponent)
283 eigenvalue_scales(i) = cmplx(sqrt_power_eval, 0.0_dp, kind=
dp)
285 IF (
PRESENT(n_dependent)) n_dependent = ndep
291 cfm_work, cfm_work,
z_zero, matrix)
294 IF (
PRESENT(verbose)) my_verbose = verbose
295 IF (matrix%matrix_struct%para_env%is_source() .AND. my_verbose)
THEN
296 condition_number = huge(0.0_dp)
297 IF (eigenvalues(1) /= 0.0_dp) condition_number = abs(eigenvalues(nrow_global)/eigenvalues(1))
299 "CP_CFM_POWER: smallest eigenvalue:", eigenvalues(1), &
300 "CP_CFM_POWER: largest eigenvalue: ", eigenvalues(nrow_global), &
301 "CP_CFM_POWER: condition number: ", condition_number
302 IF (eigenvalues(1) <= 0.0_dp)
THEN
304 "WARNING: matrix has a non-positive eigenvalue, tighten EPS_DEFAULT"
306 IF (condition_number > 1.0e12_dp)
THEN
308 "WARNING: high condition number => possibly ill-conditioned matrix"
312 DEALLOCATE (eigenvalues, eigenvalue_scales)
316 CALL timestop(handle)
327 SUBROUTINE check_generalized_diag(overlap, eigenvectors, scratch, nvec)
330 TYPE(
cp_cfm_type),
INTENT(INOUT) :: overlap, scratch
331 INTEGER,
INTENT(IN) :: nvec
333 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_generalized_diag'
335 CHARACTER(LEN=default_string_length) :: diag_type_name
336 COMPLEX(KIND=dp) :: gold, test
337 INTEGER :: handle, i, j, ncol, nrow, output_unit
338 REAL(kind=
dp) :: eps, eps_abort, eps_warning
339#if defined(__parallel)
341 INTEGER :: il, jl, ipcol, iprow, &
342 mypcol, myprow, npcol, nprow
343 INTEGER,
DIMENSION(9) :: desca
346 CALL timeset(routinen, handle)
349 CALL timestop(handle)
355 eps_abort = 10.0_dp*eps_warning
357 nrow = eigenvectors%matrix_struct%nrow_global
358 ncol = min(eigenvectors%matrix_struct%ncol_global, nvec)
367#if defined(__parallel)
368 context => overlap%matrix_struct%context
369 myprow = context%mepos(1)
370 mypcol = context%mepos(2)
371 nprow = context%num_pe(1)
372 npcol = context%num_pe(2)
373 desca(:) = overlap%matrix_struct%descriptor(:)
374 outer:
DO j = 1, ncol
376 CALL infog2l(i, j, desca, nprow, npcol, myprow, mypcol, il, jl, iprow, ipcol)
377 IF ((iprow == myprow) .AND. (ipcol == mypcol))
THEN
379 test = overlap%local_data(il, jl)
380 eps = abs(test - gold)
381 IF (eps > eps_warning)
EXIT outer
386 outer:
DO j = 1, ncol
389 test = overlap%local_data(i, j)
390 eps = abs(test - gold)
391 IF (eps > eps_warning)
EXIT outer
396 IF (eps > eps_warning)
THEN
398 diag_type_name =
"HEGVX"
400 diag_type_name =
"CUSOLVER"
402 diag_type_name =
"ELPA"
405 diag_type_name =
"DLAF"
408 diag_type_name =
"generalized eigensolver"
410 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,T2,A,I0,A,I0,A,ES10.3,/,T2,A,F0.0,A,ES10.3)") &
411 "The generalized eigenvectors returned by "//trim(diag_type_name)//
" are not S-orthonormal", &
412 "Absolute deviation of matrix element (", i,
", ", j,
") is ", eps, &
413 "The deviation from the expected value ", real(gold, kind=
dp),
" is", eps
414 IF (eps > eps_abort)
THEN
415 CALL cp_abort(__location__, &
416 "ERROR in "//routinen//
": Check of generalized matrix diagonalization failed")
418 cpwarn(
"Check of generalized matrix diagonalization failed in routine "//routinen)
422 CALL timestop(handle)
424 END SUBROUTINE check_generalized_diag
438 SUBROUTINE cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
440 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
441 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues
443 LOGICAL,
INTENT(IN),
OPTIONAL :: lowest_subset
445 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig'
447 INTEGER :: handle, nao, nmo
448 LOGICAL :: check_eigenvectors, use_lowest_subset
449 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
452 CALL timeset(routinen, handle)
455 ALLOCATE (evals(nao))
456 nmo =
SIZE(eigenvalues)
458 use_lowest_subset = .false.
459 IF (
PRESENT(lowest_subset)) use_lowest_subset = lowest_subset .AND. nmo < nao
460#if !defined(__parallel)
461 use_lowest_subset = .false.
464 IF (use_lowest_subset)
THEN
465#if defined(__parallel)
466 IF (check_eigenvectors)
THEN
471 CALL cp_cfm_geeig_scalapack(amatrix, bmatrix, work, evals(1:nmo))
472 IF (check_eigenvectors)
THEN
473 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
482 IF (check_eigenvectors)
THEN
488 IF (check_eigenvectors)
THEN
489 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
505 IF (check_eigenvectors)
THEN
511 IF (check_eigenvectors)
THEN
512 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
517#if defined(__parallel)
521 IF (check_eigenvectors)
THEN
526 CALL cp_cfm_geeig_scalapack(amatrix, bmatrix, work, evals)
527 IF (check_eigenvectors)
THEN
528 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
542 CALL cp_cfm_heevd(matrix=amatrix, eigenvectors=work, eigenvalues=evals)
548 eigenvalues(1:nmo) = evals(1:nmo)
552 CALL timestop(handle)
563 SUBROUTINE cp_cfm_geeig_scalapack(amatrix, bmatrix, eigenvectors, eigenvalues)
565 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
566 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
568 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_scalapack'
570#if defined(__parallel)
571 REAL(kind=
dp),
PARAMETER :: orfac = -1.0_dp, &
575 COMPLEX(KIND=dp),
DIMENSION(:),
ALLOCATABLE :: work
576 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: a, b, z
577 INTEGER :: handle, info, liwork, lwork, lrwork, &
578 m, n, nb, neig, npcol, nprow, nz
579 INTEGER,
DIMENSION(9) :: desca, descb, descz
580 INTEGER,
DIMENSION(:),
ALLOCATABLE :: iclustr, ifail, iwork
581 REAL(kind=
dp) :: abstol
582 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: gap, rwork, w
584 INTEGER :: mq0, nn, np0, npe
585 INTEGER,
EXTERNAL :: iceil, numroc
586 REAL(kind=
dp),
EXTERNAL :: dlamch
587#if defined (__HAS_IEEE_EXCEPTIONS)
588 LOGICAL,
DIMENSION(5) :: halt
594 CALL timeset(routinen, handle)
596#if defined(__parallel)
597 n = amatrix%matrix_struct%nrow_global
598 neig = min(
SIZE(eigenvalues), n)
601 CALL timestop(handle)
605 IF (amatrix%matrix_struct%nrow_block /= amatrix%matrix_struct%ncol_block)
THEN
606 cpabort(
"ERROR in "//routinen//
": Invalid blocksize (no square blocks) found")
609 a => amatrix%local_data
610 b => bmatrix%local_data
611 z => eigenvectors%local_data
612 desca(:) = amatrix%matrix_struct%descriptor(:)
613 descb(:) = bmatrix%matrix_struct%descriptor(:)
614 descz(:) = eigenvectors%matrix_struct%descriptor(:)
616 nprow = amatrix%matrix_struct%context%num_pe(1)
617 npcol = amatrix%matrix_struct%context%num_pe(2)
619 nb = amatrix%matrix_struct%nrow_block
621 np0 = numroc(nn, nb, 0, 0, nprow)
622 mq0 = max(numroc(nn, nb, 0, 0, npcol), nb)
624 lwork = n + (np0 + mq0 + nb)*nb
625 lrwork = 4*n + max(5*nn, np0*mq0) + iceil(neig, npe)*nn + max(0, neig - 1)*n
626 liwork = 6*max(n, npe + 1, 4)
630 ALLOCATE (iclustr(2*npe))
634 ALLOCATE (iwork(liwork))
635 ALLOCATE (rwork(lrwork))
637 ALLOCATE (work(lwork))
639 abstol = 2.0_dp*dlamch(
"S")
641#if defined (__HAS_IEEE_EXCEPTIONS)
642 CALL ieee_get_halting_mode(ieee_all, halt)
643 CALL ieee_set_halting_mode(ieee_all, .false.)
645 CALL pzhegvx(1,
"V",
"I",
"U", n, a(1, 1), 1, 1, desca, b(1, 1), 1, 1, descb, &
646 vl, vu, 1, neig, abstol, m, nz, w(1), orfac, z(1, 1), 1, 1, descz, &
647 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, ifail(1), &
648 iclustr(1), gap(1), info)
649#if defined (__HAS_IEEE_EXCEPTIONS)
650 CALL ieee_set_halting_mode(ieee_all, halt)
653 IF (info /= 0 .OR. m < neig .OR. nz < neig)
THEN
654 cpabort(
"ERROR in PZHEGVX (ScaLAPACK), info="//trim(
cp_to_string(info)))
657 eigenvalues(:) = 0.0_dp
658 eigenvalues(1:neig) = w(1:neig)
660 DEALLOCATE (gap, iclustr, ifail, iwork, rwork, w, work)
664 mark_used(eigenvectors)
665 mark_used(eigenvalues)
666 cpabort(
"ERROR in "//routinen//
": PZHEGVX requested without ScaLAPACK support")
669 CALL timestop(handle)
671 END SUBROUTINE cp_cfm_geeig_scalapack
687 TYPE(
cp_cfm_type),
INTENT(INOUT) :: amatrix, bmatrix, eigenvectors
688 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
690 REAL(kind=
dp),
INTENT(IN) :: epseig
691 INTEGER,
INTENT(OUT),
OPTIONAL :: nmo_retained
693 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_canon'
695 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cevals
696 INTEGER :: handle, i, icol, irow, nao, nc, ncol, &
698 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
700 CALL timeset(routinen, handle)
704 nmo =
SIZE(eigenvalues)
705 ALLOCATE (evals(nao), cevals(nao))
713 IF (evals(i) < epseig)
THEN
727 DO icol = nc + 1, nao
733 evals(nc + 1:nao) = 1.0_dp
736 cevals(:) = cmplx(1.0_dp/sqrt(evals(:)), 0.0_dp, kind=
dp)
743 DO icol = nc + 1, nao
750 eigenvalues(1:nmo) = evals(1:nmo)
757 IF (
PRESENT(nmo_retained)) nmo_retained = nc
761 CALL timestop(handle)
778 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
779 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
782 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_local'
784 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: a, b, z
785 INTEGER :: handle, info, n, nmo
786#if defined (__HAS_IEEE_EXCEPTIONS)
787 LOGICAL,
DIMENSION(5) :: halt
790 CALL timeset(routinen, handle)
792 cpassert(product(amatrix%matrix_struct%context%num_pe) == 1)
793 n = amatrix%matrix_struct%nrow_global
794 nmo = min(n,
SIZE(eigenvalues))
795 a => amatrix%local_data
796 b => bmatrix%local_data
797 z => eigenvectors%local_data
801#if defined (__HAS_IEEE_EXCEPTIONS)
802 CALL ieee_get_halting_mode(ieee_all, halt)
803 CALL ieee_set_halting_mode(ieee_all, .false.)
805 CALL zhegvd(1,
'V',
'U', n, a(1, 1),
SIZE(a, 1), b(1, 1),
SIZE(b, 1), ws%evals(1), &
806 ws%work(1),
SIZE(ws%work), ws%rwork(1),
SIZE(ws%rwork), ws%iwork(1),
SIZE(ws%iwork), info)
807#if defined (__HAS_IEEE_EXCEPTIONS)
808 CALL ieee_set_halting_mode(ieee_all, halt)
811 CALL cp_abort(__location__,
"Local ZHEGVD failed, info="//trim(
cp_to_string(info)))
814 eigenvalues(1:nmo) = ws%evals(1:nmo)
815 z(1:n, 1:nmo) = a(1:n, 1:nmo)
817 CALL timestop(handle)
833 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
834 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
836 REAL(kind=
dp),
INTENT(IN) :: epseig
839 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_canon_local'
841 COMPLEX(KIND=dp),
DIMENSION(:, :),
POINTER :: a, b, u, z
842 INTEGER :: handle, i, info, n, nc, nmo, nx
844 CALL timeset(routinen, handle)
846 cpassert(product(amatrix%matrix_struct%context%num_pe) == 1)
847 n = amatrix%matrix_struct%nrow_global
848 nmo = min(n,
SIZE(eigenvalues))
849 a => amatrix%local_data
850 b => bmatrix%local_data
852 z => eigenvectors%local_data
855 b(1:n, 1:n) = -b(1:n, 1:n)
858 CALL cp_abort(__location__,
"Local overlap ZHEEVD failed, info="//trim(
cp_to_string(info)))
860 ws%evals(:) = -ws%evals(:)
863 IF (ws%evals(i) < epseig)
THEN
871 IF (nc < nmo) z(1:n, nc + 1:nmo) = u(1:n, nc + 1:nmo)
873 ws%evals(nc + 1:n) = 1.0_dp
876 u(1:n, i) = u(1:n, i)/sqrt(ws%evals(i))
879 CALL zgemm(
'C',
'N', n, n, n,
z_one, u(1, 1),
SIZE(u, 1), a(1, 1),
SIZE(a, 1), &
880 z_zero, b(1, 1),
SIZE(b, 1))
881 CALL zgemm(
'N',
'N', n, n, n,
z_one, b(1, 1),
SIZE(b, 1), u(1, 1),
SIZE(u, 1), &
882 z_zero, a(1, 1),
SIZE(a, 1))
885 a(i, i) = cmplx(10000.0_dp, 0.0_dp, kind=
dp)
891 CALL cp_abort(__location__,
"Local Hamiltonian ZHEEVD failed, info="//trim(
cp_to_string(info)))
893 eigenvalues(1:nmo) = ws%evals(1:nmo)
895 CALL zgemm(
'N',
'N', n, nx, nc,
z_one, u(1, 1),
SIZE(u, 1), b(1, 1),
SIZE(b, 1), &
896 z_zero, z(1, 1),
SIZE(z, 1))
898 CALL timestop(handle)
911 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(INOUT) :: matrix
912 COMPLEX(KIND=dp),
DIMENSION(:, :),
INTENT(INOUT),
OPTIONAL :: vectors
913 INTEGER,
INTENT(OUT) :: info
917#if defined (__HAS_IEEE_EXCEPTIONS)
918 LOGICAL,
DIMENSION(5) :: halt
922#if defined (__HAS_IEEE_EXCEPTIONS)
923 CALL ieee_get_halting_mode(ieee_all, halt)
924 CALL ieee_set_halting_mode(ieee_all, .false.)
926 CALL zheevd(
'V',
'U', n, matrix(1, 1),
SIZE(matrix, 1), ws%evals(1), &
927 ws%work(1),
SIZE(ws%work), ws%rwork(1),
SIZE(ws%rwork), ws%iwork(1),
SIZE(ws%iwork), info)
928#if defined (__HAS_IEEE_EXCEPTIONS)
929 CALL ieee_set_halting_mode(ieee_all, halt)
931 IF (
PRESENT(vectors)) vectors(1:n, 1:n) = matrix(1:n, 1:n)
944 INTEGER,
INTENT(IN) :: n
945 COMPLEX(KIND=dp),
INTENT(INOUT) :: a(:, :)
946 COMPLEX(KIND=dp),
INTENT(INOUT),
OPTIONAL :: b(:, :)
948 COMPLEX(KIND=dp) :: work(1)
949 INTEGER :: info, iwork(1)
950 REAL(kind=
dp) :: rwork(1)
952 IF (ws%n == n .AND. (ws%generalized .EQV.
PRESENT(b)))
RETURN
953 IF (
ALLOCATED(ws%work))
DEALLOCATE (ws%work, ws%rwork, ws%iwork, ws%evals)
954 ALLOCATE (ws%evals(n))
956 CALL zhegvd(1,
'V',
'U', n, a(1, 1),
SIZE(a, 1), b(1, 1),
SIZE(b, 1), ws%evals(1), &
957 work(1), -1, rwork(1), -1, iwork(1), -1, info)
959 CALL zheevd(
'V',
'U', n, a(1, 1),
SIZE(a, 1), ws%evals(1), work(1), -1, rwork(1), -1, iwork(1), -1, info)
962 CALL cp_abort(__location__, &
963 "Local LAPACK workspace query failed, info="//trim(
cp_to_string(info)))
965 ALLOCATE (ws%work(max(1, ceiling(real(work(1),
dp)))), &
966 ws%rwork(max(1, ceiling(rwork(1)))), ws%iwork(max(1, iwork(1))))
968 ws%generalized =
PRESENT(b)
methods related to the blacs parallel environment
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_gemm(transa, transb, m, n, k, alpha, matrix_a, matrix_b, beta, matrix_c, a_first_col, a_first_row, b_first_col, b_first_row, c_first_col, c_first_row)
Performs one of the matrix-matrix operations: matrix_c = alpha * op1( matrix_a ) * op2( matrix_b ) + ...
subroutine, public cp_cfm_triangular_multiply(triangular_matrix, matrix_b, side, transa_tr, invert_tr, uplo_tr, unit_diag_tr, n_rows, n_cols, alpha)
Multiplies in place by a triangular matrix: matrix_b = alpha op(triangular_matrix) matrix_b or (if si...
subroutine, public cp_cfm_column_scale(matrix_a, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
subroutine, public cp_cfm_triangular_invert(matrix_a, uplo, info_out)
Inverts a triangular matrix.
various cholesky decomposition related routines
subroutine, public cp_cfm_cholesky_decompose(matrix, n, info_out)
Used to replace a symmetric positive definite matrix M with its Cholesky decomposition U: M = U^T * U...
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical orthogonalization.
subroutine, public cp_cfm_heevd_local(matrix, vectors, info, ws)
Local LAPACK ZHEEVD with prepared scratch, without allocation or communication.
subroutine, public cp_cfm_geeig_local(amatrix, bmatrix, eigenvectors, eigenvalues, ws)
Solve a generalized complex eigenproblem using the local LAPACK backend. This routine is restricted t...
subroutine, public cp_cfm_local_workspace_prepare(ws, n, a, b)
Query LAPACK once per matrix order/solver and retain private scratch across k points.
subroutine, public cp_cfm_geeig_canon_local(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, ws)
Canonical generalized complex diagonalization on a one-rank BLACS grid.
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
subroutine, public cp_cfm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
Raise the positive spectral part of a Hermitian matrix to a real power. Eigenmodes with eigenvalues b...
subroutine, public cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work, lowest_subset)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
subroutine, public cp_cfm_diag_dlaf(matrix, eigenvectors, eigenvalues)
DLA-Future eigensolver for complex Hermitian matrices.
subroutine, public cp_cfm_diag_gen_dlaf(amatrix, bmatrix, eigenvectors, eigenvalues)
DLA-Future generalized eigensolver for complex Hermitian matrices.
Wrapper for ELPA (complex matrices, i.e. cp_cfm_type).
subroutine, public cp_cfm_diag_elpa(matrix, eigenvectors, eigenvalues)
Driver routine to diagonalize a CFM matrix with the ELPA library.
logical function, public is_elpa_c_broken()
Returns .TRUE. if the runtime check detected broken BLOCK2 kernels.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_cfm_set_element(matrix, irow_global, icol_global, alpha)
Set the matrix element (irow_global,icol_global) of the full matrix to alpha.
subroutine, public cp_cfm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, matrix_struct, para_env)
Returns information about a full matrix.
subroutine, public cp_dlaf_create_grid(blacs_context)
Create DLA-Future grid from BLACS context.
subroutine, public cp_dlaf_initialize()
Initialize DLA-Future and pika runtime.
subroutine, public cp_cfm_general_cusolver(amatrix, bmatrix, eigenvectors, eigenvalues)
Driver routine to solve generalized complex eigenvalue problem A*x = lambda*B*x with cuSOLVERMp.
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
integer, parameter, public fm_diag_type_cusolver
real(kind=dp), parameter, public set_removed_eigval_to
integer, parameter, public fm_diag_type_dlaf
integer, parameter, public fm_diag_type_scalapack
logical, save, public direct_generalized_diagonalization
integer, save, public elpa_neigvec_min
real(kind=dp) function, public diag_check_warning_threshold()
Return the warning threshold for diagonalization checks.
integer, save, public diag_type
integer, save, public dlaf_neigvec_min
integer, parameter, public fm_diag_type_elpa
integer, parameter, public cusolver_n_min
logical function, public diag_check_requested()
Return whether diagonalization checks should be performed.
logical, save, public diag_lib_explicit
various routines to log and control the output. The idea is that decisions about where to log should ...
recursive integer function, public cp_logger_get_default_unit_nr(logger, local, skip_not_ionode)
asks the default unit number of the given logger. try to use cp_logger_get_unit_nr
Defines the basic variable types.
integer, parameter, public dp
integer, parameter, public default_string_length
Machine interface based on Fortran 2003 and POSIX.
integer, parameter, public default_output_unit
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
basic linear algebra operations for full matrixes
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.