Skip to content

Commit c2beec8

Browse files
committed
introduce module interface
1 parent 7b3b140 commit c2beec8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/stdlib_linalg.fypp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module stdlib_linalg
3232
public :: lstsq
3333
public :: lstsq_space
3434
public :: norm
35+
public :: mnorm
3536
public :: get_norm
3637
public :: solve
3738
public :: solve_lu
@@ -1320,6 +1321,40 @@ module stdlib_linalg
13201321
#:endfor
13211322
end interface get_norm
13221323

1324+
!> Matrix norm: function interface
1325+
interface mnorm
1326+
#:for rk,rt,ri in RC_KINDS_TYPES
1327+
#:for it,ii in NORM_INPUT_OPTIONS
1328+
module function matrix_norm_${ii}$_${ri}$(a, order, err) result(nrm)
1329+
!> Input matrix a(m,n)
1330+
${rt}$, intent(in), target :: a(:,:)
1331+
!> Norm of the matrix.
1332+
real(${rk}$) :: nrm
1333+
!> Order of the matrix norm being computed.
1334+
${it}$, intent(in) :: order
1335+
!> [optional] state return flag. On error if not requested, the code will stop
1336+
type(linalg_state_type), intent(out), optional :: err
1337+
end function matrix_norm_${ii}$_${ri}$
1338+
1339+
#:for rank in range(3, MAXRANK + 1)
1340+
!> N-D array with optional `dim` specifier
1341+
module function matrix_norm_${rank}$D_to_${rank-2}$D_${ii}$_${ri}$(a, order, dim, err) result(nrm)
1342+
!> Input matrix a(m,n)
1343+
${rt}$, intent(in), contiguous, target :: a${ranksuffix(rank)}$
1344+
!> Norm of the matrix.
1345+
real(${rk}$), allocatable :: nrm${ranksuffix(rank-2)}$
1346+
!> Order of the matrix norm being computed.
1347+
${it}$, intent(in) :: order
1348+
!> [optional] dimensions of the sub-matrices the norms should be evaluated at (default = [1,2])
1349+
integer(ilp), optional, intent(in) :: dim(2)
1350+
!> [optional] state return flag. On error if not requested, the code will stop
1351+
type(linalg_state_type), intent(out), optional :: err
1352+
end function matrix_norm_${rank}$D_to_${rank-2}$D_${ii}$_${ri}$
1353+
#:endfor
1354+
#:endfor
1355+
#:endfor
1356+
end interface mnorm
1357+
13231358
contains
13241359

13251360

0 commit comments

Comments
 (0)