org.ejml.ops
Class NormOps

java.lang.Object
  extended by org.ejml.ops.NormOps

public class NormOps
extends Object

Norms are a measure of the size of a vector or a matrix. One typical application is in error analysis.

Vector norms have the following properties:

  1. ||x|| > 0 if x ≠ 0 and ||0|| = 0
  2. ||αx|| = |α| ||x||
  3. ||x+y|| ≤ ||x|| + ||y||

Matrix norms have the following properties:

  1. ||A|| > 0 if A ≠ 0 where A ∈ ℜ m × n
  2. || α A || = |α| ||A|| where A ∈ ℜ m × n
  3. ||A+B|| ≤ ||A|| + ||B|| where A and B are ∈ ℜ m × n
  4. ||AB|| ≤ ||A|| ||B|| where A and B are ∈ ℜ m × m
Note that the last item in the list only applies to square matrices.

Matrix norms can be induced from vector norms as is shown below:

||A||M = maxx≠0||Ax||v/||x||v

where ||.||M is the induced matrix norm for the vector norm ||.||v.

By default implementations that try to mitigate overflow/underflow are used. If the word fast is found before a function's name that means it does not mitigate those issues, but runs a bit faster.

Author:
Peter Abeles

Constructor Summary
NormOps()
           
 
Method Summary
static double conditionP(DenseMatrix64F A, double p)
           The condition number of a matrix is used to measure the sensitivity of the linear system Ax=b.
static double conditionP2(DenseMatrix64F A)
           The condition p = 2 number of a matrix is used to measure the sensitivity of the linear system Ax=b.
static double elementP(RowD1Matrix64F A, double p)
           Element wise p-norm:

norm = {∑i=1:mj=1:n { |aij|p}}1/p
static double fastElementP(D1Matrix64F A, double p)
          Same as elementP(org.ejml.data.RowD1Matrix64F, double) but runs faster by not mitigating overflow/underflow related problems.
static double fastNormF(D1Matrix64F a)
           This implementation of the Frobenius norm is a straight forward implementation and can be susceptible for overflow/underflow issues.
static double fastNormP(DenseMatrix64F A, double p)
          An unsafe but faster version of normP(org.ejml.data.DenseMatrix64F, double) that calls routines which are faster but more prone to overflow/underflow problems.
static double fastNormP2(DenseMatrix64F A)
          Computes the p=2 norm.
static double inducedP1(DenseMatrix64F A)
           Computes the induced p = 1 matrix norm.

||A||1= max(j=1 to n; sum(i=1 to m; |aij|))
static double inducedP2(DenseMatrix64F A)
           Computes the induced p = 2 matrix norm, which is the largest singular value.
static double inducedPInf(DenseMatrix64F A)
           Induced matrix p = infinity norm.

||A|| = max(i=1 to m; sum(j=1 to n; |aij|))
static void normalizeF(DenseMatrix64F A)
          Normalizes the matrix such that the Frobenius norm is equal to one.
static double normF(D1Matrix64F a)
           Computes the Frobenius matrix norm:

normF = Sqrt{ ∑i=1:mj=1:n { aij2} }
static double normP(DenseMatrix64F A, double p)
          Computes either the vector p-norm or the induced matrix p-norm depending on A being a vector or a matrix respectively.
static double normP1(DenseMatrix64F A)
          Computes the p=1 norm.
static double normP2(DenseMatrix64F A)
          Computes the p=2 norm.
static double normPInf(DenseMatrix64F A)
          Computes the p=∞ norm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NormOps

public NormOps()
Method Detail

normalizeF

public static void normalizeF(DenseMatrix64F A)
Normalizes the matrix such that the Frobenius norm is equal to one.

Parameters:
A - The matrix that is to be normalized.

conditionP

public static double conditionP(DenseMatrix64F A,
                                double p)

The condition number of a matrix is used to measure the sensitivity of the linear system Ax=b. A value near one indicates that it is a well conditioned matrix.

κp = ||A||p||A-1||p

If the matrix is not square then the condition of either ATA or AAT is computed.

