hmi.math
Class Mat

java.lang.Object
  extended by hmi.math.Mat

public final class Mat
extends Object

Generic Matrix algorithmns

Author:
Herwin van Welbergen, Job Zwiers

Constructor Summary
private Mat()
           
 
Method Summary
static float[] getInvertedPermutationMatrix(int[] p)
          Assuming that p is a length m array containg a permutation of 0..m-1, this method returns a corresponding m X m inverse permutation matrix for permuting matrix rows.
static void getLUfactors(float[] matrix, int m, int[] p, float[] L, float[] U)
          Extracts the L and U factors from m X m matrix "matrix", using the permutation p.
static float[] getPermutationMatrix(int[] p)
          Assuming that p is a length m array containg a permutation of 0..m-1, this method returns a corresponding m X m permutation matrix for permuting matrix rows.
static void invertMatrix(float[] A, int n, float[] Ainv)
           
static int[] invertPermutation(int[] p)
          Inverts a permutation
static boolean LUDecompose(float[] matrix, int m, int n, int[] p)
          Calculates a LU decomposition of matrix m, and stores the result back in m.
static void mul(float[] dst, float[] a, int an, float[] b, int bn)
          dst = A * B.
static float[] permute(int[] p, float[] b)
          permutes vector b, according to permutation p
static void set(float[] dest, float[] src, int m, int n)
          Copies an m X n array from src to dest
static float[] solveLUSystem(float[] LU, int[] p, float[] b)
          Solves the matrix equation A x = b, assuming that LU is an LU decomposition of P*A , where P is the permutation matrix corresponding to p, and obtained during partial pivoting for the LU decomposition.
static void tridiagonalSolve(float[] a, float[] b, float[] c, float[] d, float[] x)
          Solves Ax=d, with A the tridiagonal matrix b1 c1 .. 0 a2 b2 c2 .. 0 0 a3 b3 c3 .. 0 .. 0 ..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mat

private Mat()
Method Detail

LUDecompose

public static boolean LUDecompose(float[] matrix,
                                  int m,
                                  int n,
                                  int[] p)
Calculates a LU decomposition of matrix m, and stores the result back in m. The int[] p receives the permutations, due to partial pivoting. The boolean result denotes whether the matrix is non-singular.


solveLUSystem

public static float[] solveLUSystem(float[] LU,
                                    int[] p,
                                    float[] b)
Solves the matrix equation A x = b, assuming that LU is an LU decomposition of P*A , where P is the permutation matrix corresponding to p, and obtained during partial pivoting for the LU decomposition. with L containing 1 at the main diagonal (Doolittle's factorization)


invertMatrix

public static void invertMatrix(float[] A,
                                int n,
                                float[] Ainv)

set

public static void set(float[] dest,
                       float[] src,
                       int m,
                       int n)
Copies an m X n array from src to dest


getLUfactors

public static void getLUfactors(float[] matrix,
                                int m,
                                int[] p,
                                float[] L,
                                float[] U)
Extracts the L and U factors from m X m matrix "matrix", using the permutation p.


invertPermutation

public static int[] invertPermutation(int[] p)
Inverts a permutation


getPermutationMatrix

public static float[] getPermutationMatrix(int[] p)
Assuming that p is a length m array containg a permutation of 0..m-1, this method returns a corresponding m X m permutation matrix for permuting matrix rows.


getInvertedPermutationMatrix

public static float[] getInvertedPermutationMatrix(int[] p)
Assuming that p is a length m array containg a permutation of 0..m-1, this method returns a corresponding m X m inverse permutation matrix for permuting matrix rows.


permute

public static float[] permute(int[] p,
                              float[] b)
permutes vector b, according to permutation p


tridiagonalSolve

public static void tridiagonalSolve(float[] a,
                                    float[] b,
                                    float[] c,
                                    float[] d,
                                    float[] x)
Solves Ax=d, with A the tridiagonal matrix b1 c1 .. 0 a2 b2 c2 .. 0 0 a3 b3 c3 .. 0 .. 0 .. an bn or alternatively written: ai*xi-1 + bi*xi + ci*xi+1 = di, a1=0, c1=0 Puts new values in c and d Implementation from http://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm


mul

public static void mul(float[] dst,
                       float[] a,
                       int an,
                       float[] b,
                       int bn)
dst = A * B.
dst cannot be aliased with A or B.
A: an x A.length/an matrix.
B: bn x B.length/bn matrix.
Encoded in the same way as matrices used in Mat3f, Mat4f:
A_ij = A[i*an+j]