matrix_diag Function

private function matrix_diag(vector) result(diag)


Type IntentOptional Attributes Name
real(kind=dp), intent(in) :: vector(:)

Return Value real(kind=dp), (size(vector),size(vector))


Source Code

Source Code

    function matrix_diag(vector) result(diag)
        ! constructs a diagonal matrix with the vector on the diagonal
        real(dp), intent(in) :: vector(:)
        HElement_t(dp) :: diag(size(vector),size(vector))

        integer :: i

        diag = 0.0_dp

        do i = 1, size(vector)
            diag(i,i) = vector(i)
        end do

    end function matrix_diag