add_scalar_to_diagonal_sp Module Subroutine

module subroutine add_scalar_to_diagonal_sp(matrix_, scalar_)

add a scalar value to the matrix diagonal (single precision).

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(inout) :: matrix_(:,:)
real(kind=sp), intent(in) :: scalar_

Contents


Variables

Type Visibility Attributes Name Initial
integer(kind=int32), private :: i_
integer(kind=int32), private :: size_

Source Code

      module subroutine add_scalar_to_diagonal_sp(matrix_, scalar_)
          !! add a scalar value to the matrix diagonal (single precision).
          real(sp), intent(inout) :: matrix_(:,:)
          real(sp), intent(in) :: scalar_
          !--------------------------------------------------------------------!
          integer(int32) :: i_, size_
          !--------------------------------------------------------------------!
          size_ = size(matrix_, dim = 1)
          !--------------------------------------------------------------------!
          do i_ = 1, size_
            matrix_(i_, i_) = matrix_(i_, i_) + scalar_
          enddo
         !---------------------------------------------------------------------!
      end subroutine add_scalar_to_diagonal_sp