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, transpose
add, capacity, cardinality, density, eachNonZeroInColumn, ensureCardinalityIsCorrect, foldNonZero, foldNonZeroInColumn, foldNonZeroInColumns, foldNonZeroInRow, foldNonZeroInRows, get, isColumnMajor, isZeroAt, multiply, nonZeroColumnMajorIterator, nonZeroIterator, nonZeroIteratorOfColumn, toMatrixMarket
add, 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, withSolver
public 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)
SparseMatrix
defaultValue
if there
is no actual element at (i
, j
) in this sparse matrix.getOrElse
in class SparseMatrix
i
- the element's row indexj
- the element's column indexdefaultValue
- the default valuepublic void set(int i, int j, double value)
Matrix
value
.public void setAll(double value)
Matrix
value
.public Vector getRow(int i)
Matrix
getRow
in class SparseMatrix
i
- the row indexpublic Vector getColumn(int j)
Matrix
getColumn
in class SparseMatrix
j
- the column indexpublic Matrix copyOfShape(int rows, int columns)
Matrix
rows
and columns
.copyOfShape
in class Matrix
rows
- the number of rows in new matrixcolumns
- the number of columns in new matrixpublic void eachNonZero(MatrixProcedure procedure)
SparseMatrix
procedure
to each non-zero element of this matrix.eachNonZero
in class SparseMatrix
procedure
- the matrix procedurepublic void each(MatrixProcedure procedure)
Matrix
procedure
to each element of this matrix.public void eachInRow(int i, VectorProcedure procedure)
Matrix
procedure
to each element of specified row of this matrix.public void eachNonZeroInRow(int i, VectorProcedure procedure)
SparseMatrix
procedure
to each non-zero element of the specified row of this matrix.eachNonZeroInRow
in class SparseMatrix
i
- the row index.procedure
- the VectorProcedure
.public void updateAt(int i, int j, MatrixFunction function)
Matrix
function
.public boolean nonZeroAt(int i, int j)
SparseMatrix
nonZeroAt
in class SparseMatrix
i
- element's row indexj
- element's column indextrue
if specified element is not zero, false
otherwisepublic double max()
Matrix
public double min()
Matrix
public double maxInRow(int i)
Matrix
public double minInRow(int i)
Matrix
public Matrix select(int[] rowIndices, int[] columnIndices)
public <T extends Matrix> T to(MatrixFactory<T> factory)
Matrix
factory
.public Matrix blankOfShape(int rows, int columns)
Matrix
rows
x columns
.blankOfShape
in class Matrix
public Iterator<Integer> iteratorOfNonZeroRows()
iteratorOfNonZeroRows
in class RowMajorSparseMatrix
public RowMajorMatrixIterator rowMajorIterator()
Matrix
rowMajorIterator
in class Matrix
public RowMajorMatrixIterator nonZeroRowMajorIterator()
SparseMatrix
nonZeroRowMajorIterator
in class SparseMatrix
public VectorIterator nonZeroIteratorOfRow(int i)
SparseMatrix
i
.nonZeroIteratorOfRow
in class SparseMatrix
public VectorIterator iteratorOfRow(int i)
Matrix
iteratorOfRow
in class Matrix
Copyright © 2015. All rights reserved.