vec_math
Class QuadMatrix

java.lang.Object
  extended by vec_math.Matrix
      extended by vec_math.QuadMatrix
All Implemented Interfaces:
Cloneable

public class QuadMatrix
extends Matrix

Extension to the NxM matrix functions Matrix. Rootines to perform matrix inversion and determinant calculation are included via means of LU decomposition. Via the routine LUdecomp() the actual matrix is destroyed and its decomposition is stored in place of the original matrix. The flag LUdecomposed is set to notify routines like getDeterminant() and getInverse() that LU has already been performed. Further extensions may use the LU for linear equ. solving. (Lit. "Num. Rec." p34ff)


Nested Class Summary
static class QuadMatrix.Test
          Testing.
 
Nested classes/interfaces inherited from class vec_math.Matrix
Matrix.CloneTest
 
Field Summary
protected  boolean decomposed
          True if this matrix is already LU-decomposed.
protected  int[] exchange
          Record the exchanged rows during LU decomposition.
protected  double sign
          Sign of pivot element.
private  boolean singular
          Gets true if this matrix is singluar.
 
Fields inherited from class vec_math.Matrix
colValid, rowValid
 
Constructor Summary
QuadMatrix(int n)
           
QuadMatrix(Matrix mat)
           
 
Method Summary
 double getDeterminant()
          Returns the determinant of the actual Matrix.
static double getDeterminant(QuadMatrix invert)
          Returns the determinant of the actual Matrix.
 QuadMatrix getInverse()
          Inverts the current matrix via luDecomposition.
static QuadMatrix getInverse(QuadMatrix invert)
          The static version of matrix inversion.
static QuadMatrix getUnitMatrix(int n)
          Returns a unit matrix of range nxn.
 boolean isSingular()
          Returns true if this matrix is singluar.
protected  double luDecomp()
          Performs an LU decomposition of the matrix, with the diagonals of the L matrix set to 1 and therfore not stored.
protected  double[] luSubst(double[] solve)
          The substitution routine to the luDecomposition.
static VectorG solve(QuadMatrix q, VectorG rhs)
          Solves the system of linear equations represented by this quadmatrix for the system
 VectorG solve(VectorG rhs)
          Solves the system of linear equations represented by this quadmatrix for the system
 
Methods inherited from class vec_math.Matrix
clone, columns, equals, evalCol, evalRow, exchangeCol, exchangeRow, getColumn, getElement, getRawColumn, getRawRow, getRow, mult, mult, multOneCol, multOneRow, rows, setCols, setElement, setOneCol, setOneRow, setRows, toString, transpose
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

singular

private boolean singular
Gets true if this matrix is singluar.


decomposed

protected boolean decomposed
True if this matrix is already LU-decomposed.


exchange

protected int[] exchange
Record the exchanged rows during LU decomposition.


sign

protected double sign
Sign of pivot element.

Constructor Detail

QuadMatrix

public QuadMatrix(int n)

QuadMatrix

public QuadMatrix(Matrix mat)
Method Detail

getUnitMatrix

public static QuadMatrix getUnitMatrix(int n)
Returns a unit matrix of range nxn.


luDecomp

protected double luDecomp()
Performs an LU decomposition of the matrix, with the diagonals of the L matrix set to 1 and therfore not stored. The original matrix is destroyed and replaced by its LU-decomposition! Non-trivial elements of the L matrix occupier the lower left corner of this, U is located in the upper right region including the diagonal. Literature on LU decomposition can be found in Num. Rec." p34ff. If an even number of rows has been exchanged, this method returns 1., -1. otherwise. If the matrix is invalid or singular, 0. is returned. In the former case, isSingular is set. The row permutations are tracked in exchange[].


isSingular

public boolean isSingular()
Returns true if this matrix is singluar. Note that this is only recognized during LU-decomposition.


luSubst

protected double[] luSubst(double[] solve)
The substitution routine to the luDecomposition. The input array rhs could be addressed as the right-hand-side of a linear eqaution system. Returned by the routine is the solution of the equation system. The rhs is destroyed by the routine!


getInverse

public QuadMatrix getInverse()
Inverts the current matrix via luDecomposition. Warning: the row-like representation of the current matrix is destroyed!


solve

public VectorG solve(VectorG rhs)
Solves the system of linear equations represented by this quadmatrix for the system
       Q_ij*ret_j+rhs_i = 0,
       
where ret is the solution vector returned and rhs is the right-hand side supplied.

Returns:
Null if matrix is singular

solve

public static VectorG solve(QuadMatrix q,
                            VectorG rhs)
Solves the system of linear equations represented by this quadmatrix for the system
       Q_ij*ret_j+rhs_i = 0,
       
where ret is the solution vector returned and rhs is the right-hand side supplied.

Returns:
Null if matrix is singular

getInverse

public static QuadMatrix getInverse(QuadMatrix invert)
The static version of matrix inversion. Attention: the matrix invert is luDecomposed on return.


getDeterminant

public double getDeterminant()
Returns the determinant of the actual Matrix. This is the only routine that uses the variable sign.


getDeterminant

public static double getDeterminant(QuadMatrix invert)
Returns the determinant of the actual Matrix. This is the only routine that uses the variable sign.