Open
Description
In support of: j3-fortran/fortran_proposals#14
Prior art:
- Python numpy.fill_diagonal
- Julia LinearAlgebra.diagind (returns indices of diagonal elements which can then be used to assign to a diagonal)
- MATLAB diag (enabled by MATLAB's special assignment syntax)
Target module: stdlib_linalg
Proposed signature:
! Scalar diagonal variant
pure subroutine set_diag(d, A, k)
{integer(*), real(*)}, complex(*)}, intent(in) :: d !! Value to set the diagonal to
{integer(*), real(*)}, complex(*)}, intent(inout) :: A(:,:) !! Matrix to set the diagonal in
integer, intent(in), optional :: k !! Number of the diagonal
! Array diagonal variant
pure subroutine set_diag(d, A, k)
{integer(*), real(*)}, complex(*)}, intent(in) :: d(:) !! Values to set the diagonal to
{integer(*), real(*)}, complex(*)}, intent(inout) :: A(:,:) !! Matrix to set the diagonal in
integer, intent(in), optional :: k !! Number of the diagonal