IMSL_MATRIX_NORM

Syntax | Return Value | Arguments | Keywords | Discussion | Examples | Version History

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 Advanced Math and Stats license. For more information, contact your ITT Visual Information Solutions sales or technical support representative.

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 codiagonals 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.

SYMMETRIC

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

Discussion

By default, IMSL_MATRIX_NORM computes the Frobenius norm:

IMSL_MATRIX_NORM-22.jpg

If the keyword One_Norm is used, the one norm

IMSL_MATRIX_NORM-23.jpg

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

IMSL_MATRIX_NORM-24.jpg

is returned.

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 

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