31#if defined (__HAS_IEEE_EXCEPTIONS)
32 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
33 ieee_set_halting_mode, &
37#include "../base/base_uses.f90"
42 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_cfm_diag'
59 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
60 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
62 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd'
66 CALL timeset(routinen, handle)
73 CALL cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
91 SUBROUTINE cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
93 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
94 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
96 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd_base'
98 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: work
99 COMPLEX(KIND=dp),
DIMENSION(:, :), &
101 INTEGER :: handle, info, liwork, &
103 INTEGER,
DIMENSION(:),
POINTER :: iwork
104 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rwork
105#if defined(__parallel)
106 INTEGER,
DIMENSION(9) :: descm, descv
107 COMPLEX(KIND=dp),
DIMENSION(:, :), &
109#if defined (__HAS_IEEE_EXCEPTIONS)
110 LOGICAL,
DIMENSION(5) :: halt
114 CALL timeset(routinen, handle)
116 n = matrix%matrix_struct%nrow_global
117 m => matrix%local_data
118 ALLOCATE (iwork(1), rwork(1), work(1))
124#if defined(__parallel)
125 v => eigenvectors%local_data
126 descm(:) = matrix%matrix_struct%descriptor(:)
127 descv(:) = eigenvectors%matrix_struct%descriptor(:)
128 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
129 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
132 lwork = ceiling(real(work(1), kind=
dp)) + 1000
134 lrwork = ceiling(rwork(1)) + 1000000
137 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
138 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
139 lwork = ceiling(real(work(1), kind=
dp))
140 lrwork = ceiling(rwork(1))
144 DEALLOCATE (iwork, rwork, work)
145 ALLOCATE (iwork(liwork), rwork(lrwork), work(lwork))
147#if defined(__parallel)
150#if defined (__HAS_IEEE_EXCEPTIONS)
151 CALL ieee_get_halting_mode(ieee_all, halt)
152 CALL ieee_set_halting_mode(ieee_all, .false.)
155 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
156 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
158#if defined (__HAS_IEEE_EXCEPTIONS)
159 CALL ieee_set_halting_mode(ieee_all, halt)
162 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
163 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
164 eigenvectors%local_data = matrix%local_data
167 DEALLOCATE (iwork, rwork, work)
169 cpabort(
"Diagonalisation of a complex matrix failed")
171 CALL timestop(handle)
173 END SUBROUTINE cp_cfm_heevd_base
186 SUBROUTINE cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
188 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
189 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues
192 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig'
194 INTEGER :: handle, nao, nmo
195 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
197 CALL timeset(routinen, handle)
200 ALLOCATE (evals(nao))
201 nmo =
SIZE(eigenvalues)
217 CALL cp_cfm_heevd(matrix=amatrix, eigenvectors=work, eigenvalues=evals)
225 eigenvalues(1:nmo) = evals(1:nmo)
229 CALL timestop(handle)
245 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
246 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
248 REAL(kind=
dp),
INTENT(IN) :: epseig
250 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_canon'
251 COMPLEX(KIND=dp),
PARAMETER :: cone = cmplx(1.0_dp, 0.0_dp, kind=
dp), &
252 czero = cmplx(0.0_dp, 0.0_dp, kind=
dp)
254 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cevals
255 INTEGER :: handle, i, icol, irow, nao, nc, ncol, &
257 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
259 CALL timeset(routinen, handle)
263 nmo =
SIZE(eigenvalues)
264 ALLOCATE (evals(nao), cevals(nao))
272 IF (evals(i) < epseig)
THEN
286 DO icol = nc + 1, nao
292 evals(nc + 1:nao) = 1.0_dp
295 cevals(:) = cmplx(1.0_dp/sqrt(evals(:)), 0.0_dp, kind=
dp)
298 CALL cp_cfm_gemm(
"C",
"N", nao, nao, nao, cone, work, amatrix, czero, bmatrix)
299 CALL cp_cfm_gemm(
"N",
"N", nao, nao, nao, cone, bmatrix, work, czero, amatrix)
302 DO icol = nc + 1, nao
308 eigenvalues(1:nmo) = evals(1:nmo)
311 CALL cp_cfm_gemm(
"N",
"N", nao, nx, nc, cone, work, bmatrix, czero, eigenvectors)
315 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.
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.