|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcolibri.extensions.textual.IE.common.crn.matrix.FloatMatrix
public class FloatMatrix
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 | |
---|---|
FloatMatrix(float[][] A)
Construct a matrix from a 2-D array. |
|
FloatMatrix(float[][] A,
int m,
int n)
Construct a matrix quickly without checking arguments. |
|
FloatMatrix(float[] vals,
int m)
Construct a matrix from a one-dimensional packed array |
|
FloatMatrix(int m,
int n)
Construct an m-by-n matrix of zeros. |
|
FloatMatrix(int m,
int n,
float s)
Construct an m-by-n constant matrix. |
Method Summary | |
---|---|
FloatMatrix |
arrayLeftDivide(FloatMatrix B)
Element-by-element left division, C = A. |
FloatMatrix |
arrayLeftDivideEquals(FloatMatrix B)
Element-by-element left division in place, A = A. |
FloatMatrix |
arrayRightDivide(FloatMatrix B)
Element-by-element right division, C = A. |
FloatMatrix |
arrayRightDivideEquals(FloatMatrix B)
Element-by-element right division in place, A = A. |
FloatMatrix |
arrayTimes(FloatMatrix B)
Element-by-element multiplication, C = A. |
FloatMatrix |
arrayTimesEquals(FloatMatrix B)
Element-by-element multiplication in place, A = A. |
java.lang.Object |
clone()
Clone the Matrix object. |
static FloatMatrix |
constructWithCopy(float[][] A)
Construct a matrix from a copy of a 2-D array. |
FloatMatrix |
copy()
Make a deep copy of a matrix |
float |
get(int i,
int j)
Get a single element. |
float[][] |
getArray()
Access the internal two-dimensional array. |
float[][] |
getArrayCopy()
Copy the internal two-dimensional array. |
int |
getColumnDimension()
Get column dimension. |
float[] |
getColumnPackedCopy()
Make a one-dimensional column packed copy of the internal array. |
int |
getColumns()
|
Matrix |
getDeepTraspose()
|
FloatMatrix |
getMatrix(int[] r,
int[] c)
Get a submatrix. |
FloatMatrix |
getMatrix(int[] r,
int j0,
int j1)
Get a submatrix. |
FloatMatrix |
getMatrix(int i0,
int i1,
int[] c)
Get a submatrix. |
FloatMatrix |
getMatrix(int i0,
int i1,
int j0,
int j1)
Get a submatrix. |
int |
getRowDimension()
Get row dimension. |
float[] |
getRowPackedCopy()
Make a one-dimensional row packed copy of the internal array. |
int |
getRows()
|
Matrix |
getShallowTraspose()
|
float |
getValue(int row,
int column)
|
static FloatMatrix |
identity(int m,
int n)
Generate identity matrix |
FloatMatrix |
minus(FloatMatrix B)
C = A - B |
FloatMatrix |
minusEquals(FloatMatrix B)
A = A - B |
Matrix |
multiply(Matrix other)
|
float |
multiply(Matrix other,
int thisRow,
int otherColumn)
|
float |
norm1()
One norm |
float |
normInf()
Infinity norm |
FloatMatrix |
plus(FloatMatrix B)
C = A + B |
FloatMatrix |
plusEquals(FloatMatrix B)
A = A + B |
void |
print(int w,
int d)
Print the matrix to stdout. |
void |
print(java.text.NumberFormat format,
int width)
Print the matrix to stdout. |
void |
print(java.io.PrintWriter output,
int w,
int d)
Print the matrix to the output stream. |
void |
print(java.io.PrintWriter output,
java.text.NumberFormat format,
int width)
Print the matrix to the output stream. |
static FloatMatrix |
random(int m,
int n)
Generate matrix with random elements |
void |
set(int i,
int j,
float s)
Set a single element. |
void |
setMatrix(int[] r,
int[] c,
FloatMatrix X)
Set a submatrix. |
void |
setMatrix(int[] r,
int j0,
int j1,
FloatMatrix X)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int[] c,
FloatMatrix X)
Set a submatrix. |
void |
setMatrix(int i0,
int i1,
int j0,
int j1,
FloatMatrix X)
Set a submatrix. |
void |
setValue(int row,
int column,
float value)
|
FloatMatrix |
times(float s)
Multiply a matrix by a scalar, C = s*A |
FloatMatrix |
times(FloatMatrix B)
Linear algebraic matrix multiplication, A * B |
FloatMatrix |
timesEquals(float s)
Multiply a matrix by a scalar in place, A = s*A |
float |
trace()
FloatMatrix trace. |
FloatMatrix |
transpose()
Matrix transpose. |
FloatMatrix |
uminus()
Unary minus |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FloatMatrix(int m, int n)
m
- Number of rows.n
- Number of colums.public FloatMatrix(int m, int n, float s)
m
- Number of rows.n
- Number of colums.s
- Fill the matrix with this scalar value.public FloatMatrix(float[][] A)
A
- Two-dimensional array of floats.
java.lang.IllegalArgumentException
- All rows must have the same lengthconstructWithCopy(float[][])
public FloatMatrix(float[][] A, int m, int n)
A
- Two-dimensional array of floats.m
- Number of rows.n
- Number of colums.public FloatMatrix(float[] vals, int m)
vals
- One-dimensional array of floats, packed by columns (ala Fortran).m
- Number of rows.
java.lang.IllegalArgumentException
- Array length must be a multiple of m.Method Detail |
---|
public static FloatMatrix constructWithCopy(float[][] A)
A
- Two-dimensional array of floats.
java.lang.IllegalArgumentException
- All rows must have the same lengthpublic FloatMatrix copy()
copy
in interface Matrix
public java.lang.Object clone()
clone
in class java.lang.Object
public float[][] getArray()
public float[][] getArrayCopy()
public float[] getColumnPackedCopy()
public float[] getRowPackedCopy()
public int getRowDimension()
public int getColumnDimension()
public float get(int i, int j)
i
- Row index.j
- Column index.
java.lang.ArrayIndexOutOfBoundsException
public FloatMatrix getMatrix(int i0, int i1, int j0, int j1)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column index
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getMatrix(int[] r, int[] c)
r
- Array of row indices.c
- Array of column indices.
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getMatrix(int i0, int i1, int[] c)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix getMatrix(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, float s)
i
- Row index.j
- Column index.s
- A(i,j).
java.lang.ArrayIndexOutOfBoundsException
public void setMatrix(int i0, int i1, int j0, int j1, FloatMatrix X)
i0
- Initial row indexi1
- Final row indexj0
- Initial column indexj1
- Final column indexX
- A(i0:i1,j0:j1)
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int[] r, int[] c, FloatMatrix X)
r
- Array of row indices.c
- Array of column indices.X
- A(r(:),c(:))
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int[] r, int j0, int j1, FloatMatrix X)
r
- Array of row indices.j0
- Initial column indexj1
- Final column indexX
- A(r(:),j0:j1)
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic void setMatrix(int i0, int i1, int[] c, FloatMatrix X)
i0
- Initial row indexi1
- Final row indexc
- Array of column indices.X
- A(i0:i1,c(:))
java.lang.ArrayIndexOutOfBoundsException
- Submatrix indicespublic FloatMatrix transpose()
public float norm1()
public float normInf()
public FloatMatrix uminus()
public FloatMatrix plus(FloatMatrix B)
B
- another matrix
public FloatMatrix plusEquals(FloatMatrix B)
B
- another matrix
public FloatMatrix minus(FloatMatrix B)
B
- another matrix
public FloatMatrix minusEquals(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayTimes(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayTimesEquals(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayRightDivide(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayRightDivideEquals(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayLeftDivide(FloatMatrix B)
B
- another matrix
public FloatMatrix arrayLeftDivideEquals(FloatMatrix B)
B
- another matrix
public FloatMatrix times(float s)
s
- scalar
public FloatMatrix timesEquals(float s)
s
- scalar
public FloatMatrix times(FloatMatrix B)
B
- another matrix
java.lang.IllegalArgumentException
- FloatMatrix inner dimensions must agree.public float trace()
public static FloatMatrix random(int m, int n)
m
- Number of rows.n
- Number of colums.
public static FloatMatrix identity(int m, int n)
m
- Number of rows.n
- Number of colums.
public void print(int w, int d)
w
- Column width.d
- Number of digits after the decimal.public void print(java.io.PrintWriter output, int w, int d)
output
- Output stream.w
- Column width.d
- Number of digits after the decimal.public void print(java.text.NumberFormat format, int width)
format
- A Formatting object for individual elements.width
- Field width for each column.DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)
public void print(java.io.PrintWriter output, java.text.NumberFormat format, int width)
output
- the output stream.format
- A formatting object to format the matrix elementswidth
- Column width.DecimalFormat.setDecimalFormatSymbols(java.text.DecimalFormatSymbols)
public int getColumns()
getColumns
in interface Matrix
public Matrix getDeepTraspose()
getDeepTraspose
in interface Matrix
public int getRows()
getRows
in interface Matrix
public Matrix getShallowTraspose()
getShallowTraspose
in interface Matrix
public float getValue(int row, int column)
getValue
in interface Matrix
public Matrix multiply(Matrix other)
multiply
in interface Matrix
public void setValue(int row, int column, float value)
setValue
in interface Matrix
public float multiply(Matrix other, int thisRow, int otherColumn)
multiply
in interface Matrix
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |