34#if defined (__HAS_IEEE_EXCEPTIONS)
35 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
36 ieee_set_halting_mode, &
39#include "../base/base_uses.f90"
44 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_cfm_diag'
61 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
62 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
64 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd'
68 CALL timeset(routinen, handle)
81 CALL cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
99 SUBROUTINE cp_cfm_heevd_base(matrix, eigenvectors, eigenvalues)
101 TYPE(
cp_cfm_type),
INTENT(IN) :: matrix, eigenvectors
102 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
104 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_heevd_base'
106 COMPLEX(KIND=dp),
DIMENSION(:),
POINTER :: work
107 COMPLEX(KIND=dp),
DIMENSION(:, :), &
109 INTEGER :: handle, info, liwork, &
111 INTEGER,
DIMENSION(:),
POINTER :: iwork
112 REAL(kind=
dp),
DIMENSION(:),
POINTER :: rwork
113#if defined(__parallel)
114 INTEGER,
DIMENSION(9) :: descm, descv
115 COMPLEX(KIND=dp),
DIMENSION(:, :), &
117#if defined (__HAS_IEEE_EXCEPTIONS)
118 LOGICAL,
DIMENSION(5) :: halt
122 CALL timeset(routinen, handle)
124 n = matrix%matrix_struct%nrow_global
125 m => matrix%local_data
126 ALLOCATE (iwork(1), rwork(1), work(1))
132#if defined(__parallel)
133 v => eigenvectors%local_data
134 descm(:) = matrix%matrix_struct%descriptor(:)
135 descv(:) = eigenvectors%matrix_struct%descriptor(:)
136 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
137 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
140 lwork = ceiling(real(work(1), kind=
dp)) + 1000
142 lrwork = ceiling(rwork(1)) + 1000000
145 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
146 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
147 lwork = ceiling(real(work(1), kind=
dp))
148 lrwork = ceiling(rwork(1))
152 DEALLOCATE (iwork, rwork, work)
153 ALLOCATE (iwork(liwork), rwork(lrwork), work(lwork))
155#if defined(__parallel)
158#if defined (__HAS_IEEE_EXCEPTIONS)
159 CALL ieee_get_halting_mode(ieee_all, halt)
160 CALL ieee_set_halting_mode(ieee_all, .false.)
163 CALL pzheevd(
'V',
'U', n, m(1, 1), 1, 1, descm, eigenvalues(1), v(1, 1), 1, 1, descv, &
164 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
166#if defined (__HAS_IEEE_EXCEPTIONS)
167 CALL ieee_set_halting_mode(ieee_all, halt)
170 CALL zheevd(
'V',
'U', n, m(1, 1),
SIZE(m, 1), eigenvalues(1), &
171 work(1), lwork, rwork(1), lrwork, iwork(1), liwork, info)
172 eigenvectors%local_data = matrix%local_data
175 DEALLOCATE (iwork, rwork, work)
177 cpabort(
"Diagonalisation of a complex matrix failed")
179 CALL timestop(handle)
181 END SUBROUTINE cp_cfm_heevd_base
194 SUBROUTINE cp_cfm_geeig(amatrix, bmatrix, eigenvectors, eigenvalues, work)
196 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
197 REAL(kind=
dp),
DIMENSION(:) :: eigenvalues
200 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig'
202 INTEGER :: handle, nao, nmo
203 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
205 CALL timeset(routinen, handle)
208 ALLOCATE (evals(nao))
209 nmo =
SIZE(eigenvalues)
233 CALL cp_cfm_heevd(matrix=amatrix, eigenvectors=work, eigenvalues=evals)
241 eigenvalues(1:nmo) = evals(1:nmo)
245 CALL timestop(handle)
261 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
262 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
264 REAL(kind=
dp),
INTENT(IN) :: epseig
266 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_geeig_canon'
268 COMPLEX(KIND=dp),
ALLOCATABLE,
DIMENSION(:) :: cevals
269 INTEGER :: handle, i, icol, irow, nao, nc, ncol, &
271 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: evals
273 CALL timeset(routinen, handle)
277 nmo =
SIZE(eigenvalues)
278 ALLOCATE (evals(nao), cevals(nao))
286 IF (evals(i) < epseig)
THEN
300 DO icol = nc + 1, nao
306 evals(nc + 1:nao) = 1.0_dp
309 cevals(:) = cmplx(1.0_dp/sqrt(evals(:)), 0.0_dp, kind=
dp)
316 DO icol = nc + 1, nao
322 eigenvalues(1:nmo) = evals(1:nmo)
329 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
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public z_zero
Represent a complex full matrix.