Skip to content

Commit 48de116

Browse files
committed
add specs
1 parent d4d1e85 commit 48de116

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

doc/specs/stdlib_linalg.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,4 +1565,52 @@ If `err` is not present, exceptions trigger an `error stop`.
15651565
{!example/linalg/example_norm.f90!}
15661566
```
15671567

1568+
## `mnorm` - Computes the matrix norm of a generic-rank array.
1569+
1570+
### Status
1571+
1572+
Experimental
1573+
1574+
### Description
1575+
1576+
This function computes one of several matrix norms of `real` or `complex` array \( A \), depending on
1577+
the value of the `order` input argument. \( A \) must be an array of rank 2 or higher. For arrays of rank > 2,
1578+
matrix norms are computed over specified dimensions.
1579+
1580+
### Syntax
1581+
1582+
`x = ` [[stdlib_linalg(module):mnorm(interface)]] `(a, order [, dim, err])`
1583+
1584+
### Arguments
1585+
1586+
`a`: Shall be a rank-n `real` or `complex` array containing the data, where n ³ 2. It is an `intent(in)` argument.
1587+
1588+
`order`: Shall be an `integer` value or a `character` flag that specifies the norm type, as follows. It is an `intent(in)` argument.
1589+
1590+
| Integer input | Character Input | Norm type |
1591+
|------------------|---------------------------|---------------------------------------------------------|
1592+
| `1` | `'1'` | 1-norm (maximum column sum) \( \max_j \sum_i{ \left|a_{i,j}\right| } \) |
1593+
| `2` | `'2','Euclidean'` | 2-norm/Euclidean/Frobenius norm \( \sqrt{\sum_{i,j}{ \left|a_{i,j}\right|^2 }} \) |
1594+
| `huge(0)` | `'inf', 'Inf', 'INF'` | Infinity norm (maximum row sum) \( \max_i \sum_j{ \left|a_{i,j}\right| } \) |
1595+
1596+
`dim` (optional): For arrays of rank > 2, shall be an integer array of size 2 specifying the dimensions over which to compute the matrix norm. Default value is `[1,2]`. It is an `intent(in)` argument.
1597+
1598+
`err` (optional): Shall be a `type(linalg_state_type)` value. This is an `intent(out)` argument.
1599+
1600+
### Return value
1601+
1602+
For rank-2 input arrays, the return value `x` is a scalar containing the matrix norm.
1603+
For arrays of rank > 2, if the optional `dim` argument is present, `x` is a rank `n-2` array with the same shape as \( A \) except
1604+
for dimensions `dim(1)` and `dim(2)`, which are dropped. Each element of `x` contains the matrix norm of the corresponding submatrix of \( A \),
1605+
evaluated over the specified dimensions only, with the given order.
1606+
1607+
If an invalid norm type is provided, defaults to 1-norm and raises `LINALG_ERROR`.
1608+
Raises `LINALG_VALUE_ERROR` if any of the arguments has an invalid size.
1609+
If `err` is not present, exceptions trigger an `error stop`.
1610+
1611+
### Example
1612+
1613+
```fortran
1614+
{!example/linalg/example_mnorm.f90!}
1615+
```
15681616

0 commit comments

Comments
 (0)