Parameters:
A - The matrix.
p - p-norm
Returns:
The condition number.

conditionP2

public static double conditionP2(DenseMatrix64F A)

The condition p = 2 number of a matrix is used to measure the sensitivity of the linear system Ax=b. A value near one indicates that it is a well conditioned matrix.

κ2 = ||A||2||A-1||2

This is also known as the spectral condition number.

Parameters:
A - The matrix.
Returns:
The condition number.

fastNormF

public static double fastNormF(D1Matrix64F a)

This implementation of the Frobenius norm is a straight forward implementation and can be susceptible for overflow/underflow issues. A more resilient implementation is normF(org.ejml.data.D1Matrix64F).

Parameters:
a - The matrix whose norm is computed. Not modified.

normF

public static double normF(D1Matrix64F a)

Computes the Frobenius matrix norm:

normF = Sqrt{ ∑i=1:mj=1:n { aij2} }

This is equivalent to the element wise p=2 norm. See fastNormF(org.ejml.data.D1Matrix64F) for another implementation that is faster, but more prone to underflow/overflow errors.

Parameters:
a - The matrix whose norm is computed. Not modified.
Returns:
The norm's value.

elementP

public static double elementP(RowD1Matrix64F A,
                              double p)

Element wise p-norm:

norm = {∑i=1:mj=1:n { |aij|p}}1/p

This is not the same as the induced p-norm used on matrices, but is the same as the vector p-norm.

Parameters:
A - Matrix. Not modified.
p - p value.
Returns:
The norm's value.

fastElementP

public static double fastElementP(D1Matrix64F A,
                                  double p)
Same as elementP(org.ejml.data.RowD1Matrix64F, double) but runs faster by not mitigating overflow/underflow related problems.

Parameters:
A - Matrix. Not modified.
p - p value.
Returns:
The norm's value.

normP

public static double normP(DenseMatrix64F A,
                           double p)
Computes either the vector p-norm or the induced matrix p-norm depending on A being a vector or a matrix respectively.

Parameters:
A - Vector or matrix whose norm is to be computed.
p - The p value of the p-norm.
Returns:
The computed norm.

fastNormP

public static double fastNormP(DenseMatrix64F A,
                               double p)
An unsafe but faster version of normP(org.ejml.data.DenseMatrix64F, double) that calls routines which are faster but more prone to overflow/underflow problems.

Parameters:
A - Vector or matrix whose norm is to be computed.
p - The p value of the p-norm.
Returns:
The computed norm.

normP1

public static double normP1(DenseMatrix64F A)
Computes the p=1 norm. If A is a matrix then the induced norm is computed.

Parameters:
A - Matrix or vector.
Returns:
The norm.

normP2

public static double normP2(DenseMatrix64F A)
Computes the p=2 norm. If A is a matrix then the induced norm is computed.

Parameters:
A - Matrix or vector.
Returns:
The norm.

fastNormP2

public static double fastNormP2(DenseMatrix64F A)
Computes the p=2 norm. If A is a matrix then the induced norm is computed. This implementation is faster, but more prone to buffer overflow or underflow problems.

Parameters:
A - Matrix or vector.
Returns:
The norm.

normPInf

public static double normPInf(DenseMatrix64F A)
Computes the p=∞ norm. If A is a matrix then the induced norm is computed.

Parameters:
A - Matrix or vector.
Returns:
The norm.

inducedP1

public static double inducedP1(DenseMatrix64F A)

Computes the induced p = 1 matrix norm.

||A||1= max(j=1 to n; sum(i=1 to m; |aij|))

Parameters:
A - Matrix. Not modified.
Returns:
The norm.

inducedP2

public static double inducedP2(DenseMatrix64F A)

Computes the induced p = 2 matrix norm, which is the largest singular value.

Parameters:
A - Matrix. Not modified.
Returns:
The norm.

inducedPInf

public static double inducedPInf(DenseMatrix64F A)

Induced matrix p = infinity norm.

||A|| = max(i=1 to m; sum(j=1 to n; |aij|))

Parameters:
A - A matrix.
Returns:
the norm.


Copyright © 2012. All Rights Reserved.