# IMSL_MATRIX_NORM

The IMSL_MATRIX_NORM function computes various norms of a rectangular matrix, a matrix stored in band format, and a matrix stored in coordinate format.

Note: This routine requires an IDL Analyst license. For more information, contact your Exelis VIS sales or technical support representative.

By default, IMSL_MATRIX_NORM computes the Frobenius norm:

If the keyword One_Norm is used, the one norm

is returned. If the keyword Inf_Norm is used, the infinity norm

is returned.

## Examples

For additional information on using IMSL_MATRIX_NORM, see Additional Examples.

### Example 1

Compute the Frobenius norm, infinity norm, and one norm of matrix A.

a = TRANSPOSE([[1.0, 2.0, -2.0, 3.0], $

[-2.0, 1.0, 3.0, 0.0], [0.0, 3.0, 1.0, -7.0], $

[5.0, -2.0, 7.0, 6.0], [4.0, 3.0, 4.0, 0.0]])

frobenius_norm = IMSL_MATRIX_NORM(a)

inf_norm = IMSL_MATRIX_NORM(a, /INF_NORM)

one_norm = IMSL_MATRIX_NORM(a, /ONE_NORM)

PRINT, 'Frobenius norm = ', frobenius_norm

PRINT, 'Infinity norm = ', inf_norm

PRINT, 'One norm = ', one_norm

Frobenius norm = 15.6844

Infinity norm = 20.0000

One norm = 17.0000

## Syntax

To compute various norms of a rectangular matrix:

Result = IMSL_MATRIX_NORM(a [, /DOUBLE] [, INF_NORM=value] [, ONE_NORM=value] [, SYMMETRIC=value])

To compute various norms of a matrix stored in band format:

Result = IMSL_MATRIX_NORM(n, nlca, nuca, a [, /DOUBLE] [, INF_NORM=value] [, ONE_NORM=value] [, SYMMETRIC=value])

To compute various norms of a matrix stored in coordinate format:

Result = IMSL_MATRIX_NORM(nrows, ncols, a [, /DOUBLE] [, INF_NORM=value] [, ONE_NORM=value] [, SYMMETRIC=value])

## Return Value

The requested norm of the input matrix, by default, the Frobenius norm. If the norm cannot be computed, NaN is returned.

## Arguments

### a

Matrix for which the norm will be computed.

### n

The order of matrix a.

### ncols

The number of columns in matrix a.

### nlca

Number of lower codiagonals of a.

### nrows

The number of rows in matrix a.

### nuca

Number of upper co-diagonals of a.

## Keywords

### DOUBLE

If present and nonzero, double precision is used.

### INF_NORM

If present and nonzero, IMSL_MATRIX_NORM computes the infinity norm of matrix a.

### ONE_NORM

If present and nonzero, IMSL_MATRIX_NORM computes the one norm of matrix a.

### SYMMETIC

If present and nonzero, matrix a is stored in symmetric storage mode. Keyword SYMMETRIC can not be used with a rectangular matrix.

## Additional Examples

### Example 2

Compute the Frobenius norm, infinity norm, and one norm of matrix a. Matrix a is stored in band storage mode.

nlca = 1

nuca = 1

n = 4

a = [0.0, 2.0, 3.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 3.0, 4.0, 0.0]

frobenius_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a)

inf_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a, /INF_NORM)

one_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a, /ONE_NORM)

PRINT, 'Frobenius norm = ', frobenius_norm

PRINT, 'Infinity norm = ', inf_norm

PRINT, 'One norm = ', one_norm

Frobenius norm = 6.55744

Infinity norm = 5.00000

One norm = 8.00000

### Example 3

Compute the Frobenius norm, infinity norm, and one norm of matrix a. Matrix a is stored in symmetric band storage mode.

nlca = 2

nuca = 2

n = 6

a = [0.0, 0.0, 7.0, 3.0, 1.0, 4.0, $

0.0, 5.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 4.0, 6.0, 3.0, 1.0]

frobenius_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a, /SYMMETRIC)

inf_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a, /INF_NORM, $

/SYMMETRIC)

one_norm = IMSL_MATRIX_NORM(n, nlca, nuca, a, /ONE_NORM, $

/SYMMETRIC)

PRINT, 'Frobenius norm = ', frobenius_norm

PRINT, 'Infinity norm = ', inf_norm

PRINT, 'One norm = ', one_norm

Frobenius norm = 16.9411

Infinity norm = 16.0000

One norm = 16.0000

### Example 4

Compute the Frobenius norm, infinity norm, and one norm of matrix a. Matrix a is stored in coordinate format.

nrows = 6

ncols = 6

a = REPLICATE(imsl_f_sp_elem, 15)

a(*).row = [0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5]

a(*).col = [0, 1, 2, 3, 2, 0, 3, 4, 0, 3, 4, 5, 0, 1, 5]

a(*).val = [10.0, 10.0, -3.0, -1.0, 15.0, $

-2.0, 10.0, -1.0, -1.0, -5.0, 1.0, -3.0, -1.0, -2.0, 6.0]

frobenius_norm = IMSL_MATRIX_NORM(nrows, ncols, a)

inf_norm = IMSL_MATRIX_NORM(nrows, ncols, a, /INF_NORM)

one_norm = IMSL_MATRIX_NORM(nrows, ncols, a, /ONE_NORM)

PRINT, 'Frobenius norm = ', frobenius_norm

PRINT, 'Infinity norm = ', inf_norm

PRINT, 'One norm = ', one_norm

Frobenius norm = 24.8395

Infinity norm = 15.0000

One norm = 18.0000

### Example 5

Compute the Frobenius norm, infinity norm and one norm of matrix a. Matrix a is stored in symmetric coordinate format.

nrows = 6

ncols = 6

a = REPLICATE(imsl_f_sp_elem, 9)

a(*).row = [0, 0, 0, 1, 1, 2, 2, 4, 4]

a(*).col = [0, 2, 5, 3, 4, 2, 5, 4, 5]

a(*).val = [10.0, -1.0, 5.0, 2.0, 3.0, 3.0, 4.0, -1.0, 4.0]

frobenius_norm = IMSL_MATRIX_NORM(nrows, ncols, a, /SYMMETRIC)

inf_norm = IMSL_MATRIX_NORM(nrows, ncols, a, /INF_NORM, $

/SYMMETRIC)

one_norm = IMSL_MATRIX_NORM(nrows, ncols, a, /ONE_NORM, $

/SYMMETRIC)

PRINT, 'Frobenius norm = ', frobenius_norm

PRINT, 'Infinity norm = ', inf_norm

PRINT, 'One norm = ', one_norm

Frobenius norm = 15.8745

Infinity norm = 16.0000

One norm = 16.0000

## Version History

6.4 | Introduced

## See Also