\n\n\n\nDenseMatrix\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n
\n
\n
\n\n\n\n
\n
org.jscience.mathematics.vector
\n

## Class DenseMatrix<F extends Field<F>>

\n
\n
\n
\n
\n
\n
• \n
\n
All Implemented Interfaces:
\n
javolution.lang.Immutable, javolution.lang.Realtime, javolution.lang.ValueType, GroupAdditive<Matrix<F>>, Ring<Matrix<F>>, Structure<Matrix<F>>, VectorSpace<Matrix<F>,F>
\n
\n
\n
\n
`public final class DenseMatrix<F extends Field<F>>\nextends Matrix<F>`
\n

This class represents a matrix made of `dense\n vectors` (as rows). To create a dense matrix made of column vectors the \n `transpose()` method can be used. \n For example:

``\n        DenseVector<Rational> column0 = DenseVector.valueOf(...);\n        DenseVector<Rational> column1 = DenseVector.valueOf(...);\n        DenseMatrix<Rational> M = DenseMatrix.valueOf(column0, column1).transpose();\n     ``

\n

As for any concrete `structure`, this class is declared `final` (otherwise most\n operations would have to be overridden to return the appropriate type).\n Specialized dense matrix should sub-class `Matrix` directly.\n For example:

``\n        // Extension through composition.\n        final class TriangularMatrix <F extends Field<F>> extends Matrix<F> {\n             private DenseMatrix<F> _value; // Possible implementation.\n             ...\n             public TriangularMatrix opposite() { // Returns the right type.\n                 return TriangularMatrix.valueOf(_value.opposite());\n             }\n             ...\n        }``
\n

\n
• \n
\n
\n
\n
\n
• \n\n
\n
• \n\n\n

### Method Summary

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Methods
Modifier and TypeMethod and Description
`DenseMatrix<F>``adjoint()`\n
Returns the adjoint of this matrix.
\n
`F``cofactor(int i,\n int j)`\n
Returns the cofactor of an element in this matrix.
\n
`DenseMatrix<F>``copy()`\n
Returns a copy of this matrix \n `allocated` \n by the calling thread (possibly on the stack).
\n
`F``determinant()`\n
Returns the determinant of this matrix.
\n
`F``get(int i,\n int j)`\n
Returns a single element from this matrix.
\n
`DenseVector<F>``getColumn(int j)`\n
Returns the column identified by the specified index in this matrix.
\n
`DenseVector<F>``getDiagonal()`\n
Returns the diagonal vector.
\n
`int``getNumberOfColumns()`\n
Returns the number of columns `n` for this matrix.
\n
`int``getNumberOfRows()`\n
Returns the number of rows `m` for this matrix.
\n
`DenseVector<F>``getRow(int i)`\n
Returns the row identified by the specified index in this matrix.
\n
`DenseMatrix<F>``inverse()`\n
Returns the inverse of this matrix (must be square).
\n
`DenseMatrix<F>``minus(Matrix<F> that)`\n
Returns the difference between this matrix and the one specified.
\n
`DenseMatrix<F>``opposite()`\n
Returns the negation of this matrix.
\n
`DenseMatrix<F>``plus(Matrix<F> that)`\n
Returns the sum of this matrix with the one specified.
\n
`Matrix<F>``tensor(Matrix<F> that)`\n
Returns the linear algebraic matrix tensor product of this matrix\n and another (Kronecker product).
\n
`DenseMatrix<F>``times(F k)`\n
Returns the product of this matrix by the specified factor.
\n
`DenseMatrix<F>``times(Matrix<F> that)`\n
Returns the product of this matrix with the one specified.
\n
`DenseVector<F>``times(Vector<F> v)`\n
Returns the product of this matrix by the specified vector.
\n
`DenseMatrix<F>``transpose()`\n
Returns the transpose of this matrix.
\n
`static <F extends Field<F>> DenseMatrix<F>``valueOf(DenseVector<F>... rows)`\n
Returns a dense matrix holding the specified row vectors \n (column vectors if `transposed`).
\n
`static <F extends Field<F>> DenseMatrix<F>``valueOf(F[][] elements)`\n
Returns a dense matrix from the specified 2-dimensional array.
\n
`static <F extends Field<F>> DenseMatrix<F>``valueOf(List<DenseVector<F>> rows)`\n
Returns a dense matrix holding the row vectors from the specified \n collection (column vectors if `transposed`).
\n
`static <F extends Field<F>> DenseMatrix<F>``valueOf(Matrix<F> that)`\n
Returns a dense matrix equivalent to the specified matrix.
\n
`Vector<F>``vectorization()`\n
Returns the vectorization of this matrix.
\n
\n
\n
• \n\n\n

