The IMSL_NORM function computes various norms of a vector or the difference of two vectors.
This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.
By default, IMSL_NORM computes the Euclidean norm as follows:
If the keyword One is set, then the 1-norm:
is returned. If the keyword INF is set, the infinity norm max|xi| is returned. In the case of the infinity norm, the index of the element with maximum modulus also is
returned.
If the parameter y is specified, the computations of the norms described above are performed on (x – y).
Examples
Example 1
In this example, the Euclidean norm of an input vector is computed.
x = [ 1.0, 3.0, -2.0, 4.0 ]
n = IMSL_NORM(x)
PM, n, Title = 'Euclidean norm of x:'
Euclidean norm of x:
5.47723
Example 2
This example computes max | xi– yi| and prints the norm and index.
x = [1.0, 3.0, -2.0, 4.0]
y = [4.0, 2.0, -1.0, -5.0]
n = IMSL_NORM(x, y, /Inf, Index_Max = imax)
PM, n, Title = 'Infinity norm of (x-y):'
PM, imax, Title = 'Element of (x-y) with maximum modulus:'
Infinity norm of (x-y):
9.00000
Element of (x-y) with maximum modulus:
3
Syntax
Result = IMSL_NORM(X [, Y] [, INDEX_MAX=variable] [, INF=value] [, ONE=value])
Return Value
The requested norm of the input vector. If the norm cannot be computed, NaN is returned.
Arguments
X
Vector for which the norm is to be computed.
Y
If present, IMSL_NORM computes the norm of (X – Y).
Keywords
INDEX_MAX (optional)
Named variable into which the index of the element of x with the maximum modulus is stored. If INDEX_MAX is used, then the keyword INF also must be used. If the argument Y is specified, then the index of (X – Y) with the maximum modulus is stored.
INF (optional)
If present and nonzero, computes the infinity norm max|xi|.
ONE (optional)
If present and nonzero, computes the 1-norm
Version History