SuanShu, a Java numerical and statistical library

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

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

public class Solver
extends java.lang.Object

Solve a system of linear equations in the form:

Ax = b,
where A has #rows <= #columns. That is, the system must not be over-determined.

This linear system is solved in two steps.

  1. We first solve Ax = 0 the homogeneous system for non trivial solutions.
  2. We then solve Ax = b for a particular solution.
If A is square and det(A) != 0, we use the LU decomposition.

Otherwise, we find the particular solution x = T %*% b.

The final solution is:

x_particular + {x_null_space_of_A}
hence, the translation of the null space of A by the vector x_particular.

See Also:

Nested Class Summary
static class Solver.NoSolution
          RuntimeException thrown when it fails to solve a system of linear equations.
 
Field Summary
 Matrix A
          matrix A as in Ax = b
 VectorList basis
          the basis of A; solution for the homogeneous part, Ax = 0
 double epsilon
          a precision parameter: when a number |x| ≤ ε, it is considered 0
 boolean isFullRank
          true iff A has full rank
 
Constructor Summary
Solver(Matrix A)
          Construct a Solver instance to solve for different Vector b.
Solver(Matrix A, double epsilon)
          Construct a Solver instance to solve for different Vector b.
 
Method Summary
 VectorList homogeneousSoln()
          Get the basis of the homogeneous solution for the linear system, Ax = b.
 Vector solve(Vector b)
          Get a particular solution for the linear system, Ax = b
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

A

public final Matrix A
matrix A as in Ax = b


isFullRank

public final boolean isFullRank
true iff A has full rank


basis

public final VectorList basis
the basis of A; solution for the homogeneous part, Ax = 0


epsilon

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

Constructor Detail

Solver

public Solver(Matrix A,
              double epsilon)
Construct a Solver instance to solve for different Vector b.

Parameters:
A - a matrix
epsilon - a precision parameter: when a number |x| ≤ ε, it is considered 0

Solver

public Solver(Matrix A)
Construct a Solver instance to solve for different Vector b.

Parameters:
A - a matrix
Method Detail

solve

public Vector solve(Vector b)
Get a particular solution for the linear system,
Ax = b

Parameters:
b - a vector
Returns:
a particular solution
Throws:
Solver.NoSolution - if there is no solution to this system

homogeneousSoln

public VectorList homogeneousSoln()
Get the basis of the homogeneous solution for the linear system, Ax = b. That is, the solutions for
Ax = 0

Returns:
the homogeneous solution

SuanShu, a Java numerical and statistical library

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