net.java.dev.joode.util
Class Matrix

java.lang.Object
  extended by net.java.dev.joode.util.Real
      extended by net.java.dev.joode.util.Matrix
Direct Known Subclasses:
Matrix3, Matrix4

public class Matrix
extends Real

A common AxB Matrix The matrix will always be an identity matrix on instatiation.

Author:
Arne Mueller

Field Summary
 
Fields inherited from class net.java.dev.joode.util.Real
m
 
Constructor Summary
Matrix(int columns, int rows)
          creates a rows x cols Matrix
 
Method Summary
static Matrix aquireInstance(int columns, int rows)
          gets a pooled instance.
static boolean epsilonEquals(Matrix a, Matrix b, float e)
           
 float get(int column, int row)
           
 Real getColumn(int i)
           
 Real getColumn(int i, Real passback)
           
 int getColumns()
           
 void getRow(int i, Real v)
           
 int getRows()
           
 Matrix mul(Matrix C)
          Matrix Operation: A = B * C
 void mul(Matrix C, Matrix A)
          Matrix Operation: A = B * C
 Real mul(Real c)
          Matrix-Vector Operation: a = B * c
 Real mulInc(Real c, Real a)
          Matrix-Vector Operation: a += B * c
 Matrix mulTranspose(Matrix C)
          Matrix Operation: A = B * C'
 void mulTranspose(Matrix C, Matrix A)
          Matrix Operation: A = B * C'
static void releaseInstance(Matrix instance)
          returns a matrix into the object pool for a caller of aquireInstance.
 void set(int column, int row, float value)
           
 void setColumn(int i, Real v)
           
 void setIdentity()
           
 void setRow(int i, Real v)
           
static boolean solve(Matrix A, Real b, Real passback)
          performs gaussian elimination with parial pivoting.
 java.lang.String toString()
           
 void transpose()
          transposes this matrix in place (garbageless)
 void transposeMul(Matrix C, Matrix A)
          Matrix Operation: A = B' * C
 Real transposeMul(Real c)
          Matrix-Vector Operation: a = B' * c Note that the transpose of an orthanormal matrix, such as a rotation matrix, is the inverse matrix
 Real transposeMul(Real c, Real a)
          Matrix-Vector Operation: a += B' * c Note that the transpose of an orthanormal matrix, such as a rotation matrix, is the inverse matrix
 
Methods inherited from class net.java.dev.joode.util.Real
add, aquireDirtyInstance, aquireInstance, dot, dot, epsilonEquals, epsilonEquals, fill, get, length, lengthSquared, max, min, norm, normalize, releaseInstance, scale, set, set, setZero, size, sub
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Matrix

public Matrix(int columns,
              int rows)
creates a rows x cols Matrix

Method Detail

aquireInstance

public static Matrix aquireInstance(int columns,
                                    int rows)
gets a pooled instance. Return the object with releaseInstance. Matrix is initialized to identity

Parameters:
columns -
rows -
Returns:

releaseInstance

public static void releaseInstance(Matrix instance)
returns a matrix into the object pool for a caller of aquireInstance.


getColumns

public int getColumns()

getRows

public int getRows()

get

public float get(int column,
                 int row)

set

public void set(int column,
                int row,
                float value)

getColumn

public Real getColumn(int i)

getColumn

public Real getColumn(int i,
                      Real passback)

setColumn

public void setColumn(int i,
                      Real v)

getRow

public void getRow(int i,
                   Real v)

setRow

public void setRow(int i,
                   Real v)

setIdentity

public void setIdentity()

mul

public Real mul(Real c)
Matrix-Vector Operation: a = B * c

Parameters:
c - Vector c
Returns:
Vector a grabage creating!

mulInc

public Real mulInc(Real c,
                   Real a)
Matrix-Vector Operation: a += B * c

Parameters:
c - Vector c
a - Vector a, contains the result

transposeMul

public Real transposeMul(Real c)
Matrix-Vector Operation: a = B' * c Note that the transpose of an orthanormal matrix, such as a rotation matrix, is the inverse matrix

Parameters:
c - Vector c
Returns:
Vector a

transposeMul

public Real transposeMul(Real c,
                         Real a)
Matrix-Vector Operation: a += B' * c Note that the transpose of an orthanormal matrix, such as a rotation matrix, is the inverse matrix

Parameters:
c - Vector c
a - Vector a, contains result

transpose

public void transpose()
transposes this matrix in place (garbageless)


mul

public Matrix mul(Matrix C)
Matrix Operation: A = B * C

Parameters:
C - Matrix C
Returns:
Matrix A

mul

public void mul(Matrix C,
                Matrix A)
Matrix Operation: A = B * C

Parameters:
C - Matrix C
A - Matrix A, contains the result

mulTranspose

public Matrix mulTranspose(Matrix C)
Matrix Operation: A = B * C'

Parameters:
C - Matrix C
Returns:
Matrix A

mulTranspose

public void mulTranspose(Matrix C,
                         Matrix A)
Matrix Operation: A = B * C'

Parameters:
C - Matrix C
A - Matrix A, contains the result

transposeMul

public void transposeMul(Matrix C,
                         Matrix A)
Matrix Operation: A = B' * C

Parameters:
C - Matrix C
A - Matrix A, contains the result

epsilonEquals

public static boolean epsilonEquals(Matrix a,
                                    Matrix b,
                                    float e)

toString

public java.lang.String toString()
Overrides:
toString in class Real

solve

public static boolean solve(Matrix A,
                            Real b,
                            Real passback)
performs gaussian elimination with parial pivoting. Input matrix must be a square matrix, input RHS must be a vector of the same size. the passback bust be the size of the matrix. Each equation should be encoded as a row of the matrix eg 2x + 3y = 7 5x - 3y = 8 [2, 3 5,-3] = [7,8]' [cooeffecients] = [rhs] the result, passback, will contain instanciationsof the unkowns that satisfy the equations or if degenerate, the method will return false DO NOT USE WITH Vector3 and Matrix3 becuase their sizes are inconsistent

Returns: