35#include "./base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'soc_pseudopotential_utils'
59 nstart_row, nstart_col, factor, add_also_herm_conj)
63 INTEGER :: nstart_row, nstart_col
64 COMPLEX(KIND=dp) :: factor
65 LOGICAL :: add_also_herm_conj
67 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_dbcsr_submat'
69 INTEGER :: handle, nao
72 TYPE(
cp_fm_type) :: fm_mat_work_double_im, fm_mat_work_im
74 CALL timeset(routinen, handle)
76 CALL cp_fm_create(fm_mat_work_double_im, cfm_mat_target%matrix_struct)
79 CALL cp_cfm_create(cfm_mat_work_double, cfm_mat_target%matrix_struct)
80 CALL cp_cfm_create(cfm_mat_work_double_2, cfm_mat_target%matrix_struct)
92 s_firstrow=1, s_firstcol=1, &
93 t_firstrow=nstart_row, t_firstcol=nstart_col)
102 IF (add_also_herm_conj)
THEN
112 CALL timestop(handle)
124 REAL(kind=
dp),
DIMENSION(:) :: alpha
126 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cfm_add_on_diag'
128 INTEGER :: handle, i_global, i_row, j_col, &
129 j_global, nao, ncol_local, nrow_local
130 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
132 CALL timeset(routinen, handle)
135 nrow_local=nrow_local, &
136 ncol_local=ncol_local, &
137 row_indices=row_indices, &
138 col_indices=col_indices)
142 DO j_col = 1, ncol_local
143 j_global = col_indices(j_col)
144 DO i_row = 1, nrow_local
145 i_global = row_indices(i_row)
146 IF (j_global == i_global)
THEN
147 IF (i_global .LE. nao)
THEN
148 cfm%local_data(i_row, j_col) = cfm%local_data(i_row, j_col) + &
149 alpha(i_global)*
z_one
151 cfm%local_data(i_row, j_col) = cfm%local_data(i_row, j_col) + &
152 alpha(i_global - nao)*
z_one
158 CALL timestop(handle)
169 SUBROUTINE add_fm_submat(cfm_mat_target, fm_mat_source, nstart_row, nstart_col)
173 INTEGER :: nstart_row, nstart_col
175 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_fm_submat'
177 INTEGER :: handle, nao
180 CALL timeset(routinen, handle)
182 CALL cp_fm_create(fm_mat_work_double_re, cfm_mat_target%matrix_struct)
188 nrow=nao, ncol=nao, &
189 s_firstrow=1, s_firstcol=1, &
190 t_firstrow=nstart_row, t_firstcol=nstart_col)
196 CALL timestop(handle)
208 SUBROUTINE add_cfm_submat(cfm_mat_target, cfm_mat_source, nstart_row, nstart_col, factor)
210 TYPE(
cp_cfm_type) :: cfm_mat_target, cfm_mat_source
211 INTEGER :: nstart_row, nstart_col
212 COMPLEX(KIND=dp),
OPTIONAL :: factor
214 CHARACTER(LEN=*),
PARAMETER :: routinen =
'add_cfm_submat'
216 COMPLEX(KIND=dp) :: factor_im, factor_re
217 INTEGER :: handle, nao
218 TYPE(
cp_fm_type) :: fm_mat_source_im, fm_mat_source_re, &
219 fm_mat_work_double_im, &
220 fm_mat_work_double_re
222 CALL timeset(routinen, handle)
224 CALL cp_fm_create(fm_mat_work_double_re, cfm_mat_target%matrix_struct)
225 CALL cp_fm_create(fm_mat_work_double_im, cfm_mat_target%matrix_struct)
229 CALL cp_fm_create(fm_mat_source_re, cfm_mat_source%matrix_struct)
230 CALL cp_fm_create(fm_mat_source_im, cfm_mat_source%matrix_struct)
231 CALL cp_cfm_to_fm(cfm_mat_source, fm_mat_source_re, fm_mat_source_im)
236 nrow=nao, ncol=nao, &
237 s_firstrow=1, s_firstcol=1, &
238 t_firstrow=nstart_row, t_firstcol=nstart_col)
241 nrow=nao, ncol=nao, &
242 s_firstrow=1, s_firstcol=1, &
243 t_firstrow=nstart_row, t_firstcol=nstart_col)
245 IF (
PRESENT(factor))
THEN
261 CALL timestop(handle)
272 SUBROUTINE get_cfm_submat(cfm_mat_target, cfm_mat_source, nstart_row, nstart_col)
274 TYPE(
cp_cfm_type) :: cfm_mat_target, cfm_mat_source
275 INTEGER :: nstart_row, nstart_col
277 CHARACTER(LEN=*),
PARAMETER :: routinen =
'get_cfm_submat'
279 INTEGER :: handle, nao
280 TYPE(
cp_fm_type) :: fm_mat_source_double_im, &
281 fm_mat_source_double_re, &
282 fm_mat_work_im, fm_mat_work_re
284 CALL timeset(routinen, handle)
286 CALL cp_fm_create(fm_mat_source_double_re, cfm_mat_source%matrix_struct)
287 CALL cp_fm_create(fm_mat_source_double_im, cfm_mat_source%matrix_struct)
288 CALL cp_cfm_to_fm(cfm_mat_source, fm_mat_source_double_re, fm_mat_source_double_im)
290 CALL cp_fm_create(fm_mat_work_re, cfm_mat_target%matrix_struct)
291 CALL cp_fm_create(fm_mat_work_im, cfm_mat_target%matrix_struct)
298 nrow=nao, ncol=nao, &
299 s_firstrow=nstart_row, s_firstcol=nstart_col, &
300 t_firstrow=1, t_firstcol=1)
303 nrow=nao, ncol=nao, &
304 s_firstrow=nstart_row, s_firstcol=nstart_col, &
305 t_firstrow=1, t_firstcol=1)
307 CALL cp_fm_to_cfm(fm_mat_work_re, fm_mat_work_im, cfm_mat_target)
314 CALL timestop(handle)
329 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_cfm_double'
331 INTEGER :: handle, ncol_global_orig, &
333 LOGICAL :: do_cfm_templ, do_fm_templ
336 CALL timeset(routinen, handle)
338 do_fm_templ =
PRESENT(fm_orig)
339 do_cfm_templ =
PRESENT(cfm_orig)
342 cpassert(do_fm_templ .NEQV. do_cfm_templ)
344 IF (do_fm_templ)
THEN
345 CALL cp_fm_get_info(matrix=fm_orig, nrow_global=nrow_global_orig, &
346 ncol_global=ncol_global_orig)
347 matrix_struct => fm_orig%matrix_struct
349 IF (do_cfm_templ)
THEN
351 ncol_global=ncol_global_orig)
352 matrix_struct => cfm_orig%matrix_struct
356 nrow_global=2*nrow_global_orig, &
357 ncol_global=2*ncol_global_orig, &
358 template_fmstruct=matrix_struct)
366 CALL timestop(handle)
Basic linear algebra operations for complex full matrices.
subroutine, public cp_cfm_scale_and_add(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b).
subroutine, public cp_cfm_transpose(matrix, trans, matrixt)
Transposes a BLACS distributed complex matrix.
subroutine, public cp_cfm_scale_and_add_fm(alpha, matrix_a, beta, matrix_b)
Scale and add two BLACS matrices (a = alpha*a + beta*b). where b is a real matrix (adapted from cp_cf...
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_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_cfm_set_all(matrix, alpha, beta)
Set all elements of the full matrix to alpha. Besides, set all diagonal matrix elements to beta (if g...
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.
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS 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_get_info(matrix, name, nrow_global, ncol_global, nrow_block, ncol_block, nrow_local, ncol_local, row_indices, col_indices, local_data, context, nrow_locals, ncol_locals, matrix_struct, para_env)
returns all kind of information about the full matrix
subroutine, public cp_fm_to_fm_submat(msource, mtarget, nrow, ncol, s_firstrow, s_firstcol, t_firstrow, t_firstcol)
copy just a part ot the matrix
subroutine, public cp_fm_set_all(matrix, alpha, beta)
set all elements of a matrix to the same value, and optionally the diagonal to a different one
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
Definition of mathematical constants and functions.
complex(kind=dp), parameter, public z_one
complex(kind=dp), parameter, public gaussi
complex(kind=dp), parameter, public z_zero
subroutine, public create_cfm_double(cfm_double, fm_orig, cfm_orig)
...
subroutine, public add_dbcsr_submat(cfm_mat_target, mat_source, fm_struct_source, nstart_row, nstart_col, factor, add_also_herm_conj)
...
subroutine, public add_cfm_submat(cfm_mat_target, cfm_mat_source, nstart_row, nstart_col, factor)
...
subroutine, public get_cfm_submat(cfm_mat_target, cfm_mat_source, nstart_row, nstart_col)
...
subroutine, public add_fm_submat(cfm_mat_target, fm_mat_source, nstart_row, nstart_col)
...
subroutine, public cfm_add_on_diag(cfm, alpha)
...
Represent a complex full matrix.
keeps the information about the structure of a full matrix