### Methods inherited from class org.jscience.mathematics.vector.Matrix

\n`divide, equals, equals, hashCode, isSquare, pow, pseudoInverse, solve, solve, toString, toText, trace`
• \n
\n
\n
• \n\n\n

### Methods inherited from class java.lang.Object

\n`getClass, notify, notifyAll, wait, wait, wait`
• \n
\n
• \n
\n
• \n
\n
\n
\n
\n
• \n\n
\n
• \n\n\n

### Method Detail

\n\n\n\n\n\n
\n
• \n

#### valueOf

\n
`public static <F extends Field<F>> DenseMatrix<F> valueOf(F[][] elements)`
\n
Returns a dense matrix from the specified 2-dimensional array.\n The first dimension being the row and the second being the column.
\n
Parameters:
`elements` - this matrix elements.
\n
Returns:
the matrix having the specified elements.
\n
Throws:
\n
`DimensionException` - if rows have different length.
`DenseMatrix`
\n
• \n
\n\n\n\n
\n
• \n

#### valueOf

\n
`public static <F extends Field<F>> DenseMatrix<F> valueOf(DenseVector<F>... rows)`
\n
Returns a dense matrix holding the specified row vectors \n (column vectors if `transposed`).
\n
Parameters:
`rows` - the row vectors.
\n
Returns:
the matrix having the specified rows.
\n
Throws:
\n
`DimensionException` - if the rows do not have the same dimension.
\n
• \n
\n\n\n\n
\n
• \n

#### valueOf

\n
`public static <F extends Field<F>> DenseMatrix<F> valueOf(List<DenseVector<F>> rows)`
\n
Returns a dense matrix holding the row vectors from the specified \n collection (column vectors if `transposed`).
\n
Parameters:
`rows` - the list of row vectors.
\n
Returns:
the matrix having the specified rows.
\n
Throws:
\n
`DimensionException` - if the rows do not have the same dimension.
\n
• \n
\n\n\n\n
\n
• \n

#### valueOf

\n
`public static <F extends Field<F>> DenseMatrix<F> valueOf(Matrix<F> that)`
\n
Returns a dense matrix equivalent to the specified matrix.
\n
Parameters:
`that` - the matrix to convert.
\n
Returns:
`that` or a dense matrix holding the same elements\n as the specified matrix.
\n
• \n
\n\n\n\n
\n
• \n

#### getNumberOfRows

\n
`public int getNumberOfRows()`
\n
Description copied from class: `Matrix`
\n
Returns the number of rows `m` for this matrix.
\n
\n
Specified by:
\n
`getNumberOfRows` in class `Matrix<F extends Field<F>>`
\n
Returns:
m, the number of rows.
\n
• \n
\n\n\n\n
\n
• \n

#### getNumberOfColumns

\n
`public int getNumberOfColumns()`
\n
Description copied from class: `Matrix`
\n
Returns the number of columns `n` for this matrix.
\n
\n
Specified by:
\n
`getNumberOfColumns` in class `Matrix<F extends Field<F>>`
\n
Returns:
n, the number of columns.
\n
• \n
\n\n\n\n
\n
• \n

