Package org.la4j.matrix
Class DenseMatrix
- java.lang.Object
-
- org.la4j.Matrix
-
- org.la4j.matrix.DenseMatrix
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Double>
- Direct Known Subclasses:
Basic1DMatrix
,Basic2DMatrix
public abstract class DenseMatrix extends Matrix
-
-
Constructor Summary
Constructors Constructor Description DenseMatrix(int rows, int columns)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T> T
apply(MatrixMatrixOperation<T> operation, Matrix that)
Pipes this matrix to a givenoperation
.<T> T
apply(MatrixOperation<T> operation)
Pipes this matrix to a givenoperation
.<T> T
apply(MatrixVectorOperation<T> operation, Vector that)
Pipes this matrix to a givenoperation
.static DenseMatrix
block(Matrix a, Matrix b, Matrix c, Matrix d)
static DenseMatrix
constant(int rows, int columns, double constant)
Creates a constantDenseMatrix
of the given shape andvalue
.static DenseMatrix
diagonal(int size, double diagonal)
static DenseMatrix
from1DArray(int rows, int columns, double[] array)
Creates aDenseMatrix
of the given 1Darray
w/o copying the underlying array.static DenseMatrix
from2DArray(double[][] array)
Creates aDenseMatrix
of the given 2Darray
w/o copying the underlying array.static DenseMatrix
fromCSV(java.lang.String csv)
ParsesDenseMatrix
from the given CSV string.static DenseMatrix
fromMatrixMarket(java.lang.String mm)
ParsesDenseMatrix
from the given Matrix Market string.Vector
getColumn(int j)
Copies the specified column of this matrix into the vector.Vector
getRow(int i)
Copies the specified row of this matrix into the vector.static DenseMatrix
identity(int size)
Creates an identityDenseMatrix
of the givensize
.static DenseMatrix
random(int rows, int columns, java.util.Random random)
static DenseMatrix
randomSymmetric(int size, java.util.Random random)
Creates a random symmetricDenseMatrix
of the givensize
.abstract double[][]
toArray()
Converts this dense matrix to double array.java.lang.String
toMatrixMarket(java.text.NumberFormat formatter)
Converts this matrix into the Matrix Market string using the given numberformatter
.static DenseMatrix
unit(int rows, int columns)
static DenseMatrix
zero(int rows, int columns)
-
Methods inherited from class org.la4j.Matrix
add, add, blank, blankOfColumns, blankOfRows, blankOfShape, columnMajorIterator, columns, copy, copyOfColumns, copyOfRows, copyOfShape, determinant, diagonalProduct, divide, each, eachInColumn, eachInRow, ensureDimensionsAreCorrect, ensureIndexesAreInBounds, equals, equals, euclideanNorm, fail, fold, foldColumn, foldColumns, foldRow, foldRows, get, hadamardProduct, hashCode, infinityNorm, insert, insert, insert, insert, insertColumn, insertRow, is, is, iterator, iteratorOfColumn, iteratorOfRow, kroneckerProduct, manhattanNorm, max, maxInColumn, maxInRow, min, minInColumn, minInRow, mkString, mkString, mkString, multiply, multiply, multiply, multiplyByItsTranspose, non, non, norm, power, product, rank, removeColumn, removeFirstColumn, removeFirstRow, removeLastColumn, removeLastRow, removeRow, rotate, rowMajorIterator, rows, select, set, setAll, setColumn, setColumn, setRow, setRow, shuffle, slice, sliceBottomRight, sliceTopLeft, subtract, subtract, sum, swapColumns, swapRows, to, toBinary, toColumnMajorSparseMatrix, toColumnVector, toCSV, toCSV, toDenseMatrix, toMatrixMarket, toRowMajorSparseMatrix, toRowVector, toSparseMatrix, toString, trace, transform, transformColumn, transformRow, transpose, update, updateAt, updateColumn, updateRow, withDecompositor, withInverter, withSolver
-
-
-
-
Method Detail
-
zero
public static DenseMatrix zero(int rows, int columns)
-
constant
public static DenseMatrix constant(int rows, int columns, double constant)
Creates a constantDenseMatrix
of the given shape andvalue
.
-
diagonal
public static DenseMatrix diagonal(int size, double diagonal)
-
unit
public static DenseMatrix unit(int rows, int columns)
-
identity
public static DenseMatrix identity(int size)
Creates an identityDenseMatrix
of the givensize
.
-
random
public static DenseMatrix random(int rows, int columns, java.util.Random random)
-
randomSymmetric
public static DenseMatrix randomSymmetric(int size, java.util.Random random)
Creates a random symmetricDenseMatrix
of the givensize
.
-
from1DArray
public static DenseMatrix from1DArray(int rows, int columns, double[] array)
Creates aDenseMatrix
of the given 1Darray
w/o copying the underlying array.
-
from2DArray
public static DenseMatrix from2DArray(double[][] array)
Creates aDenseMatrix
of the given 2Darray
w/o copying the underlying array.
-
block
public static DenseMatrix block(Matrix a, Matrix b, Matrix c, Matrix d)
-
fromCSV
public static DenseMatrix fromCSV(java.lang.String csv)
ParsesDenseMatrix
from the given CSV string.- Parameters:
csv
- the CSV string representing a matrix- Returns:
- a parsed matrix
-
fromMatrixMarket
public static DenseMatrix fromMatrixMarket(java.lang.String mm)
ParsesDenseMatrix
from the given Matrix Market string.- Parameters:
mm
- the string in Matrix Market format- Returns:
- a parsed matrix
-
toArray
public abstract double[][] toArray()
Converts this dense matrix to double array.- Returns:
- an array representation of this matrix
-
getRow
public Vector getRow(int i)
Description copied from class:Matrix
Copies the specified row of this matrix into the vector.
-
getColumn
public Vector getColumn(int j)
Description copied from class:Matrix
Copies the specified column of this matrix into the vector.
-
apply
public <T> T apply(MatrixOperation<T> operation)
Description copied from class:Matrix
Pipes this matrix to a givenoperation
.
-
apply
public <T> T apply(MatrixMatrixOperation<T> operation, Matrix that)
Description copied from class:Matrix
Pipes this matrix to a givenoperation
.
-
apply
public <T> T apply(MatrixVectorOperation<T> operation, Vector that)
Description copied from class:Matrix
Pipes this matrix to a givenoperation
.
-
toMatrixMarket
public java.lang.String toMatrixMarket(java.text.NumberFormat formatter)
Description copied from class:Matrix
Converts this matrix into the Matrix Market string using the given numberformatter
.- Specified by:
toMatrixMarket
in classMatrix
- Returns:
- a string in Matrix Market format representing this matrix;
-
-