|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.yobotics.simulationconstructionset.mathfunctions.Matrix
public final class Matrix
Jama = Java Matrix class.
The Java Matrix Class provides the fundamental operations of numerical linear algebra. Various constructors create Matrices from two dimensional arrays of double precision floating point numbers. Various "gets" and "sets" provide access to submatrices and matrix elements. Several methods implement basic matrix arithmetic, including matrix addition and multiplication, matrix norms, and element-by-element array operations. Methods for reading and printing matrices are also included. All the operations in this version of the Matrix Class involve real matrices. Complex matrices may be handled in a future version.
Five fundamental matrix decompositions, which consist of pairs or triples of matrices, permutation vectors, and the like, produce results in five decomposition classes. These decompositions are accessed by the Matrix class to compute solutions of simultaneous linear equations, determinants, inverses and other matrix functions. The five decompositions are:
double[][] vals = {{1.,2.,3},{4.,5.,6.},{7.,8.,10.}}; Matrix A = new Matrix(vals); Matrix b = Matrix.random(3,1); Matrix x = A.solve(b); Matrix r = A.times(x).minus(b); double rnorm = r.normInf();
Constructor Summary | |
---|---|
Matrix(double[][] A)
Construct a matrix from a 2-D array. |
|
Matrix(int m,
int n)
Construct an m-by-n matrix of zeros. |
Method Summary | |
---|---|
double |
get(int i,
int j)
Get a single element. |
double[][] |
getArray()
Access the internal two-dimensional array. |
void |
getArrayCopy(double[][] C)
Copy the internal two-dimensional array into the passed array. |
int |
getColumnDimension()
Get column dimension. |
void |
getMatrix(double[][] B,
int[] r,
int j0,
int j1)
Get a submatrix. |
int |
getRowDimension()
Get row dimension. |
void |
inverse(Matrix Xmat)
|
void |
set(int i,
int j,
double s)
Set a single element. |
void |
setIdentity()
Sets this Matrix to be the identity matrix May 30, 2004: Added by J.Pratt |
void |
solve(Matrix Xmat,
Matrix B)
|
Matrix |
timesEquals(double s)
Multiply a matrix by a scalar in place, A = s*A |
void |
timesEquals(Matrix B,
Matrix C)
In place Linear algebraic matrix multiplication, A = B * C May 30, 2004: Added by J. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Matrix(int m, int n)
m
- Number of rows.n
- Number of colums.public Matrix(double[][] A)
A
- Two-dimensional array of doubles.
java.lang.IllegalArgumentException
- All rows must have the same length#constructWithCopy
Method Detail |
---|
public double[][] getArray()
public void getArrayCopy(double[][] C)
C
- Array that the values get copied into. Assumes dimensions are correct.public int getRowDimension()
public int getColumnDimension()
public double get(int i, int j)
i
- Row index.j
- Column index.
java.lang.ArrayIndexOutOfBoundsException
public void getMatrix(double[][] B, int[] r, int j0, int j1)
r
- Array of row indices.i0
- Initial column indexi1
- Final column index
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void set(int i, int j, double s)
i
- Row index.j
- Column index.s
- A(i,j).
java.lang.ArrayIndexOutOfBoundsException
public Matrix timesEquals(double s)
s
- scalar
public void timesEquals(Matrix B, Matrix C)
B
- two matrices
java.lang.IllegalArgumentException
- Matrix inner dimensions must agree.public void solve(Matrix Xmat, Matrix B)
public void inverse(Matrix Xmat)
public void setIdentity()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |