function that extracts the diagonal of a matrix where is a vector containing the diagonal elements of the matrix .
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | DIMENSION(:,:) | :: | A |
FUNCTION Diag(A) RESULT(D) REAL(dp), DIMENSION(:,:), INTENT(IN) :: A REAL(dp), DIMENSION(SIZE(A,1)) :: D INTEGER :: i, N N = SIZE(A, 1) FORALL(i=1:N) D(i) = A(i,i) END FUNCTION Diag