public class CRSMatrix extends RowMajorSparseMatrix
cardinality| Constructor and Description |
|---|
CRSMatrix() |
CRSMatrix(int rows,
int columns) |
CRSMatrix(int rows,
int columns,
int capacity) |
CRSMatrix(int rows,
int columns,
int cardinality,
double[] values,
int[] columnIndices,
int[] rowPointers) |
| Modifier and Type | Method and Description |
|---|---|
Matrix |
blankOfShape(int rows,
int columns)
Creates the blank matrix (a zero matrix with same size) of this matrix
of the given shape:
rows x columns. |
static CRSMatrix |
block(Matrix a,
Matrix b,
Matrix c,
Matrix d)
|
Matrix |
copyOfShape(int rows,
int columns)
Copies this matrix into the new matrix with specified dimensions:
rows and columns. |
static CRSMatrix |
diagonal(int size,
double diagonal)
|
void |
each(MatrixProcedure procedure)
Applies given
procedure to each element of this matrix. |
void |
eachInRow(int i,
VectorProcedure procedure)
Applies given
procedure to each element of specified row of this matrix. |
void |
eachNonZero(MatrixProcedure procedure)
Applies given
procedure to each non-zero element of this matrix. |
void |
eachNonZeroInRow(int i,
VectorProcedure procedure)
Applies the given
procedure to each non-zero element of the specified row of this matrix. |
static CRSMatrix |
from1DArray(int rows,
int columns,
double[] array)
Creates a new
CRSMatrix from the given 1D array with
compressing (copying) the underlying array. |
static CRSMatrix |
from2DArray(double[][] array)
Creates a new
CRSMatrix from the given 2D array with
compressing (copying) the underlying array. |
static CRSMatrix |
fromBinary(byte[] array)
Decodes
CRSMatrix from the given byte array. |
static CRSMatrix |
fromCSV(String csv)
Parses
CRSMatrix from the given CSV string. |
static CRSMatrix |
fromMatrixMarket(String mm)
Parses
CRSMatrix from the given Matrix Market string. |
Vector |
getColumn(int j)
Copies the specified column of this matrix into the vector.
|
double |
getOrElse(int i,
int j,
double defaultValue)
Gets the specified element, or a
defaultValue if there
is no actual element at (i, j) in this sparse matrix. |
Vector |
getRow(int i)
Copies the specified row of this matrix into the vector.
|
static CRSMatrix |
identity(int size)
Creates an identity
CRSMatrix of the given size. |
Iterator<Integer> |
iteratorOfNonZeroRows() |
VectorIterator |
iteratorOfRow(int i)
Returns a vector iterator of the given row {code i}.
|
double |
max()
Searches for the maximum value of the elements of this matrix.
|
double |
maxInRow(int i)
Searches for the maximum value of specified row in this matrix.
|
double |
min()
Searches for the minimum value of the elements of this matrix.
|
double |
minInRow(int i)
Searches for the minimum value of specified row in this matrix.
|
boolean |
nonZeroAt(int i,
int j)
Whether or not the specified element is not zero.
|
VectorIterator |
nonZeroIteratorOfRow(int i)
Returns a non-zero vector iterator of the given row
i. |
RowMajorMatrixIterator |
nonZeroRowMajorIterator()
Returns a non-zero row-major matrix iterator.
|
static CRSMatrix |
random(int rows,
int columns,
double density,
Random random)
|
static CRSMatrix |
randomSymmetric(int size,
double density,
Random random)
Creates a random symmetric
CRSMatrix of the given size. |
RowMajorMatrixIterator |
rowMajorIterator()
Returns a row-major matrix iterator.
|
Matrix |
select(int[] rowIndices,
int[] columnIndices)
Returns a CRSMatrix with the selected rows and columns.
|
void |
set(int i,
int j,
double value)
Sets the specified element of this matrix to given
value. |
void |
setAll(double value)
Sets all elements of this matrix to the given
value. |
<T extends Matrix> |
to(MatrixFactory<T> factory)
Converts this matrix using the given
factory. |
byte[] |
toBinary()
Encodes this matrix into a byte array.
|
void |
updateAt(int i,
int j,
MatrixFunction function)
Updates the specified element of this matrix by applying given
function. |
static CRSMatrix |
zero(int rows,
int columns)
|
static CRSMatrix |
zero(int rows,
int columns,
int capacity)
|
apply, apply, apply, isRowMajor, rotate, transposeadd, capacity, cardinality, density, eachNonZeroInColumn, ensureCardinalityIsCorrect, foldNonZero, foldNonZeroInColumn, foldNonZeroInColumns, foldNonZeroInRow, foldNonZeroInRows, get, isColumnMajor, isZeroAt, multiply, nonZeroColumnMajorIterator, nonZeroIterator, nonZeroIteratorOfColumn, toMatrixMarketadd, blank, blankOfColumns, blankOfRows, columnMajorIterator, columns, constant, copy, copyOfColumns, copyOfRows, determinant, diagonalProduct, divide, eachInColumn, ensureDimensionsAreCorrect, ensureIndexesAreInBounds, equals, equals, euclideanNorm, fail, fold, foldColumn, foldColumns, foldRow, foldRows, hadamardProduct, hashCode, infinityNorm, insert, insert, insert, insert, insertColumn, insertRow, is, is, iterator, iteratorOfColumn, kroneckerProduct, manhattanNorm, maxInColumn, minInColumn, mkString, mkString, mkString, multiply, multiply, multiplyByItsTranspose, non, non, norm, power, product, random, randomSymmetric, rank, removeColumn, removeFirstColumn, removeFirstRow, removeLastColumn, removeLastRow, removeRow, rows, setColumn, setColumn, setRow, setRow, shuffle, slice, sliceBottomRight, sliceTopLeft, subtract, subtract, sum, swapColumns, swapRows, toColumnMajorSparseMatrix, toColumnVector, toCSV, toCSV, toDenseMatrix, toMatrixMarket, toRowMajorSparseMatrix, toRowVector, toSparseMatrix, toString, trace, transform, transformColumn, transformRow, unit, update, updateColumn, updateRow, withDecompositor, withInverter, withSolverpublic CRSMatrix()
public CRSMatrix(int rows,
int columns)
public CRSMatrix(int rows,
int columns,
int capacity)
public CRSMatrix(int rows,
int columns,
int cardinality,
double[] values,
int[] columnIndices,
int[] rowPointers)
public static CRSMatrix zero(int rows, int columns)
public static CRSMatrix zero(int rows, int columns, int capacity)
public static CRSMatrix diagonal(int size, double diagonal)
public static CRSMatrix identity(int size)
CRSMatrix of the given size.public static CRSMatrix randomSymmetric(int size, double density, Random random)
CRSMatrix of the given size.public static CRSMatrix from1DArray(int rows, int columns, double[] array)
CRSMatrix from the given 1D array with
compressing (copying) the underlying array.public static CRSMatrix from2DArray(double[][] array)
CRSMatrix from the given 2D array with
compressing (copying) the underlying array.public static CRSMatrix fromBinary(byte[] array)
CRSMatrix from the given byte array.array - the byte array representing a matrixpublic static CRSMatrix fromCSV(String csv)
CRSMatrix from the given CSV string.csv - the CSV string representing a matrixpublic static CRSMatrix fromMatrixMarket(String mm)
CRSMatrix from the given Matrix Market string.mm - the string in Matrix Market formatpublic double getOrElse(int i,
int j,
double defaultValue)
SparseMatrixdefaultValue if there
is no actual element at (i, j) in this sparse matrix.getOrElse in class SparseMatrixi - the element's row indexj - the element's column indexdefaultValue - the default valuepublic void set(int i,
int j,
double value)
Matrixvalue.public void setAll(double value)
Matrixvalue.public Vector getRow(int i)
MatrixgetRow in class SparseMatrixi - the row indexpublic Vector getColumn(int j)
MatrixgetColumn in class SparseMatrixj - the column indexpublic Matrix copyOfShape(int rows, int columns)
Matrixrows and columns.copyOfShape in class Matrixrows - the number of rows in new matrixcolumns - the number of columns in new matrixpublic void eachNonZero(MatrixProcedure procedure)
SparseMatrixprocedure to each non-zero element of this matrix.eachNonZero in class SparseMatrixprocedure - the matrix procedurepublic void each(MatrixProcedure procedure)
Matrixprocedure to each element of this matrix.public void eachInRow(int i,
VectorProcedure procedure)
Matrixprocedure to each element of specified row of this matrix.public void eachNonZeroInRow(int i,
VectorProcedure procedure)
SparseMatrixprocedure to each non-zero element of the specified row of this matrix.eachNonZeroInRow in class SparseMatrixi - the row index.procedure - the VectorProcedure.public void updateAt(int i,
int j,
MatrixFunction function)
Matrixfunction.public boolean nonZeroAt(int i,
int j)
SparseMatrixnonZeroAt in class SparseMatrixi - element's row indexj - element's column indextrue if specified element is not zero, false otherwisepublic double max()
Matrixpublic double min()
Matrixpublic double maxInRow(int i)
Matrixpublic double minInRow(int i)
Matrixpublic Matrix select(int[] rowIndices, int[] columnIndices)
public <T extends Matrix> T to(MatrixFactory<T> factory)
Matrixfactory.public Matrix blankOfShape(int rows, int columns)
Matrixrows x columns.blankOfShape in class Matrixpublic Iterator<Integer> iteratorOfNonZeroRows()
iteratorOfNonZeroRows in class RowMajorSparseMatrixpublic RowMajorMatrixIterator rowMajorIterator()
MatrixrowMajorIterator in class Matrixpublic RowMajorMatrixIterator nonZeroRowMajorIterator()
SparseMatrixnonZeroRowMajorIterator in class SparseMatrixpublic VectorIterator nonZeroIteratorOfRow(int i)
SparseMatrixi.nonZeroIteratorOfRow in class SparseMatrixpublic VectorIterator iteratorOfRow(int i)
MatrixiteratorOfRow in class MatrixCopyright © 2015. All rights reserved.