Class DenseMatrix<F extends Field<F>>
- java.lang.Object
-
- org.jscience.mathematics.vector.Matrix<F>
-
- org.jscience.mathematics.vector.DenseMatrix<F>
-
- All Implemented Interfaces:
javolution.lang.Immutable,javolution.lang.Realtime,javolution.lang.ValueType,GroupAdditive<Matrix<F>>,Ring<Matrix<F>>,Structure<Matrix<F>>,VectorSpace<Matrix<F>,F>
public final class DenseMatrix<F extends Field<F>> extends Matrix<F>
This class represents a matrix made of
dense vectors(as rows). To create a dense matrix made of column vectors thetranspose()method can be used. For example:[code] DenseVectorcolumn0 = DenseVector.valueOf(...); DenseVector column1 = DenseVector.valueOf(...); DenseMatrix M = DenseMatrix.valueOf(column0, column1).transpose(); [/code] As for any concrete
structure, this class is declaredfinal(otherwise most operations would have to be overridden to return the appropriate type). Specialized dense matrix should sub-classMatrixdirectly. For example:[code] // Extension through composition. final class TriangularMatrix> extends Matrix { private DenseMatrix _value; // Possible implementation. ... public TriangularMatrix opposite() { // Returns the right type. return TriangularMatrix.valueOf(_value.opposite()); } ... }[/code] - Version:
- 3.3, January 2, 2007
- Author:
- Jean-Marie Dautelle
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DenseMatrix<F>adjoint()Returns the adjoint of this matrix.Fcofactor(int i, int j)Returns the cofactor of an element in this matrix.DenseMatrix<F>copy()Returns a copy of this matrixallocatedby the calling thread (possibly on the stack).Fdeterminant()Returns the determinant of this matrix.Fget(int i, int j)Returns a single element from this matrix.DenseVector<F>getColumn(int j)Returns the column identified by the specified index in this matrix.DenseVector<F>getDiagonal()Returns the diagonal vector.intgetNumberOfColumns()Returns the number of columnsnfor this matrix.intgetNumberOfRows()Returns the number of rowsmfor this matrix.DenseVector<F>getRow(int i)Returns the row identified by the specified index in this matrix.DenseMatrix<F>inverse()Returns the inverse of this matrix (must be square).DenseMatrix<F>minus(Matrix<F> that)Returns the difference between this matrix and the one specified.DenseMatrix<F>opposite()Returns the negation of this matrix.DenseMatrix<F>plus(Matrix<F> that)Returns the sum of this matrix with the one specified.Matrix<F>tensor(Matrix<F> that)Returns the linear algebraic matrix tensor product of this matrix and another (Kronecker product).DenseMatrix<F>times(F k)Returns the product of this matrix by the specified factor.DenseMatrix<F>times(Matrix<F> that)Returns the product of this matrix with the one specified.DenseVector<F>times(Vector<F> v)Returns the product of this matrix by the specified vector.DenseMatrix<F>transpose()Returns the transpose of this matrix.static <F extends Field<F>>
DenseMatrix<F>valueOf(F[][] elements)Returns a dense matrix from the specified 2-dimensional array.static <F extends Field<F>>
DenseMatrix<F>valueOf(java.util.List<DenseVector<F>> rows)Returns a dense matrix holding the row vectors from the specified collection (column vectors iftransposed).static <F extends Field<F>>
DenseMatrix<F>valueOf(DenseVector<F>... rows)Returns a dense matrix holding the specified row vectors (column vectors iftransposed).static <F extends Field<F>>
DenseMatrix<F>valueOf(Matrix<F> that)Returns a dense matrix equivalent to the specified matrix.Vector<F>vectorization()Returns the vectorization of this matrix.
-
-
-
Method Detail
-
valueOf
public static <F extends Field<F>> DenseMatrix<F> valueOf(F[][] elements)
Returns a dense matrix from the specified 2-dimensional array. The first dimension being the row and the second being the column.- Parameters:
elements- this matrix elements.- Returns:
- the matrix having the specified elements.
- Throws:
DimensionException- if rows have different length.- See Also:
DenseMatrix
-
valueOf
public static <F extends Field<F>> DenseMatrix<F> valueOf(DenseVector<F>... rows)
Returns a dense matrix holding the specified row vectors (column vectors iftransposed).- Parameters:
rows- the row vectors.- Returns:
- the matrix having the specified rows.
- Throws:
DimensionException- if the rows do not have the same dimension.
-
valueOf
public static <F extends Field<F>> DenseMatrix<F> valueOf(java.util.List<DenseVector<F>> rows)
Returns a dense matrix holding the row vectors from the specified collection (column vectors iftransposed).- Parameters:
rows- the list of row vectors.- Returns:
- the matrix having the specified rows.
- Throws:
DimensionException- if the rows do not have the same dimension.
-
valueOf
public static <F extends Field<F>> DenseMatrix<F> valueOf(Matrix<F> that)
Returns a dense matrix equivalent to the specified matrix.- Parameters:
that- the matrix to convert.- Returns:
thator a dense matrix holding the same elements as the specified matrix.
-
getNumberOfRows
public int getNumberOfRows()
Description copied from class:MatrixReturns the number of rowsmfor this matrix.- Specified by:
getNumberOfRowsin classMatrix<F extends Field<F>>- Returns:
- m, the number of rows.
-
getNumberOfColumns
public int getNumberOfColumns()
Description copied from class:MatrixReturns the number of columnsnfor this matrix.- Specified by:
getNumberOfColumnsin classMatrix<F extends Field<F>>- Returns:
- n, the number of columns.
-
get
public F get(int i, int j)
Description copied from class:MatrixReturns a single element from this matrix.
-
getRow
public DenseVector<F> getRow(int i)
Description copied from class:MatrixReturns the row identified by the specified index in this matrix.
-
getColumn
public DenseVector<F> getColumn(int j)
Description copied from class:MatrixReturns the column identified by the specified index in this matrix.
-
getDiagonal
public DenseVector<F> getDiagonal()
Description copied from class:MatrixReturns the diagonal vector.- Specified by:
getDiagonalin classMatrix<F extends Field<F>>- Returns:
- the vector holding the diagonal elements.
-
opposite
public DenseMatrix<F> opposite()
Description copied from class:MatrixReturns the negation of this matrix.
-
plus
public DenseMatrix<F> plus(Matrix<F> that)
Description copied from class:MatrixReturns the sum of this matrix with the one specified.
-
minus
public DenseMatrix<F> minus(Matrix<F> that)
Description copied from class:MatrixReturns the difference between this matrix and the one specified.
-
times
public DenseMatrix<F> times(F k)
Description copied from class:MatrixReturns the product of this matrix by the specified factor.
-
times
public DenseVector<F> times(Vector<F> v)
Description copied from class:MatrixReturns the product of this matrix by the specified vector.
-
times
public DenseMatrix<F> times(Matrix<F> that)
Description copied from class:MatrixReturns the product of this matrix with the one specified.
-
inverse
public DenseMatrix<F> inverse()
Description copied from class:MatrixReturns the inverse of this matrix (must be square).
-
determinant
public F determinant()
Description copied from class:MatrixReturns the determinant of this matrix.- Specified by:
determinantin classMatrix<F extends Field<F>>- Returns:
- this matrix determinant.
-
transpose
public DenseMatrix<F> transpose()
Description copied from class:MatrixReturns the transpose of this matrix.
-
cofactor
public F cofactor(int i, int j)
Description copied from class:MatrixReturns the cofactor of an element in this matrix. It is the value obtained by evaluating the determinant formed by the elements not in that particular row or column.
-
adjoint
public DenseMatrix<F> adjoint()
Description copied from class:MatrixReturns the adjoint of this matrix. It is obtained by replacing each element in this matrix with its cofactor and applying a + or - sign according (-1)**(i+j), and then finding the transpose of the resulting matrix.
-
tensor
public Matrix<F> tensor(Matrix<F> that)
Description copied from class:MatrixReturns the linear algebraic matrix tensor product of this matrix and another (Kronecker product). The default implementation returns aDenseMatrix.
-
vectorization
public Vector<F> vectorization()
Description copied from class:MatrixReturns the vectorization of this matrix. The vectorization of a matrix is the column vector obtain by stacking the columns of the matrix on top of one another. The default implementation returns aDenseVector.- Specified by:
vectorizationin classMatrix<F extends Field<F>>- Returns:
- the vectorization of this matrix.
- See Also:
- Wikipedia: Vectorization.
-
copy
public DenseMatrix<F> copy()
Description copied from class:MatrixReturns a copy of this matrixallocatedby the calling thread (possibly on the stack).
-
-