compute a norm of a dbcsr matrix
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(dbcsr_type), | intent(inout) | :: | matrix |
the matrix |
FUNCTION dbcsr_maxabs(matrix) RESULT(norm) !! compute a norm of a dbcsr matrix TYPE(dbcsr_type), INTENT(INOUT) :: matrix !! the matrix REAL(real_8) :: norm COMPLEX(KIND=real_4), DIMENSION(:, :), POINTER :: data_c COMPLEX(KIND=real_8), DIMENSION(:, :), POINTER :: data_z INTEGER :: blk, col, row LOGICAL :: tr REAL(KIND=real_4), DIMENSION(:, :), POINTER :: data_r REAL(KIND=real_8), DIMENSION(:, :), POINTER :: data_d TYPE(dbcsr_iterator) :: iter ! --------------------------------------------------------------------------- norm = 0.0_dp CALL dbcsr_iterator_start(iter, matrix) DO WHILE (dbcsr_iterator_blocks_left(iter)) SELECT CASE (dbcsr_get_data_type(matrix)) CASE (dbcsr_type_real_4) CALL dbcsr_iterator_next_block(iter, row, col, data_r, tr, blk) norm = MAX(norm, REAL(MAXVAL(ABS(data_r)), dp)) CASE (dbcsr_type_real_8) CALL dbcsr_iterator_next_block(iter, row, col, data_d, tr, blk) norm = MAX(norm, MAXVAL(ABS(data_d))) CASE (dbcsr_type_complex_4) CALL dbcsr_iterator_next_block(iter, row, col, data_c, tr, blk) norm = MAX(norm, REAL(MAXVAL(ABS(data_c)), dp)) CASE (dbcsr_type_complex_8) CALL dbcsr_iterator_next_block(iter, row, col, data_z, tr, blk) norm = MAX(norm, MAXVAL(ABS(data_z))) CASE DEFAULT DBCSR_ABORT("Wrong data type") END SELECT END DO CALL dbcsr_iterator_stop(iter) CALL mp_max(norm, dbcsr_mp_group(dbcsr_distribution_mp(matrix%dist))) END FUNCTION dbcsr_maxabs