#### get

\n
`public F get(int i,\n    int j)`
\n
Description copied from class: `Matrix`
\n
Returns a single element from this matrix.
\n
\n
Specified by:
\n
`get` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`i` - the row index (range [0..m[).
`j` - the column index (range [0..n[).
\n
Returns:
\n
• \n
\n\n\n\n
\n
• \n

#### getRow

\n
`public DenseVector<F> getRow(int i)`
\n
Description copied from class: `Matrix`
\n
Returns the row identified by the specified index in this matrix.
\n
\n
Specified by:
\n
`getRow` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`i` - the row index (range [0..m[).
\n
Returns:
the vector holding the specified row.
\n
• \n
\n\n\n\n
\n
• \n

#### getColumn

\n
`public DenseVector<F> getColumn(int j)`
\n
Description copied from class: `Matrix`
\n
Returns the column identified by the specified index in this matrix.
\n
\n
Specified by:
\n
`getColumn` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`j` - the column index (range [0..n[).
\n
Returns:
the vector holding the specified column.
\n
• \n
\n\n\n\n
\n
• \n

#### getDiagonal

\n
`public DenseVector<F> getDiagonal()`
\n
Description copied from class: `Matrix`
\n
Returns the diagonal vector.
\n
\n
Specified by:
\n
`getDiagonal` in class `Matrix<F extends Field<F>>`
\n
Returns:
the vector holding the diagonal elements.
\n
• \n
\n\n\n\n
\n
• \n

#### opposite

\n
`public DenseMatrix<F> opposite()`
\n
Description copied from class: `Matrix`
\n
Returns the negation of this matrix.
\n
\n
Specified by:
\n
`opposite` in interface `GroupAdditive<Matrix<F extends Field<F>>>`
\n
Specified by:
\n
`opposite` in class `Matrix<F extends Field<F>>`
\n
Returns:
`-this`.
\n
• \n
\n\n\n\n
\n
• \n

#### plus

\n
`public DenseMatrix<F> plus(Matrix<F> that)`
\n
Description copied from class: `Matrix`
\n
Returns the sum of this matrix with the one specified.
\n
\n
Specified by:
\n
`plus` in interface `GroupAdditive<Matrix<F extends Field<F>>>`
\n
Specified by:
\n
`plus` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`that` - the matrix to be added.
\n
Returns:
`this + that`.
\n
• \n
\n\n\n\n
\n
• \n

#### minus

\n
`public DenseMatrix<F> minus(Matrix<F> that)`
\n
Description copied from class: `Matrix`
\n
Returns the difference between this matrix and the one specified.
\n
\n
Overrides:
\n
`minus` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`that` - the matrix to be subtracted.
\n
Returns:
`this - that`.
\n
• \n
\n\n\n\n\n\n
\n
• \n

#### times

\n
`public DenseMatrix<F> times(F k)`
\n
Description copied from class: `Matrix`
\n
Returns the product of this matrix by the specified factor.
\n
\n
Specified by:
\n
`times` in interface `VectorSpace<Matrix<F extends Field<F>>,F extends Field<F>>`
\n
Specified by:
\n
`times` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`k` - the coefficient multiplier.
\n
Returns:
`this \xc2\xb7 k`
\n
• \n
\n\n\n\n
\n
• \n

#### times

\n
`public DenseVector<F> times(Vector<F> v)`
\n
Description copied from class: `Matrix`
\n
Returns the product of this matrix by the specified vector.
\n
\n
Specified by:
\n
`times` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`v` - the vector.
\n
Returns:
`this \xc2\xb7 v`
\n
• \n
\n\n\n\n
\n
• \n

#### times

\n
`public DenseMatrix<F> times(Matrix<F> that)`
\n
Description copied from class: `Matrix`
\n
Returns the product of this matrix with the one specified.
\n
\n
Specified by:
\n
`times` in interface `Ring<Matrix<F extends Field<F>>>`
\n
Specified by:
\n
`times` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`that` - the matrix multiplier.
\n
Returns:
`this \xc2\xb7 that`.
\n
• \n
\n\n\n\n
\n
• \n

#### inverse

\n
`public DenseMatrix<F> inverse()`
\n
Description copied from class: `Matrix`
\n
Returns the inverse of this matrix (must be square).
\n
\n
Specified by:
\n
`inverse` in class `Matrix<F extends Field<F>>`
\n
Returns:
`1 / this`
\n
• \n
\n\n\n\n
\n
• \n

#### determinant

\n
`public F determinant()`
\n
Description copied from class: `Matrix`
\n
Returns the determinant of this matrix.
\n
\n
Specified by:
\n
`determinant` in class `Matrix<F extends Field<F>>`
\n
Returns:
this matrix determinant.
\n
• \n
\n\n\n\n
\n
• \n

#### transpose

\n
`public DenseMatrix<F> transpose()`
\n
Description copied from class: `Matrix`
\n
Returns the transpose of this matrix.
\n
\n
Specified by:
\n
`transpose` in class `Matrix<F extends Field<F>>`
\n
Returns:
`A\'`.
\n
• \n
\n\n\n\n
\n
• \n

#### cofactor

\n
`public F cofactor(int i,\n         int j)`
\n
Description copied from class: `Matrix`
\n
Returns the cofactor of an element in this matrix. It is the value\n obtained by evaluating the determinant formed by the elements not in\n that particular row or column.
\n
\n
Specified by:
\n
`cofactor` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`i` - the row index.
`j` - the column index.
\n
Returns:
the cofactor of `THIS[i,j]`.
\n
• \n
\n\n\n\n
\n
• \n

\n
`public DenseMatrix<F> adjoint()`
\n
Description copied from class: `Matrix`
\n
Returns the adjoint of this matrix. It is obtained by replacing each\n element in this matrix with its cofactor and applying a + or - sign\n according (-1)**(i+j), and then finding the transpose of the resulting\n matrix.
\n
\n
Specified by:
\n
`adjoint` in class `Matrix<F extends Field<F>>`
\n
Returns:
\n
• \n
\n\n\n\n
\n
• \n

#### tensor

\n
`public Matrix<F> tensor(Matrix<F> that)`
\n
Description copied from class: `Matrix`
\n
Returns the linear algebraic matrix tensor product of this matrix\n and another (Kronecker product). The default implementation returns\n a `DenseMatrix`.
\n
\n
Specified by:
\n
`tensor` in class `Matrix<F extends Field<F>>`
\n
Parameters:
`that` - the second matrix.
\n
Returns:
`this ⊗ that`
\n Wikipedia: Kronecker Product
\n
• \n
\n\n\n\n
\n
• \n

#### vectorization

\n
`public Vector<F> vectorization()`
\n
Description copied from class: `Matrix`
\n
Returns the vectorization of this matrix. The vectorization of \n a matrix is the column vector obtain by stacking the columns of the\n matrix on top of one another. The default implementation returns \n a `DenseVector`.
\n
\n
Specified by:
\n
`vectorization` in class `Matrix<F extends Field<F>>`
\n
Returns:
the vectorization of this matrix.
\n Wikipedia: Vectorization.
\n
• \n
\n\n\n\n
\n
• \n

#### copy

\n
`public DenseMatrix<F> copy()`
\n
Description copied from class: `Matrix`
\n
Returns a copy of this matrix \n `allocated` \n by the calling thread (possibly on the stack).
\n
\n
Specified by:
\n
`copy` in interface `javolution.lang.ValueType`
\n
Specified by:
\n
`copy` in class `Matrix<F extends Field<F>>`
\n
Returns:
an identical and independant copy of this matrix.
\n
• \n
\n
• \n
\n
• \n
\n
\n
\n\n\n
\n\n\n\n\n
\n
\n
\n\n\n