|
JScience v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.realtime.RealtimeObject
org.jscience.mathematics.matrices.Matrix<O>
public class Matrix<O extends Operable<O>>
This class represents an immutable matrix of Operable elements.
It may be used to resolve system of linear equations involving
any kind of Operable elements
(e.g. Real,
Complex,
Quantity,
Function, etc).
Non-commutative multiplication is supported and this class itself
implements the Operable interface. Consequently, this class may
be used to resolve system of linear equations involving matrices
(for which the multiplication is not commutative).
Implementation Note: This class uses concurrent contexts to accelerate calculations on multi-processor
systems.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javolution.realtime.RealtimeObject |
|---|
RealtimeObject.Factory<T extends RealtimeObject> |
| Nested classes/interfaces inherited from interface javolution.realtime.Realtime |
|---|
Realtime.ObjectSpace |
| Field Summary | |
|---|---|
protected static XmlFormat<Matrix> |
XML
Holds the default XML representation for Matrix and its
sub-classes. |
| Constructor Summary | |
|---|---|
Matrix(O[][] elements)
Creates a matrix from the specified 2-dimensional array of Operable objects. |
|
| Method Summary | ||
|---|---|---|
Matrix<O> |
adjoint()
Returns the adjoint of this matrix. |
|
O |
cofactor(int i,
int j)
Returns the cofactor of an element in this matrix. |
|
O |
determinant()
Returns the determinant of this matrix. |
|
Matrix<O> |
divide(Matrix<O> that)
Returns this matrix divided by the one specified. |
|
boolean |
equals(java.lang.Object that)
Indicates if this matrix is equal to the object specified. |
|
O |
get(int i,
int j)
Returns a single element from this matrix. |
|
Matrix<O> |
getMatrix(int[] rows,
int[] columns)
Returns a sub-matrix composed of the specified rows and columns from this matrix. |
|
Matrix<O> |
getMatrix(int i0,
int i1,
int j0,
int j1)
Returns a sub-matrix of this matrix given the range of its rows and columns indices. |
|
int |
getNumberOfColumns()
Returns the number of columns for this matrix. |
|
int |
getNumberOfRows()
Returns the number of rows for this matrix. |
|
int |
hashCode()
Returns a hash code value for this matrix. |
|
Matrix<O> |
inverse()
Returns the inverse or pseudo-inverse if this matrix if not square. |
|
boolean |
isSquare()
Indicates if this matrix is square. |
|
LUDecomposition<O> |
lu()
Returns the LUDecomposition of this Matrix. |
|
Matrix<O> |
minus(Matrix<O> that)
Returns the difference between this matrix and the one specified. |
|
boolean |
move(Realtime.ObjectSpace os)
|
|
Matrix<O> |
opposite()
Returns the negation of this matrix. |
|
Matrix<O> |
plus(Matrix<O> that)
Returns the sum of this matrix with the one specified. |
|
Matrix<O> |
pow(int exp)
Returns this matrix raised at the specified exponent. |
|
Matrix<O> |
reciprocal()
Returns the reciprocal of this matrix (must be square). |
|
Matrix<O> |
tensor(Matrix<O> that)
Returns the linear algebraic matrix tensor product of this matrix and another. |
|
Matrix<O> |
times(Matrix<O> that)
Returns the product of this matrix with the one specified. |
|
Matrix<O> |
times(O k)
Return the product of this matrix with the specified factor. |
|
Text |
toText()
Returns the text representation of this matrix. |
|
O |
trace()
Returns the trace of this matrix. |
|
Matrix<O> |
transpose()
Returns the transpose of this matrix. |
|
static Matrix<Float64> |
valueOf(double[][] values)
Returns a matrix from a 2-dimensional array of double
values (convenience method). |
|
static
|
valueOf(int m,
int n,
java.util.Collection<O> elements)
Returns a m-by-n matrix populated from the specified collection of Operable objects (rows first). |
|
static
|
valueOf(int m,
int n,
O diagonal,
O other)
Returns a m-by-n matrix filled with the specified diagonal element and the specified non-diagonal element. |
|
static
|
valueOf(O[][] elements)
Returns a matrix from a 2-dimensional array of Operable objects. |
|
| Methods inherited from class javolution.realtime.RealtimeObject |
|---|
export, moveHeap, preserve, recycle, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final XmlFormat<Matrix> XML
Matrix and its
sub-classes. This representation consists of the matrix
elements as nested XML elements and the matrix row and
column as attributes. For example:
<math:Matrix row="2" column="1">
<math:Complex real="1.0" imaginary="0.0"/>
<math:Complex real="0.0" imaginary="1.0"/>
</math:Matrix>
| Constructor Detail |
|---|
public Matrix(O[][] elements)
Operable objects.
The first dimension being the row and the second being the column.
Note: It is safe to reuse the specified array as it is not internally referenced by the matrix being returned.
elements - the array of Operable elements.
java.lang.IllegalArgumentException - if rows have different length.| Method Detail |
|---|
public static <O extends Operable<O>> Matrix<O> valueOf(int m,
int n,
O diagonal,
O other)
valueOf(m, m, ONE, ZERO)).
m - the number of rows.n - the number of columns.diagonal - the diagonal element.other - the non-diagonal element.
d on the diagonal and
o elsewhere.public static Matrix<Float64> valueOf(double[][] values)
double
values (convenience method). The first dimension being the number
of rows and the second being the number of columns ([m,n]).
values - the array of double values.
Float64 elements.
java.lang.IllegalArgumentException - if rows have different length.public static <O extends Operable<O>> Matrix<O> valueOf(O[][] elements)
Operable objects.
The first dimension being the number of rows and the second being the
number of columns ([m,n]).
Note: It is safe to reuse the specifed array as it is not internally referenced by the matrix being returned.
elements - the array of Operable objects.
java.lang.IllegalArgumentException - if rows have different length.
public static <O extends Operable<O>> Matrix<O> valueOf(int m,
int n,
java.util.Collection<O> elements)
Operable objects (rows first).
m - the number of rows.n - the number of columns.elements - the collection of Operable objects.
MatrixException - if elements.size() != m * n
java.lang.ClassCastException - if any of the element is not Operable.public final int getNumberOfRows()
public final int getNumberOfColumns()
public final boolean isSquare()
nbrOfRows() == nbrOfColumns()
public final O get(int i,
int j)
i - the row index (range [0..m[).j - the column index (range [0..n[).
java.lang.IndexOutOfBoundsException -
(i < 0) || (i >= m)) || (j < 0) || (j >= n))
public final Matrix<O> getMatrix(int i0,
int i1,
int j0,
int j1)
i0 - the initial row index.i1 - the final row index.j0 - the initial column index.j1 - the final column index.
THIS(i0:i1, j0:j1)
public final Matrix<O> getMatrix(int[] rows,
int[] columns)
rows - the indices of the rows to return.columns - the indices of the columns to return.
public final LUDecomposition<O> lu()
LUDecomposition of this Matrix.
Numerical stability is guaranteed (through pivoting) if the
Operable elements of this matrix are derived from
Numeric.
For others elements types, numerical stability can be ensured by setting
a local pivot comparator.
public boolean equals(java.lang.Object that)
equals in class java.lang.Objectthat - the object to compare for equality.
true if this matrix and the specified object are
considered equal; false otherwise.public int hashCode()
hashCode in class java.lang.Objectequals(java.lang.Object)public Matrix<O> opposite()
opposite in interface Operable<Matrix<O extends Operable<O>>>-this.public Matrix<O> plus(Matrix<O> that)
plus in interface Operable<Matrix<O extends Operable<O>>>that - the matrix to be added.
this + that.
MatrixException - matrices's dimensions are different.public Matrix<O> minus(Matrix<O> that)
that - the matrix to be subtracted.
this - that.
MatrixException - matrices's dimensions are different.public Matrix<O> times(O k)
k - the coefficient multiplier.
k * M.public Matrix<O> times(Matrix<O> that)
times in interface Operable<Matrix<O extends Operable<O>>>that - the matrix multiplier.
this * that.
MatrixException - M.getRowDimension()
!= this.getColumnDimension().public Matrix<O> divide(Matrix<O> that)
that - the matrix divisor.
this / that.
MatrixException - if that matrix is not square or dimensions
do not match.public Matrix<O> reciprocal()
reciprocal in interface Operable<Matrix<O extends Operable<O>>>1 / this
MatrixException - if this matrix is not square.lu()public Matrix<O> inverse()
Note: To resolve the equation A * X = B,
it is usually faster to calculate A.lu().solve(B)
rather than A.inverse().times(B).
lu()public Matrix<O> tensor(Matrix<O> that)
that - the second matrix.
this
and that.public Text toText()
toText in interface RealtimetoText in class RealtimeObjectpublic Matrix<O> transpose()
A'.public O determinant()
lu().determinant()
MatrixException - matrix is not square.
public O cofactor(int i,
int j)
i - the row index.j - the column index.
THIS[i,j].
MatrixException - matrix is not square or its dimension
is less than 2.public O trace()
public Matrix<O> adjoint()
MatrixException - if this matrix is not square or if
its dimension is less than 2.public Matrix<O> pow(int exp)
exp - the exponent.
thisexp
MatrixException - if this matrix is not square.public boolean move(Realtime.ObjectSpace os)
move in interface Realtimemove in class RealtimeObject
|
JScience v2.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||