SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.linearsystem
Class Kernel

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.linearsystem.Kernel

public class Kernel
extends java.lang.Object

The kernel or null space (also nullspace) of a matrix A is the set of all vectors x for which

Ax = 0
The kernel of a matrix with n columns is a linear subspace of n-dimensional Euclidean space.

The kernel of a matrix A is exactly the same as the kernel of the linear mapping defined by the matrix-vector multiplication,

x → Ax
That is, the set of vectors that map to the zero vector.

By the rank-nullity theorem,

rank of A + dimension of the kernel of A = number of columns in A

This class can be used to solve a system of homogeneous linear equations.

Also, with the transformation matrix T, which turns A into the reduced row echelon form, we can solve a system of non-homogeneous linear equations. Specifically, to find a particular solution for a non-homogeneous system of linear equations with a matrix A, i.e.,

Ax = b
we solve
T %*% A == U
and then
x = T %*% b
where x is a particular solution.

See Also:

Nested Class Summary
static class Kernel.Method
          the methods available to do the LU decomposition
 
Field Summary
 double epsilon
          a precision parameter: when a number |x| ≤ ε, it is considered 0
 Kernel.Method method
          the method to perform the LU decomposition
 int ncols
          number of columns
 int nrows
          number of rows
 
Constructor Summary
Kernel(Matrix A)
          Construct the kernel of a matrix.
Kernel(Matrix A, Kernel.Method method, double epsilon)
          Construct the kernel of a matrix.
 
Method Summary
 VectorList basis()
          Get a copy of the basis of the kernel.
 java.util.Map<java.lang.Integer,Vector> basisAndFreeVars()
          Get a copy of the basis of the kernel and the associated free variables for each basis/column.
 boolean isZero()
          Check if the kernel is of zero-dimension.
 int nullity()
          Get the nullity of A.
 int rank()
          Get the rank of A.
 Matrix T()
          Get the transformation matrix, T, such that T %*% A == U To find a particular solution for a non-homogeneous system of linear equations with the same A, i.e., Ax = b we do x = T %*% b where x is a particular solution.
 Matrix U()
          Get the upper triangular matrix U, such that T %*% A == U
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nrows

public final int nrows
number of rows


ncols

public final int ncols
number of columns


method

public final Kernel.Method method
the method to perform the LU decomposition


epsilon

public final double epsilon
a precision parameter: when a number |x| ≤ ε, it is considered 0

Constructor Detail

Kernel

public Kernel(Matrix A,
              Kernel.Method method,
              double epsilon)
Construct the kernel of a matrix.

We compute the basis vectors for the kernel. That is, we compute T and U such that

T %*% A == U

While the kernel basis is computed using one of the implementations in Kernel.Method, the matrices T and U are always computed using Gauss-Jordan elimination.

Parameters:
A - a matrix
method - the method to compute the orthogonal complement of A
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0; the ε is used to determine the numerical rank of the linear space

Kernel

public Kernel(Matrix A)
Construct the kernel of a matrix.

We compute the basis vectors for the kernel. That is, we compute T and U such that

T %*% A == U

While the kernel basis is computed using one of the implementations in Kernel.Method, the matrices T and U are always computed using Gauss-Jordan elimination.

Parameters:
A - a matrix
Method Detail

nullity

public int nullity()
Get the nullity of A. That is, the dimension of the kernel.

Returns:
the nullity

rank

public int rank()
Get the rank of A. That is, the number of linearly independent columns in A.

Returns:
the rank

basisAndFreeVars

public java.util.Map<java.lang.Integer,Vector> basisAndFreeVars()
Get a copy of the basis of the kernel and the associated free variables for each basis/column.

This method is only meaningful when the kernel is computed using Kernel.Method.GAUSSIAN_JORDAN_ELIMINATION. Using this process, a free variable corresponds to an entry '1' in a column.

E.g., in the example in Wikipedia, x3 (the 3rd variable) is a free variable, and it corresponds to [3,-5,1,0,0,0]t.

If the kernel basis is computed using a different method, call basis instead.

Returns:
a copy of the map of indices and basis vectors for the kernel
See Also:
Wikipedia: Basis

basis

public VectorList basis()
Get a copy of the basis of the kernel.

Returns:
a copy of the list of basis of the kernel

isZero

public boolean isZero()
Check if the kernel is of zero-dimension. That is, if A has full rank.

Returns:
true iff the kernel is null

T

public Matrix T()
Get the transformation matrix, T, such that
T %*% A == U

To find a particular solution for a non-homogeneous system of linear equations with the same A, i.e.,

Ax = b
we do
x = T %*% b
where x is a particular solution.

Returns:
the transformation matrix T

U

public Matrix U()
Get the upper triangular matrix U, such that
T %*% A == U

Returns:
the U matrix

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.