Vector norm: subroutine interface version: experimental
Computes the vector norm of a generic-rank array . (Specification)
Subroutine interface that returns one of several scalar norm metrics of a real
or complex
input array , that can have any rank. For generic rank-n arrays, the scalar norm over
the whole array is returned by default. If n>=2
and the optional input dimension dim
is
specified, a rank n-1
array is returned with dimension dim
collapsed, containing all 1D
array norms evaluated along dimension dim
only.
This pure subroutine
interface provides methods for computing the vector norm(s) of an array.
Supported data types include real
and complex
.
Input arrays may have generic rank from 1 to 3.
Norm type input is mandatory, and it is provided via the order
argument.
This can be provided as either an integer
value or a character
string.
Allowed metrics are:
- 1-norm : order
= 1 or '1'
- Euclidean norm : order
= 2 or '2'
- p-norm : integer
order
, order>=3
- Infinity norm : order = huge(0) or 'inf'
- Minus-infinity norm : order = -huge(0) or '-inf'
real(sp) :: a(3,3), na, rown(3)
type(linalg_state_type) :: err
a = reshape([1, 2, 3, 4, 5, 6, 7, 8, 9], [3, 3])
! L2 norm: whole matrix
call get_norm(a, na, 2)
! Infinity norms of each row, with error control
call get_norm(a, rown, 'inf', dim=2, err=err)
Scalar norms: complex(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: real(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: real(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: complex(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: complex(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: real(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: real(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Scalar norms: complex(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:) |
Input 1-d matrix a(:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:,:) |
Input 2-d matrix a(:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: complex(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: real(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: real(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: complex(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: complex(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: real(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: real(sp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Array norms: complex(dp)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in) | :: | a(:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=sp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in), | target | :: | a(:,:,:) |
Input 3-d matrix a(:,:,:) |
|
real(kind=dp), | intent(out) | :: | nrm |
Norm of the matrix. |
||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
character(len=*), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=sp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=sp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=sp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
complex(kind=dp), | intent(in) | :: | a(:,:,:) |
Input matrix a[..] |
||
real(kind=dp), | intent(out) | :: | nrm(merge(size(a,1),size(a,2),mask=1
|
Norm of the matrix. (Same shape as | ||
integer(kind=ilp), | intent(in) | :: | order |
Order of the matrix norm being computed. |
||
integer(kind=ilp), | intent(in) | :: | dim |
Dimension the norm is computed along |
||
type(linalg_state_type), | intent(out), | optional | :: | err |
[optional] state return flag. On error if not requested, the code will stop |