70#if defined (__parallel)
73#if defined (__HAS_IEEE_EXCEPTIONS)
74 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
75 ieee_set_halting_mode, &
78#include "../base/base_uses.f90"
83 CHARACTER(LEN=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_fm_diag'
109 REAL(kind=
dp),
SAVE :: eps_check_diag = -1.0_dp
116#if defined(__CUSOLVERMP)
161 SUBROUTINE diag_init(diag_lib, fallback_applied, elpa_kernel, elpa_c_kernel, elpa_neigvec_min_input, &
162 elpa_qr, elpa_print, elpa_one_stage, dlaf_neigvec_min_input, eps_check_diag_input, &
163 direct_generalized_diagonalization_input, diag_lib_explicit_input)
164 CHARACTER(LEN=*),
INTENT(IN) :: diag_lib
165 LOGICAL,
INTENT(OUT) :: fallback_applied
166 INTEGER,
INTENT(IN) :: elpa_kernel
167 INTEGER,
INTENT(IN),
OPTIONAL :: elpa_c_kernel
168 INTEGER,
INTENT(IN) :: elpa_neigvec_min_input
170 INTEGER,
INTENT(IN) :: dlaf_neigvec_min_input
171 REAL(kind=
dp),
INTENT(IN) :: eps_check_diag_input
172 LOGICAL,
INTENT(IN),
OPTIONAL :: direct_generalized_diagonalization_input, &
173 diag_lib_explicit_input
175 LOGICAL,
SAVE :: initialized = .false.
177 fallback_applied = .false.
179 IF (diag_lib ==
"ScaLAPACK")
THEN
181 ELSE IF (diag_lib ==
"ELPA")
THEN
188 fallback_applied = .true.
190 ELSE IF (diag_lib ==
"cuSOLVER")
THEN
192 ELSE IF (diag_lib ==
"DLAF")
THEN
196 cpabort(
"ERROR in diag_init: CP2K was not compiled with DLA-Future support")
199 cpabort(
"ERROR in diag_init: Initialization of unknown diagonalization library requested")
205 IF (
PRESENT(diag_lib_explicit_input))
diag_lib_explicit = diag_lib_explicit_input
221 mark_used(dlaf_neigvec_min_input)
225 eps_check_diag = eps_check_diag_input
226 IF (
PRESENT(direct_generalized_diagonalization_input))
THEN
263 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
264 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
265 INTEGER,
INTENT(OUT),
OPTIONAL :: info
267 CHARACTER(LEN=*),
PARAMETER :: routinen =
'choose_eigv_solver'
272 IF (
PRESENT(info)) info = 0
275 CALL cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
280 CALL cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
288 CALL cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
297 CALL cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
304 cpabort(
"ERROR in "//routinen//
": Invalid diagonalization type requested")
307 CALL check_diag(matrix, eigenvectors, nvec=
SIZE(eigenvalues))
316 LOGICAL :: check_requested
318#if defined(__CHECK_DIAG)
319 check_requested = .true.
321 check_requested = eps_check_diag >= 0.0_dp
331 REAL(kind=
dp) :: eps_warning
334 IF (eps_check_diag >= 0.0_dp)
THEN
335 eps_warning = eps_check_diag
346 SUBROUTINE check_diag(matrix, eigenvectors, nvec)
348 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
349 INTEGER,
INTENT(IN) :: nvec
351 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_diag'
353 CHARACTER(LEN=default_string_length) :: diag_type_name
354 REAL(kind=
dp) :: eps, eps_abort, eps_warning, gold, &
356 INTEGER :: handle, i, j, ncol, nrow, output_unit
357 LOGICAL :: check_eigenvectors
358#if defined(__parallel)
360 INTEGER :: il, jl, ipcol, iprow, &
361 mypcol, myprow, npcol, nprow
362 INTEGER,
DIMENSION(9) :: desca
365 CALL timeset(routinen, handle)
370 eps_abort = 10.0_dp*eps_warning
376 IF (check_eigenvectors)
THEN
377#if defined(__parallel)
378 nrow = eigenvectors%matrix_struct%nrow_global
379 ncol = min(eigenvectors%matrix_struct%ncol_global, nvec)
380 CALL cp_fm_gemm(
"T",
"N", ncol, ncol, nrow, 1.0_dp, eigenvectors, eigenvectors, 0.0_dp, matrix)
381 context => matrix%matrix_struct%context
382 myprow = context%mepos(1)
383 mypcol = context%mepos(2)
384 nprow = context%num_pe(1)
385 npcol = context%num_pe(2)
386 desca(:) = matrix%matrix_struct%descriptor(:)
387 outer:
DO j = 1, ncol
389 CALL infog2l(i, j, desca, nprow, npcol, myprow, mypcol, il, jl, iprow, ipcol)
390 IF ((iprow == myprow) .AND. (ipcol == mypcol))
THEN
391 gold = merge(0.0_dp, 1.0_dp, i /= j)
392 test = matrix%local_data(il, jl)
393 eps = abs(test - gold)
394 IF (eps > eps_warning)
EXIT outer
399 nrow =
SIZE(eigenvectors%local_data, 1)
400 ncol = min(
SIZE(eigenvectors%local_data, 2), nvec)
401 CALL dgemm(
"T",
"N", ncol, ncol, nrow, 1.0_dp, &
402 eigenvectors%local_data(1, 1), nrow, &
403 eigenvectors%local_data(1, 1), nrow, &
404 0.0_dp, matrix%local_data(1, 1), nrow)
405 outer:
DO j = 1, ncol
407 gold = merge(0.0_dp, 1.0_dp, i /= j)
408 test = matrix%local_data(i, j)
409 eps = abs(test - gold)
410 IF (eps > eps_warning)
EXIT outer
414 IF (eps > eps_warning)
THEN
416 diag_type_name =
"SYEVD"
418 diag_type_name =
"ELPA"
420 diag_type_name =
"CUSOLVER"
422 diag_type_name =
"DLAF"
424 cpabort(
"Unknown diag_type")
426 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,T2,A,I0,A,I0,A,F0.15,/,T2,A,F0.0,A,ES10.3)") &
427 "The eigenvectors returned by "//trim(diag_type_name)//
" are not orthonormal", &
428 "Matrix element (", i,
", ", j,
") = ", test, &
429 "The deviation from the expected value ", gold,
" is", eps
430 IF (eps > eps_abort)
THEN
431 cpabort(
"ERROR in "//routinen//
": Check of matrix diagonalization failed")
433 cpwarn(
"Check of matrix diagonalization failed in routine "//routinen)
438 CALL timestop(handle)
440 END SUBROUTINE check_diag
449 SUBROUTINE check_generalized_diag(overlap, eigenvectors, scratch, nvec)
452 TYPE(
cp_fm_type),
INTENT(INOUT) :: overlap, scratch
453 INTEGER,
INTENT(IN) :: nvec
455 CHARACTER(LEN=*),
PARAMETER :: routinen =
'check_generalized_diag'
457 CHARACTER(LEN=default_string_length) :: diag_type_name
458 REAL(kind=
dp) :: eps, eps_abort, eps_warning, gold, &
460 INTEGER :: handle, i, j, ncol, nrow, output_unit
461#if defined(__parallel)
463 INTEGER :: il, jl, ipcol, iprow, &
464 mypcol, myprow, npcol, nprow
465 INTEGER,
DIMENSION(9) :: desca
468 CALL timeset(routinen, handle)
471 CALL timestop(handle)
477 eps_abort = 10.0_dp*eps_warning
479 nrow = eigenvectors%matrix_struct%nrow_global
480 ncol = min(eigenvectors%matrix_struct%ncol_global, nvec)
482 CALL parallel_gemm(
"N",
"N", nrow, ncol, nrow, 1.0_dp, overlap, eigenvectors, 0.0_dp, scratch)
483 CALL parallel_gemm(
"T",
"N", ncol, ncol, nrow, 1.0_dp, eigenvectors, scratch, 0.0_dp, overlap)
489#if defined(__parallel)
490 context => overlap%matrix_struct%context
491 myprow = context%mepos(1)
492 mypcol = context%mepos(2)
493 nprow = context%num_pe(1)
494 npcol = context%num_pe(2)
495 desca(:) = overlap%matrix_struct%descriptor(:)
496 outer:
DO j = 1, ncol
498 CALL infog2l(i, j, desca, nprow, npcol, myprow, mypcol, il, jl, iprow, ipcol)
499 IF ((iprow == myprow) .AND. (ipcol == mypcol))
THEN
500 gold = merge(0.0_dp, 1.0_dp, i /= j)
501 test = overlap%local_data(il, jl)
502 eps = abs(test - gold)
503 IF (eps > eps_warning)
EXIT outer
508 outer:
DO j = 1, ncol
510 gold = merge(0.0_dp, 1.0_dp, i /= j)
511 test = overlap%local_data(i, j)
512 eps = abs(test - gold)
513 IF (eps > eps_warning)
EXIT outer
518 IF (eps > eps_warning)
THEN
520 diag_type_name =
"SYGVX"
522 diag_type_name =
"ELPA"
524 diag_type_name =
"CUSOLVER"
526 diag_type_name =
"DLAF"
528 cpabort(
"Unknown diag_type")
530 WRITE (unit=output_unit, fmt=
"(/,T2,A,/,T2,A,I0,A,I0,A,F0.15,/,T2,A,F0.0,A,ES10.3)") &
531 "The generalized eigenvectors returned by "//trim(diag_type_name)//
" are not S-orthonormal", &
532 "Matrix element (", i,
", ", j,
") = ", test, &
533 "The deviation from the expected value ", gold,
" is", eps
534 IF (eps > eps_abort)
THEN
535 cpabort(
"ERROR in "//routinen//
": Check of generalized matrix diagonalization failed")
537 cpwarn(
"Check of generalized matrix diagonalization failed in routine "//routinen)
541 CALL timestop(handle)
543 END SUBROUTINE check_generalized_diag
551 SUBROUTINE cp_fm_error(mesg, info, warn)
552 CHARACTER(LEN=*),
INTENT(IN) :: mesg
553 INTEGER,
INTENT(IN),
OPTIONAL :: info
554 LOGICAL,
INTENT(IN),
OPTIONAL :: warn
556 CHARACTER(LEN=2*default_string_length) :: message
559 IF (
PRESENT(info))
THEN
560 WRITE (message,
"(A,A,I0,A)") mesg,
" (INFO = ", info,
")"
562 WRITE (message,
"(A)") mesg
565 IF (
PRESENT(warn))
THEN
572 cpwarn(trim(message))
574 cpabort(trim(message))
576 END SUBROUTINE cp_fm_error
593 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
594 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
595 INTEGER,
INTENT(OUT),
OPTIONAL :: info
597 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_syevd'
599 INTEGER :: handle, myinfo, n, nmo
600 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eig
601#if defined(__parallel)
602 TYPE(
cp_fm_type) :: eigenvectors_new, matrix_new
604 INTEGER :: liwork, lwork
605 INTEGER,
DIMENSION(:),
POINTER :: iwork
606 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: m
607 REAL(kind=
dp),
DIMENSION(:),
POINTER :: work
608 INTEGER,
TARGET :: v(1)
609 REAL(kind=
dp),
TARGET :: w(1)
612 CALL timeset(routinen, handle)
616 n = matrix%matrix_struct%nrow_global
619#if defined(__parallel)
627 IF (
ASSOCIATED(matrix_new%matrix_struct))
THEN
628 IF (
PRESENT(info))
THEN
629 CALL cp_fm_syevd_base(matrix_new, eigenvectors_new, eig, myinfo)
631 CALL cp_fm_syevd_base(matrix_new, eigenvectors_new, eig)
640 m => matrix%local_data
644 CALL dsyevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eig(1), work(1), lwork, iwork(1), liwork, myinfo)
646 IF (myinfo /= 0)
THEN
647 CALL cp_fm_error(
"ERROR in DSYEVD: Work space query failed", myinfo,
PRESENT(info))
651 lwork = nint(work(1))
652 ALLOCATE (work(lwork))
655 ALLOCATE (iwork(liwork))
657 CALL dsyevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eig(1), work(1), lwork, iwork(1), liwork, myinfo)
659 IF (myinfo /= 0)
THEN
660 CALL cp_fm_error(
"ERROR in DSYEVD: Matrix diagonalization failed", myinfo,
PRESENT(info))
669 IF (
PRESENT(info)) info = myinfo
671 nmo =
SIZE(eigenvalues, 1)
673 eigenvalues(1:n) = eig(1:n)
675 eigenvalues(1:nmo) = eig(1:nmo)
680 CALL check_diag(matrix, eigenvectors, n)
682 CALL timestop(handle)
693 SUBROUTINE cp_fm_syevd_base(matrix, eigenvectors, eigenvalues, info)
695 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
696 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
697 INTEGER,
INTENT(OUT),
OPTIONAL :: info
699 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_syevd_base'
701 INTEGER :: handle, myinfo
702#if defined(__parallel)
704 INTEGER :: liwork, lwork, n
705 INTEGER,
DIMENSION(9) :: descm, descv
706 INTEGER,
DIMENSION(:),
POINTER :: iwork
707 REAL(kind=
dp),
DIMENSION(:),
POINTER :: work
708 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: m, v
709 REAL(kind=
dp),
TARGET :: w(1)
710#if defined (__HAS_IEEE_EXCEPTIONS)
711 LOGICAL,
DIMENSION(5) :: halt
715 CALL timeset(routinen, handle)
719#if defined(__parallel)
721 n = matrix%matrix_struct%nrow_global
722 m => matrix%local_data
723 context => matrix%matrix_struct%context
724 descm(:) = matrix%matrix_struct%descriptor(:)
726 v => eigenvectors%local_data
727 descv(:) = eigenvectors%matrix_struct%descriptor(:)
729 liwork = 7*n + 8*context%num_pe(2) + 2
730 ALLOCATE (iwork(liwork))
736 CALL pdsyevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
737 work(1), lwork, iwork(1), liwork, myinfo)
739 IF (matrix%matrix_struct%para_env%is_source() .AND. (myinfo /= 0))
THEN
740 CALL cp_fm_error(
"ERROR in PDSYEVD: Work space query failed", myinfo,
PRESENT(info))
743 lwork = nint(work(1))
744#if !defined(__SCALAPACK_NO_WA)
746 CALL pdormtr(
'L',
'U',
'N', n, n, m(1, 1), 1, 1, descm, m(1, 1), &
747 v(1, 1), 1, 1, descv, work(1), -1, myinfo)
749 IF (matrix%matrix_struct%para_env%is_source() .AND. (myinfo /= 0))
THEN
750 CALL cp_fm_error(
"ERROR in PDORMTR: Work space query failed", myinfo,
PRESENT(info))
753 IF (lwork < (work(1) + 2*n))
THEN
754 lwork = nint(work(1)) + 2*n
757 ALLOCATE (work(lwork))
760 IF (liwork < iwork(1))
THEN
763 ALLOCATE (iwork(liwork))
768#if defined (__HAS_IEEE_EXCEPTIONS)
769 CALL ieee_get_halting_mode(ieee_all, halt)
770 CALL ieee_set_halting_mode(ieee_all, .false.)
773 CALL pdsyevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
774 work(1), lwork, iwork(1), liwork, myinfo)
776#if defined (__HAS_IEEE_EXCEPTIONS)
777 CALL ieee_set_halting_mode(ieee_all, halt)
779 IF (matrix%matrix_struct%para_env%is_source() .AND. (myinfo /= 0))
THEN
780 CALL cp_fm_error(
"ERROR in PDSYEVD: Matrix diagonalization failed", myinfo,
PRESENT(info))
783 IF (
PRESENT(info)) info = myinfo
789 mark_used(eigenvectors)
790 mark_used(eigenvalues)
792 IF (
PRESENT(info)) info = myinfo
793 CALL cp_fm_error(
"ERROR in "//trim(routinen)// &
794 ": Matrix diagonalization using PDSYEVD requested without ScaLAPACK support")
797 CALL timestop(handle)
799 END SUBROUTINE cp_fm_syevd_base
815 SUBROUTINE cp_fm_syevx(matrix, eigenvectors, eigenvalues, neig, work_syevx)
820 TYPE(
cp_fm_type),
OPTIONAL,
INTENT(IN) :: eigenvectors
821 REAL(kind=
dp),
OPTIONAL,
INTENT(IN) :: work_syevx
822 INTEGER,
INTENT(IN),
OPTIONAL :: neig
823 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
825 CHARACTER(LEN=*),
PARAMETER :: routinen =
"cp_fm_syevx"
827#if defined(__parallel)
828 REAL(kind=
dp),
PARAMETER :: orfac = -1.0_dp
830 REAL(kind=
dp),
PARAMETER :: vl = 0.0_dp, &
835 CHARACTER(LEN=1) :: job_type
836 REAL(kind=
dp) :: abstol, work_syevx_local
837 INTEGER :: handle, info, liwork, lwork, &
838 m, n, nb, npcol, nprow, &
839 output_unit, neig_local
840 LOGICAL :: ionode, needs_evecs
841 INTEGER,
DIMENSION(:),
ALLOCATABLE :: ifail, iwork
842 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: w, work
843 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, z
845 REAL(kind=
dp),
EXTERNAL :: dlamch
847#if defined(__parallel)
848 INTEGER :: nn, np0, npe, nq0, nz
849 INTEGER,
DIMENSION(9) :: desca, descz
850 INTEGER,
DIMENSION(:),
ALLOCATABLE :: iclustr
851 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: gap
852 INTEGER,
EXTERNAL :: iceil, numroc
855 INTEGER,
EXTERNAL :: ilaenv
857#if defined (__HAS_IEEE_EXCEPTIONS)
858 LOGICAL,
DIMENSION(5) :: halt
862 n = matrix%matrix_struct%nrow_global
864 IF (
PRESENT(neig)) neig_local = neig
865 IF (neig_local == 0)
RETURN
867 CALL timeset(routinen, handle)
869 needs_evecs =
PRESENT(eigenvectors)
872 ionode = logger%para_env%is_source()
873 n = matrix%matrix_struct%nrow_global
876 work_syevx_local = 1.0_dp
877 IF (
PRESENT(work_syevx)) work_syevx_local = work_syevx
880 IF (needs_evecs)
THEN
887 abstol = 2.0_dp*dlamch(
"S")
889 context => matrix%matrix_struct%context
890 nprow = context%num_pe(1)
891 npcol = context%num_pe(2)
894 eigenvalues(:) = 0.0_dp
895#if defined(__parallel)
897 IF (matrix%matrix_struct%nrow_block /= matrix%matrix_struct%ncol_block)
THEN
898 cpabort(
"ERROR in "//routinen//
": Invalid blocksize (no square blocks) found")
901 a => matrix%local_data
902 desca(:) = matrix%matrix_struct%descriptor(:)
904 IF (needs_evecs)
THEN
905 z => eigenvectors%local_data
906 descz(:) = eigenvectors%matrix_struct%descriptor(:)
909 z => matrix%local_data
916 nb = matrix%matrix_struct%nrow_block
918 np0 = numroc(nn, nb, 0, 0, nprow)
919 nq0 = max(numroc(nn, nb, 0, 0, npcol), nb)
921 IF (needs_evecs)
THEN
922 lwork = 5*n + max(5*nn, np0*nq0) + iceil(neig_local, npe)*nn + 2*nb*nb + &
923 int(work_syevx_local*real((neig_local - 1)*n,
dp))
925 lwork = 5*n + max(5*nn, nb*(np0 + 1))
927 liwork = 6*max(n, npe + 1, 4)
931 ALLOCATE (iclustr(2*npe))
935 ALLOCATE (iwork(liwork))
936 ALLOCATE (work(lwork))
940#if defined (__HAS_IEEE_EXCEPTIONS)
941 CALL ieee_get_halting_mode(ieee_all, halt)
942 CALL ieee_set_halting_mode(ieee_all, .false.)
944 CALL pdsyevx(job_type,
"I",
"U", n, a(1, 1), 1, 1, desca, vl, vu, 1, neig_local, abstol, m, nz, w(1), orfac, &
945 z(1, 1), 1, 1, descz, work(1), lwork, iwork(1), liwork, ifail(1), iclustr(1), gap, info)
946#if defined (__HAS_IEEE_EXCEPTIONS)
947 CALL ieee_set_halting_mode(ieee_all, halt)
954 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T12,1X,I10))") &
957 "liwork = ", liwork, &
960 WRITE (unit=output_unit, fmt=
"(/,T3,A,(T12,6(1X,I10)))") &
962 WRITE (unit=output_unit, fmt=
"(/,T3,A,(T12,6(1X,I10)))") &
963 "iclustr = ", iclustr
964 WRITE (unit=output_unit, fmt=
"(/,T3,A,(T12,6(1X,E10.3)))") &
968 cpabort(
"ERROR in PDSYEVX (ScaLAPACK)")
977 a => matrix%local_data
978 IF (needs_evecs)
THEN
979 z => eigenvectors%local_data
982 z => matrix%local_data
987 nb = max(ilaenv(1,
"DSYTRD",
"U", n, -1, -1, -1), &
988 ilaenv(1,
"DORMTR",
"U", n, -1, -1, -1))
990 lwork = max((nb + 3)*n, 8*n) + n
995 ALLOCATE (iwork(liwork))
996 ALLOCATE (work(lwork))
1003#if defined (__HAS_IEEE_EXCEPTIONS)
1004 CALL ieee_get_halting_mode(ieee_all, halt)
1005 CALL ieee_set_halting_mode(ieee_all, .false.)
1007 CALL dsyevx(job_type,
"I",
"U", n, a(1, 1), nla, vl, vu, 1, neig_local, &
1008 abstol, m, w, z(1, 1), nlz, work(1), lwork, iwork(1), ifail(1), info)
1009#if defined (__HAS_IEEE_EXCEPTIONS)
1010 CALL ieee_set_halting_mode(ieee_all, halt)
1016 WRITE (unit=output_unit, fmt=
"(/,(T3,A,T12,1X,I10))") &
1019 WRITE (unit=output_unit, fmt=
"(/,T3,A,(T12,6(1X,I10)))") &
1022 cpabort(
"Error in DSYEVX (ScaLAPACK)")
1030 eigenvalues(1:neig_local) = w(1:neig_local)
1033 IF (needs_evecs)
CALL check_diag(matrix, eigenvectors, neig_local)
1035 CALL timestop(handle)
1048 SUBROUTINE cp_fm_svd(matrix_a, matrix_eigvl, matrix_eigvr_t, eigval, info)
1051 TYPE(
cp_fm_type),
INTENT(INOUT) :: matrix_eigvl, matrix_eigvr_t
1052 REAL(kind=
dp),
DIMENSION(:),
POINTER, &
1053 INTENT(INOUT) :: eigval
1054 INTEGER,
INTENT(OUT),
OPTIONAL :: info
1056 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_svd'
1058 INTEGER :: handle, n, m, myinfo, lwork
1059 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a
1061 REAL(kind=
dp),
DIMENSION(:),
POINTER :: work
1062 REAL(kind=
dp),
TARGET :: w(1)
1063#if defined(__parallel)
1064 INTEGER,
DIMENSION(9) :: desca, descu, descvt
1067 CALL timeset(routinen, handle)
1070 matrix_struct=matrix_a%matrix_struct, &
1073 a => matrix_lu%local_data
1074 m = matrix_lu%matrix_struct%nrow_global
1075 n = matrix_lu%matrix_struct%ncol_global
1083#if defined(__parallel)
1085 desca(:) = matrix_lu%matrix_struct%descriptor(:)
1086 descu(:) = matrix_eigvl%matrix_struct%descriptor(:)
1087 descvt(:) = matrix_eigvr_t%matrix_struct%descriptor(:)
1090 CALL pdgesvd(
'V',
'V', m, m, matrix_lu%local_data, 1, 1, desca, eigval, matrix_eigvl%local_data, &
1091 1, 1, descu, matrix_eigvr_t%local_data, 1, 1, descvt, work, lwork, myinfo)
1093 IF (matrix_lu%matrix_struct%para_env%is_source() .AND. (myinfo /= 0))
THEN
1094 CALL cp_fm_error(
"ERROR in PDGESVD: Work space query failed", myinfo,
PRESENT(info))
1097 lwork = nint(work(1))
1098 ALLOCATE (work(lwork))
1100 CALL pdgesvd(
'V',
'V', m, m, matrix_lu%local_data, 1, 1, desca, eigval, matrix_eigvl%local_data, &
1101 1, 1, descu, matrix_eigvr_t%local_data, 1, 1, descvt, work, lwork, myinfo)
1103 IF (matrix_lu%matrix_struct%para_env%is_source() .AND. (myinfo /= 0))
THEN
1104 CALL cp_fm_error(
"ERROR in PDGESVD: Matrix diagonalization failed", myinfo,
PRESENT(info))
1108 CALL dgesvd(
'S',
'S', m, m, matrix_lu%local_data, m, eigval, matrix_eigvl%local_data, &
1109 m, matrix_eigvr_t%local_data, m, work, lwork, myinfo)
1111 IF (myinfo /= 0)
THEN
1112 CALL cp_fm_error(
"ERROR in DGESVD: Work space query failed", myinfo,
PRESENT(info))
1115 lwork = nint(work(1))
1116 ALLOCATE (work(lwork))
1118 CALL dgesvd(
'S',
'S', m, m, matrix_lu%local_data, m, eigval, matrix_eigvl%local_data, &
1119 m, matrix_eigvr_t%local_data, m, work, lwork, myinfo)
1121 IF (myinfo /= 0)
THEN
1122 CALL cp_fm_error(
"ERROR in DGESVD: Matrix diagonalization failed", myinfo,
PRESENT(info))
1130 IF (
PRESENT(info)) info = myinfo
1132 CALL timestop(handle)
1145 SUBROUTINE cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
1155 REAL(kind=
dp),
INTENT(IN) :: exponent, threshold
1156 INTEGER,
INTENT(OUT) :: n_dependent
1157 LOGICAL,
INTENT(IN),
OPTIONAL :: verbose
1158 REAL(kind=
dp),
DIMENSION(2),
INTENT(OUT), &
1161 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_power'
1163 INTEGER :: handle, icol_global, &
1165 ncol_global, nrow_global
1166 LOGICAL :: my_verbose
1167 REAL(kind=
dp) :: condition_number, f, p
1168 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: eigenvalues
1169 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: eigenvectors
1172#if defined(__parallel)
1173 INTEGER :: icol_local, ipcol, iprow, irow_global, &
1177 CALL timeset(routinen, handle)
1179 my_verbose = .false.
1180 IF (
PRESENT(verbose)) my_verbose = verbose
1182 context => matrix%matrix_struct%context
1183 myprow = context%mepos(1)
1184 mypcol = context%mepos(2)
1188 nrow_global = matrix%matrix_struct%nrow_global
1189 ncol_global = matrix%matrix_struct%ncol_global
1191 ALLOCATE (eigenvalues(ncol_global))
1192 eigenvalues(:) = 0.0_dp
1198 IF (
PRESENT(eigvals))
THEN
1199 eigvals(1) = eigenvalues(1)
1200 eigvals(2) = eigenvalues(ncol_global)
1203#if defined(__parallel)
1204 eigenvectors => work%local_data
1208 DO icol_global = 1, ncol_global
1210 IF (eigenvalues(icol_global) < threshold)
THEN
1212 n_dependent = n_dependent + 1
1214 ipcol = work%matrix_struct%g2p_col(icol_global)
1216 IF (mypcol == ipcol)
THEN
1217 icol_local = work%matrix_struct%g2l_col(icol_global)
1218 DO irow_global = 1, nrow_global
1219 iprow = work%matrix_struct%g2p_row(irow_global)
1220 IF (myprow == iprow)
THEN
1221 irow_local = work%matrix_struct%g2l_row(irow_global)
1222 eigenvectors(irow_local, icol_local) = 0.0_dp
1229 f = eigenvalues(icol_global)**p
1231 ipcol = work%matrix_struct%g2p_col(icol_global)
1233 IF (mypcol == ipcol)
THEN
1234 icol_local = work%matrix_struct%g2l_col(icol_global)
1235 DO irow_global = 1, nrow_global
1236 iprow = work%matrix_struct%g2p_row(irow_global)
1237 IF (myprow == iprow)
THEN
1238 irow_local = work%matrix_struct%g2l_row(irow_global)
1239 eigenvectors(irow_local, icol_local) = &
1240 f*eigenvectors(irow_local, icol_local)
1251 eigenvectors => work%local_data
1255 DO icol_global = 1, ncol_global
1257 IF (eigenvalues(icol_global) < threshold)
THEN
1259 n_dependent = n_dependent + 1
1260 eigenvectors(1:nrow_global, icol_global) = 0.0_dp
1264 f = eigenvalues(icol_global)**p
1265 eigenvectors(1:nrow_global, icol_global) = &
1266 f*eigenvectors(1:nrow_global, icol_global)
1273 CALL cp_fm_syrk(
"U",
"N", ncol_global, 1.0_dp, work, 1, 1, 0.0_dp, matrix)
1277 IF (matrix%matrix_struct%para_env%is_source() .AND. my_verbose)
THEN
1278 condition_number = abs(eigenvalues(ncol_global)/eigenvalues(1))
1280 "CP_FM_POWER: smallest eigenvalue:", eigenvalues(1), &
1281 "CP_FM_POWER: largest eigenvalue: ", eigenvalues(ncol_global), &
1282 "CP_FM_POWER: condition number: ", condition_number
1283 IF (eigenvalues(1) <= 0.0_dp)
THEN
1285 "WARNING: matrix has a negative eigenvalue, tighten EPS_DEFAULT"
1287 IF (condition_number > 1.0e12_dp)
THEN
1289 "WARNING: high condition number => possibly ill-conditioned matrix"
1293 DEALLOCATE (eigenvalues)
1295 CALL timestop(handle)
1318 TYPE(
cp_fm_type),
INTENT(IN) :: eigenvectors, matrix
1319 REAL(kind=
dp),
DIMENSION(:),
INTENT(IN) :: eigval
1320 INTEGER,
INTENT(IN) :: start_sec_block
1321 REAL(kind=
dp),
INTENT(IN) :: thresh
1323 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_block_jacobi'
1326 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, ev
1328 REAL(kind=
dp) :: tan_theta, tau, c, s
1330 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: c_ip
1332#if defined(__parallel)
1335 INTEGER :: nprow, npcol, block_dim_row, block_dim_col, info, &
1336 ev_row_block_size, iam, mynumrows, mype, npe, q_loc
1337 REAL(kind=
dp),
DIMENSION(:, :),
ALLOCATABLE :: a_loc, ev_loc
1338 INTEGER,
DIMENSION(9) :: desca, descz, &
1343 INTEGER,
EXTERNAL :: numroc
1348 CALL timeset(routinen, handle)
1350#if defined(__parallel)
1351 context => matrix%matrix_struct%context
1352 allgrp = matrix%matrix_struct%para_env
1354 nprow = context%num_pe(1)
1355 npcol = context%num_pe(2)
1357 n = matrix%matrix_struct%nrow_global
1359 a => matrix%local_data
1360 desca(:) = matrix%matrix_struct%descriptor(:)
1361 ev => eigenvectors%local_data
1362 descz(:) = eigenvectors%matrix_struct%descriptor(:)
1368 block_dim_row = start_sec_block - 1
1369 block_dim_col = n - block_dim_row
1370 ALLOCATE (a_loc(block_dim_row, block_dim_col))
1372 mype = matrix%matrix_struct%para_env%mepos
1373 npe = matrix%matrix_struct%para_env%num_pe
1375 CALL ictxt_loc%gridinit(matrix%matrix_struct%para_env,
'R', nprow*npcol, 1)
1377 CALL descinit(desc_a_block, block_dim_row, block_dim_col, block_dim_row, &
1378 block_dim_col, 0, 0, ictxt_loc%get_handle(), block_dim_row, info)
1380 CALL pdgemr2d(block_dim_row, block_dim_col, a, 1, start_sec_block, desca, &
1381 a_loc, 1, 1, desc_a_block, context%get_handle())
1383 CALL allgrp%bcast(a_loc, 0)
1390 ev_row_block_size = n/(nprow*npcol)
1391 mynumrows = numroc(n, ev_row_block_size, iam, 0, nprow*npcol)
1393 ALLOCATE (ev_loc(mynumrows, n), c_ip(mynumrows))
1395 CALL descinit(desc_ev_loc, n, n, ev_row_block_size, n, 0, 0, ictxt_loc%get_handle(), &
1398 CALL pdgemr2d(n, n, ev, 1, 1, descz, ev_loc, 1, 1, desc_ev_loc, context%get_handle())
1404 DO q = start_sec_block, n
1406 DO p = 1, (start_sec_block - 1)
1408 IF (abs(a_loc(p, q_loc)) > thresh)
THEN
1410 tau = (eigval(q) - eigval(p))/(2.0_dp*a_loc(p, q_loc))
1412 tan_theta = sign(1.0_dp, tau)/(abs(tau) + sqrt(1.0_dp + tau*tau))
1415 c = 1.0_dp/sqrt(1.0_dp + tan_theta*tan_theta)
1423 CALL dcopy(mynumrows, ev_loc(1, p), 1, c_ip(1), 1)
1424 CALL dscal(mynumrows, c, ev_loc(1, p), 1)
1425 CALL daxpy(mynumrows, -s, ev_loc(1, q), 1, ev_loc(1, p), 1)
1426 CALL dscal(mynumrows, c, ev_loc(1, q), 1)
1427 CALL daxpy(mynumrows, s, c_ip(1), 1, ev_loc(1, q), 1)
1435 CALL pdgemr2d(n, n, ev_loc, 1, 1, desc_ev_loc, ev, 1, 1, descz, context%get_handle())
1438 DEALLOCATE (a_loc, ev_loc, c_ip)
1440 CALL ictxt_loc%gridexit()
1444 n = matrix%matrix_struct%nrow_global
1448 a => matrix%local_data
1449 ev => eigenvectors%local_data
1456 DO q = start_sec_block, n
1457 DO p = 1, (start_sec_block - 1)
1459 IF (abs(a(p, q)) > thresh)
THEN
1461 tau = (eigval(q) - eigval(p))/(2.0_dp*a(p, q))
1463 tan_theta = sign(1.0_dp, tau)/(abs(tau) + sqrt(1.0_dp + tau*tau))
1466 c = 1.0_dp/sqrt(1.0_dp + tan_theta*tan_theta)
1474 CALL dcopy(n, ev(1, p), 1, c_ip(1), 1)
1475 CALL dscal(n, c, ev(1, p), 1)
1476 CALL daxpy(n, -s, ev(1, q), 1, ev(1, p), 1)
1477 CALL dscal(n, c, ev(1, q), 1)
1478 CALL daxpy(n, s, c_ip(1), 1, ev(1, q), 1)
1491 CALL timestop(handle)
1505 SUBROUTINE cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
1507 TYPE(
cp_fm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
1508 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues
1511 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_geeig'
1513 INTEGER :: handle, nao, nmo
1514 LOGICAL :: check_eigenvectors
1515 TYPE(
cp_fm_type) :: overlap_check, scratch_check
1517 CALL timeset(routinen, handle)
1520 nmo =
SIZE(eigenvalues)
1528 IF (check_eigenvectors)
THEN
1529 CALL cp_fm_create(overlap_check, bmatrix%matrix_struct)
1530 CALL cp_fm_create(scratch_check, bmatrix%matrix_struct)
1534 IF (check_eigenvectors)
THEN
1535 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
1540#if defined(__parallel)
1544 IF (check_eigenvectors)
THEN
1545 CALL cp_fm_create(overlap_check, bmatrix%matrix_struct)
1546 CALL cp_fm_create(scratch_check, bmatrix%matrix_struct)
1549 CALL cp_fm_geeig_scalapack(amatrix, bmatrix, work, eigenvalues)
1550 IF (check_eigenvectors)
THEN
1551 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
1561 IF (check_eigenvectors)
THEN
1562 CALL cp_fm_create(overlap_check, bmatrix%matrix_struct)
1563 CALL cp_fm_create(scratch_check, bmatrix%matrix_struct)
1567 IF (check_eigenvectors)
THEN
1568 CALL check_generalized_diag(overlap_check, work, scratch_check, nmo)
1584 eigenvalues=eigenvalues)
1590 CALL timestop(handle)
1601 SUBROUTINE cp_fm_geeig_scalapack(amatrix, bmatrix, eigenvectors, eigenvalues)
1603 TYPE(
cp_fm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
1604 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
1606 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_geeig_scalapack'
1608#if defined(__parallel)
1609 REAL(kind=
dp),
PARAMETER :: orfac = -1.0_dp, &
1613 INTEGER :: handle, info, liwork, lwork, m, n, nb, &
1614 neig, npcol, nprow, nz
1615 INTEGER,
DIMENSION(9) :: desca, descb, descz
1616 INTEGER,
DIMENSION(:),
ALLOCATABLE :: iclustr, ifail, iwork
1617 REAL(kind=
dp) :: abstol
1618 REAL(kind=
dp),
DIMENSION(:),
ALLOCATABLE :: gap, w, work
1619 REAL(kind=
dp),
DIMENSION(:, :),
POINTER :: a, b, z
1621 INTEGER :: mq0, nn, np0, npe
1622 INTEGER,
EXTERNAL :: iceil, numroc
1623 REAL(kind=
dp),
EXTERNAL :: dlamch
1624#if defined (__HAS_IEEE_EXCEPTIONS)
1625 LOGICAL,
DIMENSION(5) :: halt
1631 CALL timeset(routinen, handle)
1633#if defined(__parallel)
1634 n = amatrix%matrix_struct%nrow_global
1635 neig = min(
SIZE(eigenvalues), n)
1638 CALL timestop(handle)
1642 IF (amatrix%matrix_struct%nrow_block /= amatrix%matrix_struct%ncol_block)
THEN
1643 cpabort(
"ERROR in "//routinen//
": Invalid blocksize (no square blocks) found")
1646 a => amatrix%local_data
1647 b => bmatrix%local_data
1648 z => eigenvectors%local_data
1649 desca(:) = amatrix%matrix_struct%descriptor(:)
1650 descb(:) = bmatrix%matrix_struct%descriptor(:)
1651 descz(:) = eigenvectors%matrix_struct%descriptor(:)
1653 nprow = amatrix%matrix_struct%context%num_pe(1)
1654 npcol = amatrix%matrix_struct%context%num_pe(2)
1656 nb = amatrix%matrix_struct%nrow_block
1658 np0 = numroc(nn, nb, 0, 0, nprow)
1659 mq0 = max(numroc(nn, nb, 0, 0, npcol), nb)
1661 lwork = 5*n + max(5*nn, np0*mq0 + 2*nb*nb) + iceil(neig, npe)*nn + &
1663 liwork = 6*max(n, npe + 1, 4)
1667 ALLOCATE (iclustr(2*npe))
1671 ALLOCATE (iwork(liwork))
1673 ALLOCATE (work(lwork))
1675 abstol = 2.0_dp*dlamch(
"S")
1677#if defined (__HAS_IEEE_EXCEPTIONS)
1678 CALL ieee_get_halting_mode(ieee_all, halt)
1679 CALL ieee_set_halting_mode(ieee_all, .false.)
1681 CALL pdsygvx(1,
"V",
"I",
"U", n, a(1, 1), 1, 1, desca, b(1, 1), 1, 1, descb, &
1682 vl, vu, 1, neig, abstol, m, nz, w(1), orfac, z(1, 1), 1, 1, descz, &
1683 work(1), lwork, iwork(1), liwork, ifail(1), iclustr(1), gap(1), info)
1684#if defined (__HAS_IEEE_EXCEPTIONS)
1685 CALL ieee_set_halting_mode(ieee_all, halt)
1688 IF (info /= 0 .OR. m < neig .OR. nz < neig)
THEN
1689 cpabort(
"ERROR in PDSYGVX (ScaLAPACK), info="//trim(
cp_to_string(info)))
1692 eigenvalues(:) = 0.0_dp
1693 eigenvalues(1:neig) = w(1:neig)
1695 DEALLOCATE (gap, iclustr, ifail, iwork, w, work)
1699 mark_used(eigenvectors)
1700 mark_used(eigenvalues)
1701 cpabort(
"ERROR in "//routinen//
": PDSYGVX requested without ScaLAPACK support")
1704 CALL timestop(handle)
1706 END SUBROUTINE cp_fm_geeig_scalapack
1722 TYPE(
cp_fm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
1723 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
1725 REAL(kind=
dp),
INTENT(IN) :: epseig
1726 INTEGER,
INTENT(OUT),
OPTIONAL :: nmo_retained
1728 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_geeig_canon'
1730 INTEGER :: handle, i, icol, irow, nao, nc, ncol, &
1732 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
1734 CALL timeset(routinen, handle)
1738 nmo =
SIZE(eigenvalues)
1739 ALLOCATE (evals(nao))
1744 evals(:) = -evals(:)
1747 IF (evals(i) < epseig)
THEN
1758 CALL cp_fm_to_fm(work, eigenvectors, ncol, nc + 1, nc + 1)
1761 DO icol = nc + 1, nao
1767 evals(nc + 1:nao) = 1.0_dp
1770 evals(:) = 1.0_dp/sqrt(evals(:))
1773 CALL cp_fm_gemm(
"T",
"N", nao, nao, nao, 1.0_dp, work, amatrix, 0.0_dp, bmatrix)
1774 CALL cp_fm_gemm(
"N",
"N", nao, nao, nao, 1.0_dp, bmatrix, work, 0.0_dp, amatrix)
1777 DO icol = nc + 1, nao
1782 CALL choose_eigv_solver(matrix=amatrix, eigenvectors=bmatrix, eigenvalues=eigenvalues)
1785 CALL cp_fm_gemm(
"N",
"N", nao, nx, nc, 1.0_dp, work, bmatrix, 0.0_dp, eigenvectors)
1789 IF (
PRESENT(nmo_retained)) nmo_retained = nc
1793 CALL timestop(handle)
static void dgemm(const char transa, const char transb, const int m, const int n, const int k, const double alpha, const double *a, const int lda, const double *b, const int ldb, const double beta, double *c, const int ldc)
Convenient wrapper to hide Fortran nature of dgemm_, swapping a and b.
methods related to the blacs parallel environment
wrappers for the actual blacs calls. all functionality needed in the code should actually be provide ...
Wrapper for ELPA (complex matrices, i.e. cp_cfm_type).
subroutine, public set_elpa_c_kernel(requested_kernel)
Sets the active ELPA kernel for complex matrices.
subroutine, public cp_dlaf_finalize()
Finalize DLA-Future and pika runtime.
subroutine, public cp_dlaf_initialize()
Initialize DLA-Future and pika runtime.
Basic linear algebra operations for full matrices.
subroutine, public cp_fm_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)
computes matrix_c = beta * matrix_c + alpha * ( matrix_a ** transa ) * ( matrix_b ** transb )
subroutine, public cp_fm_syrk(uplo, trans, k, alpha, matrix_a, ia, ja, beta, matrix_c)
performs a rank-k update of a symmetric matrix_c matrix_c = beta * matrix_c + alpha * matrix_a * tran...
subroutine, public cp_fm_uplo_to_full(matrix, work, uplo)
given a triangular matrix according to uplo, computes the corresponding full matrix
subroutine, public cp_fm_scale(alpha, matrix_a)
scales a matrix matrix_a = alpha * matrix_b
subroutine, public cp_fm_column_scale(matrixa, scaling, first_col, source)
Scales columns of the full matrix by corresponding factors.
subroutine, public cp_fm_triangular_invert(matrix_a, uplo_tr)
inverts a triangular matrix
subroutine, public cp_fm_triangular_multiply(triangular_matrix, matrix_b, side, transpose_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...
various cholesky decomposition related routines
subroutine, public cp_fm_cholesky_decompose(matrix, n, info_out)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_fm_general_cusolver(amatrix, bmatrix, eigenvectors, eigenvalues)
Driver routine to solve generalized eigenvalue problem A*x = lambda*B*x with cuSOLVERMp.
subroutine, public cp_fm_diag_cusolver(matrix, eigenvectors, eigenvalues)
Driver routine to diagonalize a FM matrix with the cuSOLVERMp library.
Auxiliary tools to redistribute cp_fm_type and cp_cfm_type matrices before and after diagonalization....
subroutine, public cp_fm_redistribute_end(matrix, eigenvectors, eig, matrix_new, eigenvectors_new)
Redistributes eigenvectors and eigenvalues back to the original communicator group.
subroutine, public cp_fm_redistribute_start(matrix, eigenvectors, matrix_new, eigenvectors_new, caller_is_elpa, redist_info)
Determines the optimal number of CPUs for matrix diagonalization and redistributes the input matrices...
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_block_jacobi(matrix, eigenvectors, eigval, thresh, start_sec_block)
...
real(kind=dp), parameter, public eps_check_diag_default
subroutine, public cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
integer, parameter, public fm_diag_type_cusolver
real(kind=dp), parameter, public set_removed_eigval_to
subroutine, public cp_fm_svd(matrix_a, matrix_eigvl, matrix_eigvr_t, eigval, info)
decomposes a quadratic matrix into its singular value decomposition
subroutine, public cp_fm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig, nmo_retained)
General Eigenvalue Problem AX = BXE Use canonical diagonalization : U*s**(-1/2).
integer, parameter, public fm_diag_type_dlaf
integer, parameter, public fm_diag_type_scalapack
subroutine, public cp_fm_syevd(matrix, eigenvectors, eigenvalues, info)
Computes all eigenvalues and vectors of a real symmetric matrix significantly faster than syevx,...
subroutine, public diag_finalize()
Finalize the diagonalization library.
logical, save, public direct_generalized_diagonalization
integer, parameter, public fm_diag_type_default
integer, save, public elpa_neigvec_min
subroutine, public diag_init(diag_lib, fallback_applied, elpa_kernel, elpa_c_kernel, elpa_neigvec_min_input, elpa_qr, elpa_print, elpa_one_stage, dlaf_neigvec_min_input, eps_check_diag_input, direct_generalized_diagonalization_input, diag_lib_explicit_input)
Setup the diagonalization library to be used.
subroutine, public cp_fm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE. Use cuSOLVERMp directly when requested and large enough; otherwi...
subroutine, public choose_eigv_solver(matrix, eigenvectors, eigenvalues, info)
Choose the Eigensolver depending on which library is available ELPA seems to be unstable for small sy...
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.
subroutine, public cp_fm_syevx(matrix, eigenvectors, eigenvalues, neig, work_syevx)
compute eigenvalues and optionally eigenvectors of a real symmetric matrix using scalapack....
logical, save, public diag_lib_explicit
subroutine, public cp_fm_diag_dlaf(matrix, eigenvectors, eigenvalues)
...
subroutine, public cp_fm_diag_gen_dlaf(a_matrix, b_matrix, eigenvectors, eigenvalues)
...
subroutine, public set_elpa_kernel(requested_kernel)
Sets the active ELPA kernel.
logical, save, public elpa_qr
subroutine, public cp_fm_diag_elpa(matrix, eigenvectors, eigenvalues)
Driver routine to diagonalize a FM matrix with the ELPA library.
logical, save, public elpa_print
subroutine, public finalize_elpa_library()
Finalize the ELPA library.
logical, save, public elpa_one_stage
subroutine, public initialize_elpa_library(one_stage, qr, should_print)
Initialize the ELPA library.
represent the structure of a full matrix
subroutine, public cp_fm_struct_create(fmstruct, para_env, context, nrow_global, ncol_global, nrow_block, ncol_block, descriptor, first_p_pos, local_leading_dimension, template_fmstruct, square_blocks, force_block)
allocates and initializes a full matrix structure
logical function, public cp_fm_struct_equivalent(fmstruct1, fmstruct2)
returns true if the two matrix structures are equivalent, false otherwise.
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
subroutine, public cp_fm_create(matrix, matrix_struct, name, nrow, ncol, set_zero)
creates a new full matrix with the given structure
subroutine, public cp_fm_set_element(matrix, irow_global, icol_global, alpha)
sets an element of a matrix
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
integer function, public cp_logger_get_unit_nr(logger, local)
returns the unit nr for the requested kind of log.
integer function, public cp_logger_get_default_io_unit(logger)
returns the unit nr for the ionode (-1 on all other processors) skips as well checks if the procs cal...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
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
subroutine, public m_memory(mem)
Returns the total amount of memory [bytes] in use, if known, zero otherwise.
Interface to the message passing library MPI.
basic linear algebra operations for full matrixes
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
keeps the information about the structure of a full matrix
type of a logger, at the moment it contains just a print level starting at which level it should be l...