MATRIX_NORM Function

Computes various norms of a rectangular matrix, a matrix stored in band format, and a matrix stored in coordinate format.

Usage

Computes various norms of a rectangular matrix.

result = MATRIX_NORM(a)

Computes various norms of a matrix stored in band format.

result = MATRIX_NORM(n, nlca, nuca, a)

Computes various norms of a matrix stored in coordinate format.

result = MATRIX_NORM(nrows, ncols, a)

Input Parameters

a—Matrix for which the norm will be computed.

n—The order of matrix A.

nlca—Number of lower codiagonals of A.

nuca—Number of upper codiagonals of A.

nrows—The number of rows in matrix A.

ncols—The number of columns in matrix A.

Returned Value

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

Input Keywords

Double—If present and nonzero, double precision is used.

One_Norm—If present and nonzero, function MATRIX_NORM computes the one norm of matrix A.

Inf_Norm—If present and nonzero, function MATRIX_NORM computes the infinity 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, 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.

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  =  MATRIX_NORM(a)
inf_norm  =  MATRIX_NORM(a, /Inf_Norm)
one_norm  =  MATRIX_NORM(a, /One_Norm)
PRINT, 'Frobenius norm = ', frobenius_norm
PRINT, 'Infinity norm  = ', inf_norm
PRINT, 'One norm       = ', one_norm
; PV-WAVE prints: Frobenius norm =       15.6844
; PV-WAVE prints: Infinity norm  =       20.0000
; PV-WAVE prints: 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  =  MATRIX_NORM(n, nlca, nuca, a)
inf_norm  =  MATRIX_NORM(n, nlca, nuca, a, /Inf_Norm)
one_norm  =  MATRIX_NORM(n, nlca, nuca, a, /One_Norm)
PRINT, 'Frobenius norm = ', frobenius_norm
PRINT, 'Infinity norm  = ', inf_norm
PRINT, 'One norm       = ', one_norm
; PV-WAVE prints: Frobenius norm =       6.55744
; PV-WAVE prints: Infinity norm  =       5.00000
; PV-WAVE prints: 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  =  MATRIX_NORM(n, nlca, nuca, a, /Symmetric)
inf_norm  =  MATRIX_NORM(n, nlca, nuca, a, /Inf_Norm, /Symmetric)
one_norm  =  MATRIX_NORM(n, nlca, nuca, a, /One_Norm, /Symmetric)
PRINT, 'Frobenius norm = ', frobenius_norm
PRINT, 'Infinity norm  = ', inf_norm
PRINT, 'One norm       = ', one_norm
; PV-WAVE prints: Frobenius norm =       16.9411
; PV-WAVE prints: Infinity norm  =       16.0000
; PV-WAVE prints: 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(!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  =  MATRIX_NORM(nrows, ncols, a)
inf_norm  =  MATRIX_NORM(nrows, ncols, a, /Inf_Norm)
one_norm  =  MATRIX_NORM(nrows, ncols, a, /One_Norm)
PRINT, 'Frobenius norm = ', frobenius_norm
PRINT, 'Infinity norm  = ', inf_norm
PRINT, 'One norm       = ', one_norm
; PV-WAVE prints: Frobenius norm =       24.8395
; PV-WAVE prints: Infinity norm  =       15.0000
; PV-WAVE prints: 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(!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  =  MATRIX_NORM(nrows, ncols, a, /Symmetric)
inf_norm  =  MATRIX_NORM(nrows, ncols, a, /Inf_Norm, /Symmetric)
one_norm  =  MATRIX_NORM(nrows, ncols, a, /One_Norm, /Symmetric)
PRINT, 'Frobenius norm = ', frobenius_norm
PRINT, 'Infinity norm  = ', inf_norm
PRINT, 'One norm       = ', one_norm
; PV-WAVE prints: Frobenius norm =       15.8745
; PV-WAVE prints: Infinity norm  =       16.0000
; PV-WAVE prints: One norm       =       16.0000