32#if defined (__HAS_IEEE_EXCEPTIONS)
33 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
34 ieee_set_halting_mode, &
38#include "../base/base_uses.f90"
43 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_cfm_diag'
60 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
61 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
63 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd'
67 CALL timeset(routinen, handle)
80 CALL cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
98 SUBROUTINE cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
100 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
101 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
103 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd_base'
105 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: work
106 COMPLEX(KIND=dp),
DIMENSION(:, :), &
108 INTEGER :: handle, info, liwork, &
110 INTEGER,
DIMENSION(:),
POINTER :: iwork
111 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rwork
112#if defined(__parallel)
113 INTEGER,
DIMENSION(9) :: descm, descv
114 COMPLEX(KIND=dp),
DIMENSION(:, :), &
116#if defined (__HAS_IEEE_EXCEPTIONS)
117 LOGICAL,
DIMENSION(5) :: halt
121 CALL timeset(routinen, handle)
123 n = matrix%matrix_struct%nrow_global
124 m => matrix%local_data
125 ALLOCATE (iwork(1), rwork(1), work(1))
131#if defined(__parallel)
132 v => eigenvectors%local_data
133 descm(:) = matrix%matrix_struct%descriptor(:)
134 descv(:) = eigenvectors%matrix_struct%descriptor(:)
135 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
136 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
139 lwork = ceiling(real(work(1), kind=
dp)) + 1000
141 lrwork = ceiling(rwork(1)) + 1000000
144 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
145 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
146 lwork = ceiling(real(work(1), kind=
dp))
147 lrwork = ceiling(rwork(1))
151 DEALLOCATE (iwork, rwork, work)
152 ALLOCATE (iwork(liwork), rwork(lrwork), work(lwork))
154#if defined(__parallel)
157#if defined (__HAS_IEEE_EXCEPTIONS)
158 CALL ieee_get_halting_mode(ieee_all, halt)
159 CALL ieee_set_halting_mode(ieee_all, .false.)
162 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
163 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
165#if defined (__HAS_IEEE_EXCEPTIONS)
166 CALL ieee_set_halting_mode(ieee_all, halt)
169 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
170 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
171 eigenvectors%local_data = matrix%local_data
174 DEALLOCATE (iwork, rwork, work)
176 cpabort(
"Diagonalisation of a complex matrix failed")
178 CALL timestop(handle)
180 END SUBROUTINE cp_cfm_heevd_base
193 SUBROUTINE cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
195 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
196 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues
199 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig'
201 INTEGER :: handle, nao, nmo
202 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
204 CALL timeset(routinen, handle)
207 ALLOCATE (evals(nao))
208 nmo =
SIZE(eigenvalues)
232 CALL cp_cfm_heevd(matrix=amatrix, eigenvectors=work, eigenvalues=evals)
240 eigenvalues(1:nmo) = evals(1:nmo)
244 CALL timestop(handle)
260 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
261 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
263 REAL(kind=
dp),
INTENT(IN) :: epseig
265 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_canon'
266 COMPLEX(KIND=dp),
PARAMETER :: cone = cmplx(1.0_dp, 0.0_dp, kind=
dp), &
267 czero = cmplx(0.0_dp, 0.0_dp, kind=
dp)
269 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cevals
270 INTEGER :: handle, i, icol, irow, nao, nc, ncol, &
272 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
274 CALL timeset(routinen, handle)
278 nmo =
SIZE(eigenvalues)
279 ALLOCATE (evals(nao), cevals(nao))
287 IF (evals(i) < epseig)
THEN
301 DO icol = nc + 1, nao
307 evals(nc + 1:nao) = 1.0_dp
310 cevals(:) = cmplx(1.0_dp/sqrt(evals(:)), 0.0_dp, kind=
dp)
313 CALL cp_cfm_gemm(
"C",
"N", nao, nao, nao, cone, work, amatrix, czero, bmatrix)
314 CALL cp_cfm_gemm(
"N",
"N", nao, nao, nao, cone, bmatrix, work, czero, amatrix)
317 DO icol = nc + 1, nao
323 eigenvalues(1:nmo) = evals(1:nmo)
326 CALL cp_cfm_gemm(
"N",
"N", nao, nx, nc, cone, work, bmatrix, czero, eigenvectors)
330 CALL timestop(handle)
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)
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(amatrix, bmatrix, eigenvectors, eigenvalues, work)
General Eigenvalue Problem AX = BXE Single option version: Cholesky decomposition of B.
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
subroutine, public cp_cfm_geeig_canon(amatrix, bmatrix, eigenvectors, eigenvalues, work, epseig)
General Eigenvalue Problem AX = BXE Use canonical orthogonalization.
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.
Represents a complex full matrix distributed on many processors.
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_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.
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
integer, parameter, public fm_diag_type_dlaf
integer, save, public diag_type
Defines the basic variable types.
integer, parameter, public dp
Represent a complex full matrix.