Class Matrix
java.lang.Object
org.la4j.Matrix
- Direct Known Subclasses:
DenseMatrix, SparseMatrix
A real matrix.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprivate static final Stringprivate static final NumberFormatprivate static final Stringprivate static final String[]protected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double value) Adds givenvalue(v) to every element of this matrix (A).Adds giventhatmatrix (B) to this matrix (A).abstract <T> Tapply(MatrixMatrixOperation<T> operation, Matrix that) Pipes this matrix to a givenoperation.abstract <T> Tapply(MatrixOperation<T> operation) Pipes this matrix to a givenoperation.abstract <T> Tapply(MatrixVectorOperation<T> operation, Vector that) Pipes this matrix to a givenoperation.blank()Creates the blank matrix (a zero matrix with same size) of this matrix.blankOfColumns(int columns) Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:columns.blankOfRows(int rows) Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rows.abstract MatrixblankOfShape(int rows, int columns) Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rowsxcolumns.static MatrixReturns a column-major matrix iterator.intcolumns()Returns the number of columns of this matrix.static Matrixconstant(int rows, int columns, double constant) Creates a constantMatrixof the given shape andvalue.copy()Copies this matrix.copyOfColumns(int columns) Copies this matrix into the new matrix with specified column dimension:columns.copyOfRows(int rows) Copies this matrix into the new matrix with specified row dimension:rows.abstract MatrixcopyOfShape(int rows, int columns) Copies this matrix into the new matrix with specified dimensions:rowsandcolumns.doubleCalculates the determinant of this matrix.static Matrixdiagonal(int size, double diagonal) doubleCalculates the product of diagonal elements of this matrix.divide(double value) Divides every element of this matrix (A) by givenvalue(v).voideach(MatrixProcedure procedure) Applies givenprocedureto each element of this matrix.voideachInColumn(int j, VectorProcedure procedure) Applies givenprocedureto each element of specified column of this matrix.voideachInRow(int i, VectorProcedure procedure) Applies givenprocedureto each element of specified row of this matrix.protected voidensureDimensionsAreCorrect(int rows, int columns) protected voidensureIndexesAreInBounds(int i, int j) booleanbooleanReturns true when matrix is equal to givenmatrixwith givenprecisiondoubleCalculates an Euclidean norm of this matrix, a.k.a.protected voiddoublefold(MatrixAccumulator accumulator) Folds all elements of this matrix with givenaccumulator.doublefoldColumn(int j, VectorAccumulator accumulator) Folds all elements of specified column in this matrix with givenaccumulator.double[]foldColumns(VectorAccumulator accumulator) Folds all elements (in a column-by-column manner) of this matrix with givenaccumulator.doublefoldRow(int i, VectorAccumulator accumulator) Folds all elements of specified row in this matrix with givenaccumulator.double[]foldRows(VectorAccumulator accumulator) Folds all elements (in row-by-row manner) of this matrix with givenaccumulator.static Matrixfrom1DArray(int rows, int columns, double[] array) Creates aMatrixof the given 1Darrayw/o copying the underlying array.static Matrixfrom2DArray(double[][] array) Creates aMatrixof the given 2Darrayw/o copying the underlying array.static MatrixParsesMatrixfrom the given CSV string.static MatrixParsesMatrixfrom the given Matrix Market string.abstract doubleget(int i, int j) Gets the specified element of this matrix.abstract VectorgetColumn(int j) Copies the specified column of this matrix into the vector.abstract VectorgetRow(int i) Copies the specified row of this matrix into the vector.hadamardProduct(Matrix that) Calculates the Hadamard (element-wise) product of this and giventhatmatrix.inthashCode()static Matrixidentity(int size) Creates an identityMatrixof the givensize.private voidindent(StringBuilder sb, int howMany) doubleCalculates an Infinity norm of this matrix.Inserts a giventhat(B) into this matrix (A).Inserts a giventhatmatrix (B) into this matrix (A).Inserts a giventhatmatrix (B) into this matrix (A).Inserts a giventhatmatrix (B) into this matrix (A).insertColumn(int j, Vector column) Adds one column to matrix.Adds one row to matrix.booleanis(AdvancedMatrixPredicate predicate) Checks whether this matrix compiles with givenpredicateor not.booleanis(MatrixPredicate predicate) Checks whether this matrix compiles with givenpredicateor not.iterator()Returns a matrix iterator.iteratorOfColumn(int j) Returns a vector iterator of the given column {code j}.iteratorOfRow(int i) Returns a vector iterator of the given row {code i}.kroneckerProduct(Matrix that) Calculates the Kronecker product of this matrix (A) and giventhatmatrix (B).doubleCalculates a Manhattan norm of this matrix, a.k.a.doublemax()Searches for the maximum value of the elements of this matrix.doublemaxInColumn(int j) Searches for the maximum value of specified column in this matrix.doublemaxInRow(int i) Searches for the maximum value of specified row in this matrix.doublemin()Searches for the minimum value of the elements of this matrix.doubleminInColumn(int j) Searches for the minimum value of specified column in this matrix.doubleminInRow(int i) Searches for the minimum value of specified row in this matrix.Converts this matrix into the string representation.mkString(NumberFormat formatter) Converts this matrix into the string representation.mkString(NumberFormat formatter, String rowsDelimiter, String columnsDelimiter) Converts this matrix into the string representation.multiply(double value) Scales this matrix by givenvalue(v).Multiplies this matrix (A) by giventhatmatrix (B).Multiplies this matrix (A) by giventhatvector (x).Multiplies this matrix by its transpose.booleannon(AdvancedMatrixPredicate predicate) Checks whether this matrix compiles with givenpredicateor not.booleannon(MatrixPredicate predicate) Checks whether this matrix compiles with givenpredicateor not.doublenorm()Calculates an Euclidean norm of this matrix, a.k.a.power(int n) Powers this matrix of given exponent {code n}.doubleproduct()Multiplies up all elements of this matrix.static Matrixstatic MatrixrandomSymmetric(int size, Random random) Creates a random symmetricMatrixof the givensize.intrank()Calculates the rank of this matrix.removeColumn(int j) Removes one column from matrix.Removes first column from matrix.Removes first row from matrix.Removes last column from matrix.Removes last row from matrix.removeRow(int i) Removes one row from matrix.rotate()Rotates this matrix by 90 degrees to the right.Returns a row-major matrix iterator.introws()Returns the number of rows of this matrix.select(int[] rowIndices, int[] columnIndices) Returns a new matrix with the selected rows and columns.abstract voidset(int i, int j, double value) Sets the specified element of this matrix to givenvalue.voidsetAll(double value) Sets all elements of this matrix to the givenvalue.voidsetColumn(int j, double value) Sets all elements of the specified column of this matrix to givenvalue.voidCopies givencolumninto the specified column of this matrix.voidsetRow(int i, double value) Sets all elements of the specified row of this matrix to givenvalue.voidCopies givenrowinto the specified row of this matrix.shuffle()Shuffles this matrix.slice(int fromRow, int fromColumn, int untilRow, int untilColumn) Retrieves the specified sub-matrix of this matrix.sliceBottomRight(int fromRow, int fromColumn) Retrieves the specified sub-matrix of this matrix.sliceTopLeft(int untilRow, int untilColumn) Retrieves the specified sub-matrix of this matrix.subtract(double value) Subtracts givenvalue(v) from every element of this matrix (A).Subtracts giventhatmatrix (B) from this matrix (A).doublesum()Summarizes up all elements of this matrix.voidswapColumns(int i, int j) Swaps the specified columns of this matrix.voidswapRows(int i, int j) Swaps the specified rows of this matrix.<T extends Matrix>
Tto(MatrixFactory<T> factory) Converts this matrix using the givenfactory.abstract byte[]toBinary()Encodes this matrix into a byte array.Converts this matrix into a column-major sparse matrix.Converts this matrix into the column vector.toCSV()Converts this matrix into the CSV (Comma Separated Value) string.toCSV(NumberFormat formatter) Converts this matrix into the CSV (Comma Separated Value) string using the givenformatter.Converts this matrix into a dense matrix.Converts this matrix into the Matrix Market string.abstract StringtoMatrixMarket(NumberFormat formatter) Converts this matrix into the Matrix Market string using the given numberformatter.Converts this matrix into a row-major sparse matrix.Converts this matrix into the row vector.Converts this matrix into a sparse matrix.toString()doubletrace()Calculates the trace of this matrix.transform(MatrixFunction function) Builds a new matrix by applying givenfunctionto each element of this matrix.transformColumn(int j, VectorFunction function) Builds a new matrix by applying givenfunctionto each element of specified column in this matrix.transformRow(int i, VectorFunction function) Builds a new matrix by applying givenfunctionto each element of specified row in this matrix.Transposes this matrix.static Matrixunit(int rows, int columns) voidupdate(MatrixFunction function) Updates all elements of this matrix by applying givenfunction.voidupdateAt(int i, int j, MatrixFunction function) Updates the specified element of this matrix by applying givenfunction.voidupdateColumn(int j, VectorFunction function) Updates all elements of the specified column in this matrix by applying givenfunction.voidupdateRow(int i, VectorFunction function) Updates all elements of the specified row in this matrix by applying givenfunction.Creates a new decompositor by givenfactoryof this matrix.Creates a new inverter by givenfactoryof this matrix.withSolver(LinearAlgebra.SolverFactory factory) Creates a new solver by givenfactoryof this matrix.static Matrixzero(int rows, int columns) Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_ROWS_DELIMITER
- See Also:
-
DEFAULT_COLUMNS_DELIMITER
- See Also:
-
DEFAULT_FORMATTER
-
INDENTS
-
rows
protected int rows -
columns
protected int columns
-
-
Constructor Details
-
Matrix
public Matrix()Creates a zero-shape matrix. -
Matrix
public Matrix(int rows, int columns) Creates a matrix of given shaperowsxcolumns;
-
-
Method Details
-
zero
-
constant
-
diagonal
-
unit
-
identity
-
random
-
randomSymmetric
-
from1DArray
-
from2DArray
-
block
-
fromCSV
-
fromMatrixMarket
-
get
public abstract double get(int i, int j) Gets the specified element of this matrix.- Parameters:
i- element's row indexj- element's column index- Returns:
- the element of this matrix
-
set
public abstract void set(int i, int j, double value) Sets the specified element of this matrix to givenvalue.- Parameters:
i- element's row indexj- element's column indexvalue- element's new value
-
getRow
Copies the specified row of this matrix into the vector.- Parameters:
i- the row index- Returns:
- the row represented as vector
-
getColumn
Copies the specified column of this matrix into the vector.- Parameters:
j- the column index- Returns:
- the column represented as vector
-
blankOfShape
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rowsxcolumns.- Returns:
- blank matrix
-
copyOfShape
Copies this matrix into the new matrix with specified dimensions:rowsandcolumns.- Parameters:
rows- the number of rows in new matrixcolumns- the number of columns in new matrix- Returns:
- the copy of this matrix with new size
-
apply
Pipes this matrix to a givenoperation.- Type Parameters:
T- the result type- Parameters:
operation- the matrix operation (an operation that takes a matrix and returnsT)- Returns:
- the result of an operation applied to this matrix
-
apply
Pipes this matrix to a givenoperation.- Type Parameters:
T- the result type- Parameters:
operation- the matrix-matrix operation (an operation that takes two matrices and returnsT)that- the right hand matrix of the given operation- Returns:
- the result of an operation applied to this matrix
-
apply
Pipes this matrix to a givenoperation.- Type Parameters:
T- the result type- Parameters:
operation- the matrix-vector operation (an operation that takes matrix and vector and returnsT)that- the right hand vector of the given operation- Returns:
- the result of an operation applied to this matrix
-
toBinary
public abstract byte[] toBinary()Encodes this matrix into a byte array.- Returns:
- a byte array representing this matrix
-
toMatrixMarket
Converts this matrix into the Matrix Market string using the given numberformatter.- Returns:
- a string in Matrix Market format representing this matrix;
-
setAll
public void setAll(double value) Sets all elements of this matrix to the givenvalue.- Parameters:
value- the element's new value
-
setRow
public void setRow(int i, double value) Sets all elements of the specified row of this matrix to given
value.- Parameters:
i- the row indexvalue- the element's new value
-
setColumn
public void setColumn(int j, double value) Sets all elements of the specified column of this matrix to given
value.- Parameters:
j- the column indexvalue- the element's new value
-
swapRows
public void swapRows(int i, int j) Swaps the specified rows of this matrix.- Parameters:
i- the row indexj- the row index
-
swapColumns
public void swapColumns(int i, int j) Swaps the specified columns of this matrix.- Parameters:
i- the column indexj- the column index
-
rows
public int rows()Returns the number of rows of this matrix.- Returns:
- the number of rows
-
columns
public int columns()Returns the number of columns of this matrix.- Returns:
- the number of columns
-
transpose
-
rotate
-
power
Powers this matrix of given exponent {code n}.- Parameters:
n- the exponent- Returns:
- the powered matrix
-
multiply
Scales this matrix by givenvalue(v).- Parameters:
value- the scale factor- Returns:
- A * v
-
multiply
-
multiply
-
multiplyByItsTranspose
Multiplies this matrix by its transpose.- Returns:
- this matrix multiplied by its transpose
-
subtract
Subtracts givenvalue(v) from every element of this matrix (A).- Parameters:
value- the right hand value for subtraction- Returns:
- A - v
-
subtract
-
add
Adds givenvalue(v) to every element of this matrix (A).- Parameters:
value- the right hand value for addition- Returns:
- A + v
-
add
-
insert
-
insert
Inserts a giventhatmatrix (B) into this matrix (A). The original values are overwritten by the new ones.- Parameters:
that- the matrix to insertrows- number of rows to insertcolumns- number of columns to insert- Returns:
- a matrix with the parameter inserted into it
-
insert
Inserts a giventhatmatrix (B) into this matrix (A). The original values are overwritten by the new ones.- Parameters:
that- the matrix to insertdestRow- the row to insert at in the destination matrixdestColumn- the column to insert at in the destination matrixrows- number of rows to insertcolumns- number of columns to insert- Returns:
- a matrix with the parameter inserted into it
-
insert
public Matrix insert(Matrix that, int srcRow, int srcColumn, int destRow, int destColumn, int rows, int columns) Inserts a giventhatmatrix (B) into this matrix (A). The original values are overwritten by the new ones.- Parameters:
that- the matrix to insertsrcRow- the row to start at in the source matrixsrcColumn- the column to start at in the source matrixdestRow- the row to insert at in the destination matrixdestColumn- the column to insert at in the destination matrixrows- number of rows to insertcolumns- number of columns to insert- Returns:
- a matrix with the parameter inserted into it
-
divide
Divides every element of this matrix (A) by givenvalue(v).- Parameters:
value- the right hand value for division- Returns:
- A / v
-
kroneckerProduct
-
trace
public double trace()Calculates the trace of this matrix.See http://mathworld.wolfram.com/MatrixTrace.html for more details.
- Returns:
- the trace of this matrix
-
diagonalProduct
public double diagonalProduct()Calculates the product of diagonal elements of this matrix.- Returns:
- the product of diagonal elements of this matrix
-
norm
public double norm()Calculates an Euclidean norm of this matrix, a.k.a. frobenius norm- Returns:
- an Euclidean norm
-
euclideanNorm
public double euclideanNorm()Calculates an Euclidean norm of this matrix, a.k.a. frobenius norm- Returns:
- an Euclidean norm
-
manhattanNorm
public double manhattanNorm()Calculates a Manhattan norm of this matrix, a.k.a. taxicab norm- Returns:
- a Manhattan norm
-
infinityNorm
public double infinityNorm()Calculates an Infinity norm of this matrix.- Returns:
- an Infinity norm
-
product
public double product()Multiplies up all elements of this matrix.- Returns:
- the product of all elements of this matrix
-
sum
public double sum()Summarizes up all elements of this matrix.- Returns:
- the sum of all elements of this matrix
-
hadamardProduct
-
determinant
public double determinant()Calculates the determinant of this matrix.See http://mathworld.wolfram.com/Determinant.html for more details.
- Returns:
- the determinant of this matrix
-
rank
public int rank()Calculates the rank of this matrix.See http://mathworld.wolfram.com/MatrixRank.html for more details.
- Returns:
- the rank of this matrix
-
setRow
Copies givenrowinto the specified row of this matrix.- Parameters:
i- the row indexrow- the row represented as vector
-
setColumn
Copies givencolumninto the specified column of this matrix.- Parameters:
j- the column indexcolumn- the column represented as vector
-
insertRow
-
insertColumn
-
removeRow
Removes one row from matrix.- Parameters:
i- the row index- Returns:
- matrix without row.
-
removeColumn
Removes one column from matrix.- Parameters:
j- the column index- Returns:
- matrix without column.
-
removeFirstRow
-
removeFirstColumn
Removes first column from matrix.- Returns:
- matrix without first column
-
removeLastRow
-
removeLastColumn
Removes last column from matrix.- Returns:
- matrix without last column
-
blank
Creates the blank matrix (a zero matrix with same size) of this matrix.- Returns:
- blank matrix
-
blankOfRows
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:rows. Thecolumnsnumber remains the same.- Returns:
- blank matrix
-
blankOfColumns
Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape:columns. Therowsnumber remains the same.- Returns:
- blank matrix
-
copy
-
copyOfRows
Copies this matrix into the new matrix with specified row dimension:rows.- Parameters:
rows- the number of rows in new matrix- Returns:
- the copy of this matrix with new size
-
copyOfColumns
Copies this matrix into the new matrix with specified column dimension:columns.- Parameters:
columns- the number of columns in new matrix- Returns:
- the copy of this matrix with new size
-
shuffle
Shuffles this matrix.Copies this matrix into the matrix that contains the same elements but with the elements shuffled around (which might also result in the same matrix (with a small likelihood)).
- Returns:
- the shuffled matrix
-
slice
Retrieves the specified sub-matrix of this matrix. The sub-matrix is specified by intervals for row indices and column indices.- Parameters:
fromRow- the beginning of the row indices intervalfromColumn- the beginning of the column indices intervaluntilRow- the ending of the row indices intervaluntilColumn- the ending of the column indices interval- Returns:
- the sub-matrix of this matrix
-
sliceTopLeft
Retrieves the specified sub-matrix of this matrix. The sub-matrix is specified by intervals for row indices and column indices. The top left points of both intervals are fixed to zero.- Parameters:
untilRow- the ending of the row indices intervaluntilColumn- the ending of the column indices interval- Returns:
- the sub-matrix of this matrix
-
sliceBottomRight
Retrieves the specified sub-matrix of this matrix. The sub-matrix is specified by intervals for row indices and column indices. The bottom right points of both intervals are fixed to matrix dimensions - it's rows and columns correspondingly.- Parameters:
fromRow- the beginning of the row indices intervalfromColumn- the beginning of the column indices interval- Returns:
- the sub-matrix of this matrix
-
select
Returns a new matrix with the selected rows and columns. This method can be used either return a specific subset of rows and/or columns or to permute the indices in an arbitrary order. The list of indices are allowed to contain duplicates indices. This is more general than slice() which selects only contiguous blocks. However, where applicable slice() is probably more efficient.- Parameters:
rowIndices- the array of row indicescolumnIndices- the array of column indices- Returns:
- the new matrix with the selected rows and columns
- Throws:
IllegalArgumentException- if invalid row or column indices are provided
-
each
Applies givenprocedureto each element of this matrix.- Parameters:
procedure- the matrix procedure
-
eachInRow
Applies givenprocedureto each element of specified row of this matrix.- Parameters:
i- the row indexprocedure- the vector procedure
-
eachInColumn
Applies givenprocedureto each element of specified column of this matrix.- Parameters:
j- the column indexprocedure- the vector procedure
-
max
public double max()Searches for the maximum value of the elements of this matrix.- Returns:
- maximum value of this matrix
-
min
public double min()Searches for the minimum value of the elements of this matrix.- Returns:
- minimum value of this matrix
-
maxInRow
public double maxInRow(int i) Searches for the maximum value of specified row in this matrix.- Parameters:
i- the row index- Returns:
- maximum value of specified row in this matrix
-
minInRow
public double minInRow(int i) Searches for the minimum value of specified row in this matrix.- Parameters:
i- the row index- Returns:
- minimum value of specified row in this matrix
-
maxInColumn
public double maxInColumn(int j) Searches for the maximum value of specified column in this matrix.- Parameters:
j- the column index- Returns:
- maximum value of specified column in this matrix
-
minInColumn
public double minInColumn(int j) Searches for the minimum value of specified column in this matrix.- Parameters:
j- the column index- Returns:
- minimum value of specified column in this matrix
-
transform
Builds a new matrix by applying givenfunctionto each element of this matrix.- Parameters:
function- the matrix function- Returns:
- the transformed matrix
-
transformRow
Builds a new matrix by applying givenfunctionto each element of specified row in this matrix.- Parameters:
i- the row indexfunction- the vector function- Returns:
- the transformed matrix
-
transformColumn
Builds a new matrix by applying givenfunctionto each element of specified column in this matrix.- Parameters:
j- the column indexfunction- the vector function- Returns:
- the transformed matrix
-
update
Updates all elements of this matrix by applying givenfunction.- Parameters:
function- the matrix function
-
updateAt
Updates the specified element of this matrix by applying givenfunction.- Parameters:
i- the row indexj- the column indexfunction- the matrix function
-
updateRow
Updates all elements of the specified row in this matrix by applying givenfunction.- Parameters:
i- the row indexfunction- the vector function
-
updateColumn
Updates all elements of the specified column in this matrix by applying givenfunction.- Parameters:
j- the column indexfunction- the vector function
-
fold
Folds all elements of this matrix with givenaccumulator.- Parameters:
accumulator- the matrix accumulator- Returns:
- the accumulated value
-
foldRow
Folds all elements of specified row in this matrix with givenaccumulator.- Parameters:
i- the row indexaccumulator- the vector accumulator- Returns:
- the accumulated value
-
foldRows
Folds all elements (in row-by-row manner) of this matrix with givenaccumulator.- Parameters:
accumulator- the vector accumulator- Returns:
- the accumulated double array
-
foldColumn
Folds all elements of specified column in this matrix with givenaccumulator.- Parameters:
j- the column indexaccumulator- the vector accumulator- Returns:
- the accumulated value
-
foldColumns
Folds all elements (in a column-by-column manner) of this matrix with givenaccumulator.- Parameters:
accumulator- the vector accumulator- Returns:
- the accumulated double array
-
is
Checks whether this matrix compiles with givenpredicateor not.- Parameters:
predicate- the matrix predicate- Returns:
- whether this matrix compiles with predicate
-
is
Checks whether this matrix compiles with givenpredicateor not.- Parameters:
predicate- the advanced matrix predicate- Returns:
- whether this matrix compiles with predicate
-
non
Checks whether this matrix compiles with givenpredicateor not.- Parameters:
predicate- the matrix predicate- Returns:
- whether this matrix compiles with predicate
-
non
Checks whether this matrix compiles with givenpredicateor not.- Parameters:
predicate- the advanced matrix predicate- Returns:
- whether this matrix compiles with predicate
-
toRowVector
Converts this matrix into the row vector.- Returns:
- the row vector of this matrix
-
toColumnVector
Converts this matrix into the column vector.- Returns:
- the column vector of this matrix
-
withSolver
Creates a new solver by givenfactoryof this matrix.- Parameters:
factory- the solver factory- Returns:
- the linear system solver of this matrix
-
withInverter
Creates a new inverter by givenfactoryof this matrix.- Parameters:
factory- the inverter factory- Returns:
- the inverter of this matrix
-
withDecompositor
Creates a new decompositor by givenfactoryof this matrix.- Parameters:
factory- the decompositor factory- Returns:
- the decompositor of this matrix
-
equals
Returns true when matrix is equal to givenmatrixwith givenprecision- Parameters:
matrix- matrixprecision- given precision- Returns:
- equals of this matrix to that
-
mkString
Converts this matrix into the string representation.- Parameters:
formatter- the number formatter- Returns:
- the matrix converted to a string
-
mkString
-
mkString
Converts this matrix into the string representation.- Parameters:
formatter- the number formatterrowsDelimiter- the rows' delimitercolumnsDelimiter- the columns' delimiter- Returns:
- the matrix converted to a string
-
toString
-
iterator
Returns a matrix iterator. -
rowMajorIterator
Returns a row-major matrix iterator.- Returns:
- a row-major matrix iterator.
-
columnMajorIterator
Returns a column-major matrix iterator.- Returns:
- a column-major matrix iterator.
-
iteratorOfRow
Returns a vector iterator of the given row {code i}.- Returns:
- a vector iterator
-
iteratorOfColumn
Returns a vector iterator of the given column {code j}.- Returns:
- a vector iterator
-
hashCode
-
equals
-
to
Converts this matrix using the givenfactory.- Type Parameters:
T- type of the result matrix- Parameters:
factory- the factory that creates an output matrix- Returns:
- converted matrix
-
toSparseMatrix
Converts this matrix into a sparse matrix.- Returns:
- a sparse matrix
-
toDenseMatrix
Converts this matrix into a dense matrix.- Returns:
- a dense matrix
-
toRowMajorSparseMatrix
Converts this matrix into a row-major sparse matrix.- Returns:
- a row-major sparse matrix
-
toColumnMajorSparseMatrix
Converts this matrix into a column-major sparse matrix.- Returns:
- a row-major sparse matrix
-
toCSV
Converts this matrix into the CSV (Comma Separated Value) string.- Returns:
- a CSV string representing this matrix
-
toMatrixMarket
Converts this matrix into the Matrix Market string.- Returns:
- a string in Matrix Market format representing this matrix;
-
toCSV
Converts this matrix into the CSV (Comma Separated Value) string using the givenformatter.- Parameters:
formatter- the number formatter- Returns:
- a CSV string representing this matrix
-
ensureDimensionsAreCorrect
protected void ensureDimensionsAreCorrect(int rows, int columns) -
ensureIndexesAreInBounds
protected void ensureIndexesAreInBounds(int i, int j) -
fail
-
indent
-