41#include "base/base_uses.f90"
47 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_dbcsr_diag'
66 SUBROUTINE cp_dbcsr_syevd(matrix, eigenvectors, eigenvalues, para_env, blacs_env)
74 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
78 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_syevd'
80 INTEGER :: handle, nfullrows_total
84 CALL timeset(routinen, handle)
90 ncol_global=nfullrows_total, para_env=para_env)
91 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
92 CALL cp_fm_create(fm_eigenvectors, fm_struct, name=
"fm_eigenvectors")
104 CALL timestop(handle)
130 TYPE(
dbcsr_type),
OPTIONAL,
POINTER :: eigenvectors
131 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
132 INTEGER,
INTENT(IN),
OPTIONAL :: neig
133 REAL(kind=
dp),
INTENT(IN),
OPTIONAL :: work_syevx
137 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_dbcsr_syevx'
139 INTEGER :: handle, n, neig_local
141 TYPE(
cp_fm_type) :: fm_eigenvectors, fm_matrix
143 CALL timeset(routinen, handle)
148 IF (
PRESENT(neig)) neig_local = neig
149 IF (neig_local == 0)
RETURN
153 ncol_global=n, para_env=para_env)
154 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
158 IF (
PRESENT(eigenvectors))
THEN
159 CALL cp_fm_create(fm_eigenvectors, fm_struct, name=
"fm_eigenvectors")
160 CALL cp_fm_syevx(fm_matrix, fm_eigenvectors, eigenvalues, neig, work_syevx)
164 CALL cp_fm_syevx(fm_matrix, eigenvalues=eigenvalues, neig=neig, work_syevx=work_syevx)
170 CALL timestop(handle)
184 SUBROUTINE cp_dbcsr_heevd(matrix_re, matrix_im, eigenvectors_re, eigenvectors_im, &
185 eigenvalues, para_env, blacs_env)
187 TYPE(
dbcsr_type),
OPTIONAL :: matrix_re, matrix_im, eigenvectors_re, &
189 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
193 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_heevd'
195 INTEGER :: handle, nfullrows_total
198 TYPE(
cp_fm_type) :: fm_eigenvectors_im, fm_eigenvectors_re, &
199 fm_matrix_im, fm_matrix_re
201 CALL timeset(routinen, handle)
205 IF (
PRESENT(matrix_re))
THEN
207 ELSE IF (
PRESENT(matrix_im))
THEN
210 cpabort(
"Neither matrix_re nor matrix_im are present.")
213 ncol_global=nfullrows_total, para_env=para_env)
216 IF (
PRESENT(matrix_re))
THEN
217 CALL cp_fm_create(fm_matrix_re, fm_struct, name=
"fm_matrix_re")
220 IF (
PRESENT(matrix_im))
THEN
221 CALL cp_fm_create(fm_matrix_im, fm_struct, name=
"fm_matrix_im")
227 IF (
PRESENT(matrix_re) .AND.
PRESENT(matrix_im))
THEN
228 CALL cp_fm_to_cfm(msourcer=fm_matrix_re, msourcei=fm_matrix_im, mtarget=cfm_matrix)
229 ELSE IF (
PRESENT(matrix_re) .AND. .NOT.
PRESENT(matrix_im))
THEN
230 CALL cp_fm_to_cfm(msourcer=fm_matrix_re, mtarget=cfm_matrix)
231 ELSE IF (.NOT.
PRESENT(matrix_re) .AND.
PRESENT(matrix_im))
THEN
232 CALL cp_fm_to_cfm(msourcei=fm_matrix_im, mtarget=cfm_matrix)
234 cpabort(
"Neither matrix_re nor matrix_im are present.")
240 CALL cp_cfm_create(cfm_eigenvectors, fm_struct, name=
"cfm_eigenvectors")
241 CALL cp_cfm_heevd(cfm_matrix, cfm_eigenvectors, eigenvalues)
245 IF (
PRESENT(eigenvectors_re))
THEN
246 CALL cp_fm_create(fm_eigenvectors_re, fm_struct, name=
"fm_eigenvectors_re")
247 CALL cp_cfm_to_fm(msource=cfm_eigenvectors, mtargetr=fm_eigenvectors_re)
251 IF (
PRESENT(eigenvectors_im))
THEN
252 CALL cp_fm_create(fm_eigenvectors_im, fm_struct, name=
"fm_eigenvectors_im")
253 CALL cp_cfm_to_fm(msource=cfm_eigenvectors, mtargeti=fm_eigenvectors_im)
262 CALL timestop(handle)
278 SUBROUTINE cp_dbcsr_power(matrix, exponent, threshold, n_dependent, para_env, blacs_env, verbose, eigenvectors, eigenvalues)
280 REAL(
dp),
INTENT(IN) :: exponent, threshold
281 INTEGER,
INTENT(OUT) :: n_dependent
284 LOGICAL,
INTENT(IN),
OPTIONAL :: verbose
285 TYPE(
dbcsr_type),
INTENT(INOUT),
OPTIONAL :: eigenvectors
286 REAL(kind=
dp),
DIMENSION(2),
INTENT(OUT),
OPTIONAL :: eigenvalues
288 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_power'
290 INTEGER :: handle, nfullrows_total
291 REAL(kind=
dp),
DIMENSION(2) :: eigenvalues_prv
293 TYPE(
cp_fm_type) :: fm_eigenvectors, fm_matrix
295 CALL timeset(routinen, handle)
301 ncol_global=nfullrows_total, para_env=para_env)
302 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
303 CALL cp_fm_create(fm_eigenvectors, fm_struct, name=
"fm_eigenvectors")
308 CALL cp_fm_power(fm_matrix, fm_eigenvectors, exponent, threshold, n_dependent, verbose, eigenvalues_prv)
313 IF (
PRESENT(eigenvalues)) eigenvalues(:) = eigenvalues_prv
314 IF (
PRESENT(eigenvectors))
CALL copy_fm_to_dbcsr(fm_eigenvectors, eigenvectors)
318 CALL timestop(handle)
methods related to the blacs parallel environment
used for collecting diagonalization schemes available for cp_cfm_type
subroutine, public cp_cfm_heevd(matrix, eigenvectors, eigenvalues)
Perform a diagonalisation of a complex matrix.
Represents a complex full matrix distributed on many processors.
subroutine, public cp_cfm_create(matrix, matrix_struct, name)
Creates a new full matrix with the given structure.
subroutine, public cp_cfm_release(matrix)
Releases a full matrix.
subroutine, public cp_fm_to_cfm(msourcer, msourcei, mtarget)
Construct a complex full matrix by taking its real and imaginary parts from two separate real-value f...
subroutine, public cp_cfm_to_fm(msource, mtargetr, mtargeti)
Copy real and imaginary parts of a complex full matrix into separate real-value full matrices.
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_syevx(matrix, eigenvectors, eigenvalues, neig, work_syevx, para_env, blacs_env)
compute eigenvalues and optionally eigenvectors of a real symmetric matrix using scalapack....
subroutine, public cp_dbcsr_heevd(matrix_re, matrix_im, eigenvectors_re, eigenvectors_im, eigenvalues, para_env, blacs_env)
...
subroutine, public cp_dbcsr_syevd(matrix, eigenvectors, eigenvalues, para_env, blacs_env)
...
subroutine, public cp_dbcsr_power(matrix, exponent, threshold, n_dependent, para_env, blacs_env, verbose, eigenvectors, eigenvalues)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
used for collecting some of the diagonalization schemes available for cp_fm_type. cp_fm_power also mo...
subroutine, public cp_fm_power(matrix, work, exponent, threshold, n_dependent, verbose, eigvals)
...
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...
subroutine, public cp_fm_syevx(matrix, eigenvectors, eigenvalues, neig, work_syevx)
compute eigenvalues and optionally eigenvectors of a real symmetric matrix using scalapack....
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
subroutine, public cp_fm_struct_release(fmstruct)
releases a full matrix structure
represent a full matrix distributed on many processors
subroutine, public cp_fm_create(matrix, matrix_struct, name, use_sp)
creates a new full matrix with the given structure
Defines the basic variable types.
integer, parameter, public dp
Interface to the message passing library MPI.
represent a blacs multidimensional parallel environment (for the mpi corrispective see cp_paratypes/m...
Represent a complex full matrix.
keeps the information about the structure of a full matrix
stores all the informations relevant to an mpi environment