# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.linearsystem

## Class Kernel

• java.lang.Object
• com.numericalmethod.suanshu.algebra.linear.matrix.doubles.linearsystem.Kernel

• public class Kernel
extends 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. Also, 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. The rank-nullity theorem says that the rank of A + the dimension of the kernel of A = the number of columns in A.

The kernel is the solution of a system of homogeneous linear equations. With the transformation matrix T, which turns A into the reduced row echelon form, it can solve also 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.
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  Kernel.Method
These are the available methods to compute kernel basis.
• ### Constructor Summary

Constructors
Constructor and Description
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

All Methods
Modifier and Type Method and Description
List<Vector> basis()
Get the kernel basis.
Map<Integer,Vector> basisAndFreeVars()
Get the kernel basis and the associated free variables for each basis/column.
boolean isZero()
Check if the kernel has zero dimension, that is, if A has full rank.
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.
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
• ### Constructor Detail

• #### Kernel

public Kernel(Matrix A,
Kernel.Method method,
double epsilon)
Construct the kernel of a matrix.
Parameters:
A - a matrix
method - the kernel computation method
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.
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 or rows in A.
Returns:
the rank
• #### basisAndFreeVars

public Map<Integer,Vector> basisAndFreeVars()
Get the kernel basis 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. For 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 map of indices and kernel basis vectors
Wikipedia: Basis
• #### basis

public List<Vector> basis()
Get the kernel basis.
Returns:
the kernel basis
• #### isZero

public boolean isZero()
Check if the kernel has zero dimension, that is, if A has full rank.
Returns:
true if 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 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