Encapsulates a given scalar value and makes it conform with the type of the matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=real_8), | intent(in) | :: | scalar | |||
type(dbcsr_type), | intent(in) | :: | matrix |
FUNCTION make_conformant_scalar_z (scalar, matrix) RESULT(encapsulated)
!! Encapsulates a given scalar value and makes it conform with the
!! type of the matrix.
COMPLEX(kind=real_8), INTENT(IN) :: scalar
TYPE(dbcsr_type), INTENT(IN) :: matrix
TYPE(dbcsr_scalar_type) :: encapsulated
INTEGER :: data_type, scalar_data_type
encapsulated = dbcsr_scalar(scalar)
CALL dbcsr_scalar_fill_all(encapsulated)
data_type = dbcsr_get_data_type(matrix)
scalar_data_type = dbcsr_scalar_get_type(encapsulated)
IF (scalar_data_type .EQ. dbcsr_type_complex_4 .OR. &
scalar_data_type .EQ. dbcsr_type_complex_8) THEN
IF (data_type .NE. dbcsr_type_complex_4 .AND. data_type .NE. dbcsr_type_complex_8) &
DBCSR_ABORT("Can not conform a complex to a real number")
END IF
CALL dbcsr_scalar_set_type(encapsulated, data_type)
END FUNCTION make_conformant_scalar_z