31 USE dbcsr_api,
ONLY: dbcsr_get_info,&
34 #include "base/base_uses.f90"
38 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'cp_dbcsr_cholesky'
61 TYPE(dbcsr_type) :: matrix
62 INTEGER,
INTENT(in),
OPTIONAL :: n
63 TYPE(mp_para_env_type),
POINTER :: para_env
64 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
66 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_cholesky_decompose'
68 INTEGER :: handle, my_n, nfullcols_total, &
70 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
71 TYPE(cp_fm_type) :: fm_matrix
73 CALL timeset(routinen, handle)
76 CALL dbcsr_get_info(matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
79 ncol_global=nfullcols_total, para_env=para_env)
80 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
85 my_n = min(fm_matrix%matrix_struct%nrow_global, &
86 fm_matrix%matrix_struct%ncol_global)
96 CALL cp_fm_release(fm_matrix)
114 TYPE(dbcsr_type) :: matrix
115 INTEGER,
INTENT(in),
OPTIONAL :: n
116 TYPE(mp_para_env_type),
POINTER :: para_env
117 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
118 LOGICAL,
INTENT(IN) :: upper_to_full
120 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_cholesky_invert'
122 INTEGER :: handle, my_n, nfullcols_total, &
124 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
125 TYPE(cp_fm_type) :: fm_matrix, fm_matrix_tmp
127 CALL timeset(routinen, handle)
130 CALL dbcsr_get_info(matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
133 ncol_global=nfullrows_total, para_env=para_env)
134 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
139 my_n = min(fm_matrix%matrix_struct%nrow_global, &
140 fm_matrix%matrix_struct%ncol_global)
148 IF (upper_to_full)
THEN
149 CALL cp_fm_create(fm_matrix_tmp, fm_matrix%matrix_struct, name=
"fm_matrix_tmp")
151 CALL cp_fm_release(fm_matrix_tmp)
156 CALL cp_fm_release(fm_matrix)
158 CALL timestop(handle)
176 TYPE(dbcsr_type) :: matrix
177 INTEGER,
INTENT(IN) :: neig
178 TYPE(dbcsr_type) :: matrixb, matrixout
179 CHARACTER(LEN=*),
INTENT(IN) :: op
180 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: pos, transa
181 TYPE(mp_para_env_type),
POINTER :: para_env
182 TYPE(cp_blacs_env_type),
POINTER :: blacs_env
184 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_dbcsr_cholesky_restore'
186 CHARACTER :: chol_pos, chol_transa
187 INTEGER :: handle, nfullcols_total, nfullrows_total
188 TYPE(cp_fm_struct_type),
POINTER :: fm_struct
189 TYPE(cp_fm_type) :: fm_matrix, fm_matrixb, fm_matrixout
191 CALL timeset(routinen, handle)
195 CALL dbcsr_get_info(matrix, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
197 ncol_global=nfullcols_total, para_env=para_env)
198 CALL cp_fm_create(fm_matrix, fm_struct, name=
"fm_matrix")
201 CALL dbcsr_get_info(matrixb, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
203 ncol_global=nfullcols_total, para_env=para_env)
204 CALL cp_fm_create(fm_matrixb, fm_struct, name=
"fm_matrixb")
207 CALL dbcsr_get_info(matrixout, nfullrows_total=nfullrows_total, nfullcols_total=nfullcols_total)
209 ncol_global=nfullcols_total, para_env=para_env)
210 CALL cp_fm_create(fm_matrixout, fm_struct, name=
"fm_matrixout")
217 IF (op /=
"SOLVE" .AND. op /=
"MULTIPLY") &
218 cpabort(
"wrong argument op")
220 IF (
PRESENT(pos))
THEN
227 cpabort(
"wrong argument pos")
234 IF (
PRESENT(transa)) chol_transa = transa
236 IF ((fm_matrix%use_sp .NEQV. fm_matrixb%use_sp) .OR. (fm_matrix%use_sp .NEQV. fm_matrixout%use_sp)) &
237 cpabort(
"not the same precision")
243 CALL cp_fm_release(fm_matrix)
244 CALL cp_fm_release(fm_matrixb)
245 CALL cp_fm_release(fm_matrixout)
247 CALL timestop(handle)
methods related to the blacs parallel environment
Interface to (sca)lapack for the Cholesky based procedures.
subroutine, public cp_dbcsr_cholesky_decompose(matrix, n, para_env, blacs_env)
used to replace a symmetric positive def. matrix M with its cholesky decomposition U: M = U^T * U,...
subroutine, public cp_dbcsr_cholesky_restore(matrix, neig, matrixb, matrixout, op, pos, transa, para_env, blacs_env)
...
subroutine, public cp_dbcsr_cholesky_invert(matrix, n, para_env, blacs_env, upper_to_full)
used to replace the cholesky decomposition by the inverse
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.
basic linear algebra operations for full matrices
subroutine, public cp_fm_potrf(fm_matrix, n)
Cholesky decomposition.
subroutine, public cp_fm_upper_to_full(matrix, work)
given an upper triangular matrix computes the corresponding full matrix
subroutine, public cp_fm_cholesky_restore(fm_matrix, neig, fm_matrixb, fm_matrixout, op, pos, transa)
...
subroutine, public cp_fm_potri(fm_matrix, n)
Invert trianguar matrix.
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
Interface to the message passing library MPI.