Matrix |
abstract public class Matrix implements VectorSpace<Matrix<F>, F>,Ring<Matrix<F>>,ValueType,Realtime(Code) |
| This class represents a rectangular table of elements of a ring-like
algebraic structure.
Instances of this class can be used to resolve system of linear equations
involving any kind of
Field Field elements
(e.g.
org.jscience.mathematics.number.Real Real ,
org.jscience.mathematics.number.Complex Complex ,
org.jscience.physics.amount.Amount Amount<?> ,
org.jscience.mathematics.function.Function Function , etc).
For example:[code]
// Creates a dense matrix (2x2) of Rational numbers.
DenseMatrix M = DenseMatrix.valueOf(
{ Rational.valueOf(23, 45), Rational.valueOf(33, 75) },
{ Rational.valueOf(15, 31), Rational.valueOf(-20, 45)});
// Creates a sparse matrix (16x2) of Real numbers.
SparseMatrix M = SparseMatrix.valueOf(
SparseVector.valueOf(16, Real.ZERO, 0, Real.valueOf(5)),
SparseVector.valueOf(16, Real.ZERO, 15, Real.valueOf(-3)));
// Creates a floating-point (64 bits) matrix (3x2).
Float64Matrix M = Float64Matrix.valueOf(
{{ 1.0, 2.0, 3.0}, { 4.0, 5.0, 6.0}});
// Creates a complex single column matrix (1x2).
ComplexMatrix M = ComplexMatrix.valueOf(
{{ Complex.valueOf(1.0, 2.0), Complex.valueOf(4.0, 5.0)}}).transpose();
// Creates an identity matrix (2x2) for modulo integer.
SparseMatrix IDENTITY = SparseMatrix.valueOf(
DenseVector.valueOf(ModuloInteger.ONE, ModuloInteger.ONE), ModuloInteger.ZERO);
[/code]
Non-commutative field multiplication is supported. Invertible square
matrices may form a non-commutative field (also called a division
ring). In which case this class may be used to resolve system of linear
equations with matrix coefficients.
Implementation Note: Matrices may use
javolution.context.StackContext StackContext and
javolution.context.ConcurrentContext ConcurrentContext in order to
minimize heap allocation and accelerate calculations on multi-core
systems.
author: Jean-Marie Dautelle version: 3.3, December 24, 2006 See Also:
* Wikipedia: Matrix (mathematics) |
Method Summary |
|
abstract public Matrix<F> | adjoint() Returns the adjoint of this matrix. |
abstract public F | cofactor(int i, int j) Returns the cofactor of an element in this matrix. |
abstract public Matrix<F> | copy() Returns a copy of this matrix
javolution.context.AllocatorContext allocated
by the calling thread (possibly on the stack). |
abstract public F | determinant() Returns the determinant of this matrix. |
public Matrix<F> | divide(Matrix<F> that) Returns this matrix divided by the one specified.
Parameters: that - the matrix divisor. |
public boolean | equals(Matrix<F> that, Comparator<F> cmp) Indicates if this matrix can be considered equals to the one
specified using the specified comparator when testing for
element equality. |
public boolean | equals(Object that) Indicates if this matrix is strictly equal to the object specified.
Parameters: that - the object to compare for equality. |
abstract public F | get(int i, int j) Returns a single element from this matrix.
Parameters: i - the row index (range [0..m[). Parameters: j - the column index (range [0..n[). |
abstract public Vector<F> | getColumn(int j) Returns the column identified by the specified index in this matrix.
Parameters: j - the column index (range [0..n[). |
abstract public Vector<F> | getDiagonal() Returns the diagonal vector. |
abstract public int | getNumberOfColumns() Returns the number of columns n for this matrix. |
abstract public int | getNumberOfRows() Returns the number of rows m for this matrix. |
abstract public Vector<F> | getRow(int i) Returns the row identified by the specified index in this matrix.
Parameters: i - the row index (range [0..m[). |
public int | hashCode() Returns a hash code value for this matrix. |
abstract public Matrix<F> | inverse() Returns the inverse of this matrix (must be square). |
public boolean | isSquare() Indicates if this matrix is square. |
public Matrix<F> | minus(Matrix<F> that) Returns the difference between this matrix and the one specified.
Parameters: that - the matrix to be subtracted. |
abstract public Matrix<F> | opposite() Returns the negation of this matrix. |
abstract public Matrix<F> | plus(Matrix<F> that) Returns the sum of this matrix with the one specified.
Parameters: that - the matrix to be added. |
public Matrix<F> | pow(int exp) Returns this matrix raised at the specified exponent.
Parameters: exp - the exponent. |
public Matrix<F> | pseudoInverse() Returns the inverse or pseudo-inverse if this matrix if not square. |
public Vector<F> | solve(Vector<F> y) Solves this matrix for the specified vector (returns x
such as this · x = y ).
Parameters: y - the vector for which the solution is calculated. |
public Matrix<F> | solve(Matrix<F> y) Solves this matrix for the specified matrix (returns x
such as this · x = y ).
Parameters: y - the matrix for which the solution is calculated. |
abstract public Matrix<F> | tensor(Matrix<F> that) Returns the linear algebraic matrix tensor product of this matrix
and another (Kronecker product). |
abstract public Matrix<F> | times(F k) Returns the product of this matrix by the specified factor.
Parameters: k - the coefficient multiplier. |
abstract public Vector<F> | times(Vector<F> v) Returns the product of this matrix by the specified vector.
Parameters: v - the vector. |
abstract public Matrix<F> | times(Matrix<F> that) Returns the product of this matrix with the one specified.
Parameters: that - the matrix multiplier. |
final public String | toString() Returns the text representation of this matrix as a
java.lang.String . |
public Text | toText() Returns the text representation of this matrix. |
public F | trace() Returns the trace of this matrix. |
abstract public Matrix<F> | transpose() Returns the transpose of this matrix. |
abstract public Vector<F> | vectorization() Returns the vectorization of this matrix. |