UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.gesture.util
Class Matrix

java.lang.Object
  |
  +--edu.berkeley.guir.lib.gesture.util.Matrix

public class Matrix
extends Object


Field Summary
static int sigFigs
           
static int width
           
 
Method Summary
static double[][] add(double[][] arg1, double[][] arg2)
          Add two matrices.
static double[][] add(double[][] arg1, double[][] arg2, double[][] result)
          Add two Matrices.
static double[] add(double[] v1, double[] v2)
           
static int bitcount(BitSet mask)
           
static double[][] clone(double[][] src)
           
static double[][] deSlice(double[][] m, double fill, BitSet rowMask, BitSet colMask, double[][] r)
          Only works on rectangular matrices.
static double dotMultiply(double[][] arg1, double[][] arg2)
          Dot Multiply matrix by another matrix.
static double dotMultiply(double[] v1, double[] v2)
           
static void fill(double[][] m, double fill)
           
static double[][] invert(double[][] arg)
          Invert a matrix.
static double[][] luBackSubstitute(double[][] a, double[][] b, int[] indx)
          Do the backsubstitution on matrix a which is the LU decomposition of the original matrix.
static double[][] luDecompose(double[][] matrix, int[] indx, boolean parity)
          luDecomposition performs LU Decomposition on a matrix.
static void main(String[] args)
          Test routine
static double[][] multiply(double[][] arg1, double[][] arg2)
          Multiply two matrices.
static double[][] multiply(double[][] arg1, double[][] arg2, double[][] result)
          Multiply two matrices.
static double[] multiply(double factor, double[] v)
           
static double[][] multiply(double arg1, double[][] arg2)
          Multiply matrix by a constant.
static double[][] multiply(double arg1, double[][] arg2, double[][] result)
          Multiply a matrix by a constant.
static double myInvert(double[][] ym, double[][] rm)
          A new invert routine taken directly from Amulet's gest_matrix.cc (where it's called InvertMatrix).
static void prettyPrint(double[] vector)
           
static void prettyPrint(double[][] matrix)
          Print a matrix to standard output.
static void prettyPrint(Double[][] matrix)
           
static void print(double[][] matrix)
          Print a matrix to standard output.
static double QuadraticForm(double[] v, double[][] m)
           
static double[][] safeInvert(double[][] m)
           
static double[][] slice(double[][] m, BitSet rowMask, BitSet colMask)
           
static double[][] solve(double[][] a, double[][] b)
          Solve a set of linear equations.
static double[][] subtract(double[][] arg1, double[][] arg2)
          Subtract two matrices.
static double[][] subtract(double[][] arg1, double[][] arg2, double[][] result)
          Subract two Matrices.
static double[] subtract(double[] v1, double[] v2)
           
static double[][] transpose(double[][] matrix, boolean inPlace)
          Transpose a matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sigFigs

public static int sigFigs

width

public static int width
Method Detail

prettyPrint

public static void prettyPrint(double[][] matrix)
Print a matrix to standard output. (pretty)

prettyPrint

public static void prettyPrint(Double[][] matrix)

prettyPrint

public static void prettyPrint(double[] vector)

print

public static void print(double[][] matrix)
Print a matrix to standard output.

transpose

public static double[][] transpose(double[][] matrix,
                                   boolean inPlace)
Transpose a matrix. Returns a new matrix if unless inPlace is true; Otherwise, replaces a square matrix with a transpose of itself.

add

public static double[][] add(double[][] arg1,
                             double[][] arg2,
                             double[][] result)
Add two Matrices. Put result in given Matrix.

add

public static double[][] add(double[][] arg1,
                             double[][] arg2)
Add two matrices. Put result in new matrix.

subtract

public static double[][] subtract(double[][] arg1,
                                  double[][] arg2,
                                  double[][] result)
Subract two Matrices. Put result in given Matrix.

subtract

public static double[][] subtract(double[][] arg1,
                                  double[][] arg2)
Subtract two matrices. Put result in new matrix.

multiply

public static double[][] multiply(double arg1,
                                  double[][] arg2,
                                  double[][] result)
Multiply a matrix by a constant. Put result in given matrix.

multiply

public static double[][] multiply(double arg1,
                                  double[][] arg2)
Multiply matrix by a constant. Put result in new matrix.

multiply

public static double[][] multiply(double[][] arg1,
                                  double[][] arg2,
                                  double[][] result)
Multiply two matrices. Put result in given matrix. if matrix is NXM and argument matrix is MXP, then result matrix must be NXP.

multiply

public static double[][] multiply(double[][] arg1,
                                  double[][] arg2)
Multiply two matrices. Put result in new matrix. if matrix is NXM and argument matrix is MXP, then result matrix will be NXP.

dotMultiply

public static double dotMultiply(double[][] arg1,
                                 double[][] arg2)
Dot Multiply matrix by another matrix. Returns a double. One matrix must be 1XN; the other must be NX1.

dotMultiply

public static double dotMultiply(double[] v1,
                                 double[] v2)

luDecompose

public static double[][] luDecompose(double[][] matrix,
                                     int[] indx,
                                     boolean parity)
luDecomposition performs LU Decomposition on a matrix. must be given an array to mark the row permutations and a flag to mark whether the number of permutations was even or odd. Reference: Numerical Recipes in C.

luBackSubstitute

public static double[][] luBackSubstitute(double[][] a,
                                          double[][] b,
                                          int[] indx)
Do the backsubstitution on matrix a which is the LU decomposition of the original matrix. b is the right hand side vector which is NX1. b is replaced by the solution. indx is the array that marks the row permutations.

solve

public static double[][] solve(double[][] a,
                               double[][] b)
Solve a set of linear equations. a is a square matrix of coefficients. b is the right hand side. b is replaced by solution. Target is replaced by its LU decomposition.

invert

public static double[][] invert(double[][] arg)
Invert a matrix.

clone

public static double[][] clone(double[][] src)

safeInvert

public static double[][] safeInvert(double[][] m)

bitcount

public static int bitcount(BitSet mask)

slice

public static double[][] slice(double[][] m,
                               BitSet rowMask,
                               BitSet colMask)

deSlice

public static double[][] deSlice(double[][] m,
                                 double fill,
                                 BitSet rowMask,
                                 BitSet colMask,
                                 double[][] r)
Only works on rectangular matrices. r may be provided or not, as desired.

fill

public static void fill(double[][] m,
                        double fill)

myInvert

public static double myInvert(double[][] ym,
                              double[][] rm)
A new invert routine taken directly from Amulet's gest_matrix.cc (where it's called InvertMatrix). Their comment is Matrix inversion using full pivoting. The standard Gauss-Jordan method is used. The return value is the determinant. The input matrix may be the same as the result matrix det = InvertMatrix(inputmatrix, resultmatrix); HISTORY 26-Feb-82 David Smith (drs) at Carnegie-Mellon University Written. Sun Mar 20 19:36:16 EST 1988 - stolen by dandb, and converted to this form

QuadraticForm

public static double QuadraticForm(double[] v,
                                   double[][] m)

subtract

public static double[] subtract(double[] v1,
                                double[] v2)

add

public static double[] add(double[] v1,
                           double[] v2)

multiply

public static double[] multiply(double factor,
                                double[] v)

main

public static void main(String[] args)
Test routine

Copyright Information