public class CCSMatrix extends ColumnMajorSparseMatrix
cardinality
Constructor and Description |
---|
CCSMatrix() |
CCSMatrix(int rows,
int columns) |
CCSMatrix(int rows,
int columns,
int capacity) |
CCSMatrix(int rows,
int columns,
int cardinality,
double[] values,
int[] rowIndices,
int[] columnPointers) |
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 CCSMatrix |
block(Matrix a,
Matrix b,
Matrix c,
Matrix d)
|
ColumnMajorMatrixIterator |
columnMajorIterator()
Returns a column-major matrix iterator.
|
Matrix |
copyOfShape(int rows,
int columns)
Copies this matrix into the new matrix with specified dimensions:
rows and columns . |
static CCSMatrix |
diagonal(int size,
double diagonal)
|
void |
each(MatrixProcedure procedure)
Applies given
procedure to each element of this matrix. |
void |
eachInColumn(int j,
VectorProcedure procedure)
Applies given
procedure to each element of specified column of this matrix. |
void |
eachNonZero(MatrixProcedure procedure)
Applies given
procedure to each non-zero element of this matrix. |
void |
eachNonZeroInColumn(int j,
VectorProcedure procedure)
Applies the given
procedure to each non-zero element of the specified column of this matrix. |
static CCSMatrix |
from1DArray(int rows,
int columns,
double[] array)
Creates a new
CCSMatrix from the given 1D array with
compressing (copying) the underlying array. |
static CCSMatrix |
from2DArray(double[][] array)
Creates a new
CCSMatrix from the given 2D array with
compressing (copying) the underlying array. |
static CCSMatrix |
fromBinary(byte[] array)
Decodes
CCSMatrix from the given byte array . |
static CCSMatrix |
fromCSV(String csv)
Parses
CCSMatrix from the given CSV string. |
static CCSMatrix |
fromMatrixMarket(String mm)
Parses
CCSMatrix 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 CCSMatrix |
identity(int size)
Creates an identity
CCSMatrix of the given size . |
VectorIterator |
iteratorOfColumn(int j)
Returns a vector iterator of the given column {code j}.
|
Iterator<Integer> |
iteratorOrNonZeroColumns() |
double |
max()
Searches for the maximum value of the elements of this matrix.
|
double |
maxInColumn(int j)
Searches for the maximum value of specified column in this matrix.
|
double |
min()
Searches for the minimum value of the elements of this matrix.
|
double |
minInColumn(int j)
Searches for the minimum value of specified column in this matrix.
|
boolean |
nonZeroAt(int i,
int j)
Whether or not the specified element is not zero.
|
ColumnMajorMatrixIterator |
nonZeroColumnMajorIterator()
Returns a non-zero column-major matrix iterator.
|
VectorIterator |
nonZeroIteratorOfColumn(int j)
Returns a non-zero vector iterator of the given column
j . |
static CCSMatrix |
random(int rows,
int columns,
double density,
Random random)
|
static CCSMatrix |
randomSymmetric(int size,
double density,
Random random)
Creates a random symmetric
CCSMatrix of the given size . |
Matrix |
select(int[] rowIndices,
int[] columnIndices)
Returns a CCSMatrix 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 CCSMatrix |
zero(int rows,
int columns)
|
static CCSMatrix |
zero(int rows,
int columns,
int capacity)
|
apply, apply, apply, isRowMajor, iterator, nonZeroIterator, rotate, transpose
add, capacity, cardinality, density, eachNonZeroInRow, ensureCardinalityIsCorrect, foldNonZero, foldNonZeroInColumn, foldNonZeroInColumns, foldNonZeroInRow, foldNonZeroInRows, get, isColumnMajor, isZeroAt, multiply, nonZeroIteratorOfRow, nonZeroRowMajorIterator, toMatrixMarket
add, blank, blankOfColumns, blankOfRows, columns, constant, copy, copyOfColumns, copyOfRows, determinant, diagonalProduct, divide, eachInRow, ensureDimensionsAreCorrect, ensureIndexesAreInBounds, equals, equals, euclideanNorm, fail, fold, foldColumn, foldColumns, foldRow, foldRows, hadamardProduct, hashCode, infinityNorm, insert, insert, insert, insert, insertColumn, insertRow, is, is, iteratorOfRow, kroneckerProduct, manhattanNorm, maxInRow, minInRow, mkString, mkString, mkString, multiply, multiply, multiplyByItsTranspose, non, non, norm, power, product, random, randomSymmetric, rank, removeColumn, removeFirstColumn, removeFirstRow, removeLastColumn, removeLastRow, removeRow, rowMajorIterator, 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 CCSMatrix()
public CCSMatrix(int rows, int columns)
public CCSMatrix(int rows, int columns, int capacity)
public CCSMatrix(int rows, int columns, int cardinality, double[] values, int[] rowIndices, int[] columnPointers)
public static CCSMatrix zero(int rows, int columns)
public static CCSMatrix zero(int rows, int columns, int capacity)
public static CCSMatrix diagonal(int size, double diagonal)
public static CCSMatrix identity(int size)
CCSMatrix
of the given size
.public static CCSMatrix randomSymmetric(int size, double density, Random random)
CCSMatrix
of the given size
.public static CCSMatrix from1DArray(int rows, int columns, double[] array)
CCSMatrix
from the given 1D array
with
compressing (copying) the underlying array.public static CCSMatrix from2DArray(double[][] array)
CCSMatrix
from the given 2D array
with
compressing (copying) the underlying array.public static CCSMatrix fromBinary(byte[] array)
CCSMatrix
from the given byte array
.array
- the byte array representing a matrixpublic static CCSMatrix fromCSV(String csv)
CCSMatrix
from the given CSV string.csv
- the CSV string representing a matrixpublic static CCSMatrix fromMatrixMarket(String mm)
CCSMatrix
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 getColumn(int j)
Matrix
getColumn
in class SparseMatrix
j
- the column indexpublic Vector getRow(int i)
Matrix
getRow
in class SparseMatrix
i
- the row 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 eachInColumn(int j, VectorProcedure procedure)
Matrix
procedure
to each element of specified column of this matrix.eachInColumn
in class Matrix
j
- the column indexprocedure
- the vector procedurepublic void eachNonZeroInColumn(int j, VectorProcedure procedure)
SparseMatrix
procedure
to each non-zero element of the specified column of this matrix.eachNonZeroInColumn
in class SparseMatrix
j
- the column 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 maxInColumn(int j)
Matrix
maxInColumn
in class Matrix
j
- the column indexpublic double minInColumn(int j)
Matrix
minInColumn
in class Matrix
j
- the column indexpublic 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> iteratorOrNonZeroColumns()
iteratorOrNonZeroColumns
in class ColumnMajorSparseMatrix
public ColumnMajorMatrixIterator columnMajorIterator()
Matrix
columnMajorIterator
in class Matrix
public ColumnMajorMatrixIterator nonZeroColumnMajorIterator()
SparseMatrix
nonZeroColumnMajorIterator
in class SparseMatrix
public VectorIterator nonZeroIteratorOfColumn(int j)
SparseMatrix
j
.nonZeroIteratorOfColumn
in class SparseMatrix
public VectorIterator iteratorOfColumn(int j)
Matrix
iteratorOfColumn
in class Matrix
Copyright © 2015. All rights reserved.