Package org.flag4j.arrays.sparse
Class CsrMatrix
java.lang.Object
org.flag4j.core.TensorBase<CsrMatrix,Matrix,CsrCMatrix,CMatrix,CsrMatrix,double[],Double>
org.flag4j.core.sparse_base.SparseTensorBase<CsrMatrix,Matrix,CsrCMatrix,CMatrix,CsrMatrix,double[],Double>
org.flag4j.core.sparse_base.RealSparseTensorBase<CsrMatrix,Matrix,CsrCMatrix,CMatrix>
org.flag4j.arrays.sparse.CsrMatrix
- All Implemented Interfaces:
Serializable
,MatrixComparisonsMixin<CsrMatrix>
,MatrixManipulationsMixin<CsrMatrix,
,Double> MatrixMixin<CsrMatrix,
,Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> MatrixOperationsMixin<CsrMatrix,
,Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> MatrixPropertiesMixin
,RealMatrixMixin<CsrMatrix,
,CsrCMatrix> RealTensorMixin<CsrMatrix,
,CsrCMatrix> SparseTensorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CsrMatrix>
,TensorOperationsMixin<CsrMatrix,
,Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> TensorPropertiesMixin
public class CsrMatrix
extends RealSparseTensorBase<CsrMatrix,Matrix,CsrCMatrix,CMatrix>
implements MatrixMixin<CsrMatrix,Matrix,CsrMatrix,CsrCMatrix,CsrCMatrix,Double,CooVector,Vector>, RealMatrixMixin<CsrMatrix,CsrCMatrix>
Real sparse matrix stored in compressed sparse row (CSR) format.
CSR matrices are best suited for efficient access and matrix operations. Specifically, matrix-matrix and
matrix-vector multiplication. CSR matrices are not well suited for modification (see CooMatrix
).
The CSR format stores a sparse m-by-n
matrix as three one-dimensional arrays: TensorBase.entries
,
rowPointers
, and colIndices
.
- entries: Stores the non-zero values of the sparse matrix. Note, zero values can be stored explicitly in this array. Hence, the term "non-zero values" is a misnomer.
- rowPointers: Encodes the total number of non-zero values above each row. Has length
m+1
. For example,rowPointers[j]
contains the total number of non-zero values above rowj
. The first entry is always 0 and the last element is alwaysentries.length
- colIndices: Contains the column indices for all non-zero entries. Has length
entries.length
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal int[]
Column indices of the non-zero entries of the sparse matrix.final int
The number of columns in this matrix.final int
The number of rows in this matrix.final int[]
Row indices of the non-zero entries of the sparse matrix.Fields inherited from class org.flag4j.core.sparse_base.SparseTensorBase
indices, nnz
Fields inherited from class org.flag4j.core.TensorBase
DEFAULT_ROUND_TO_ZERO_THRESHOLD, entries, shape
-
Constructor Summary
ConstructorDescriptionCsrMatrix
(int numRows, int numCols) Constructs an empty sparse CSR matrix with the specified shape.CsrMatrix
(int numRows, int numCols, double[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.Converts a sparse COO matrix to a sparse CSR matrix.Constructs a sparse CSR matrix which is a deep copy of thesrc
matrix.Constructs an empty sparse CSR matrix with the specified shape.Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries. -
Method Summary
Modifier and TypeMethodDescriptionadd
(double a) Adds specified value to all entries of this tensor.Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two matrices.add
(CooCMatrix B) Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two sparse matrices.add
(CsrCMatrix B) Computes the element-wise addition between two tensors of the same rank.Computes the element-wise addition between two tensors of the same rank.Adds specified value to all entries of this tensor.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each column of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.Adds a vector to each row of a matrix.boolean
Checks if all entries of this tensor are close to the entries of the argumenttensor
.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Augments a matrix with a vector.Stacks matrices along rows.Stacks matrices along rows.copy()
Creates a copy of this tensor.det()
Computes the determinant of a square matrix.Computes the element-wise division between two matrices.Computes the element-wise division between two tensors.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication (Hadamard product) between two matrices.Computes the element-wise multiplication between two tensors.boolean
Checks if this CSR matrix is equal to another CSR matrix.Computes the Frobenius inner product of two matrices.Computes the Frobenius inner product of two matrices.fib
(CooCMatrix B) Computes the Frobenius inner product of two matrices.Computes the Frobenius inner product of two matrices.fib
(CsrCMatrix B) Computes the Frobenius inner product of two matrices.Computes the Frobenius inner product of two matrices.flatten()
Flattens tensor to single dimension.flatten
(int axis) Flattens a tensor along the specified axis.get
(int... indices) Gets the element in this tensor at the specified indices.getCol
(int j) Get the column of this matrix at the specified index.getCol
(int colIdx, int rowStart, int rowEnd) Gets a specified column of this matrix betweenrowStart
(inclusive) androwEnd
(exclusive).getColBelow
(int rowStart, int j) Get a specified column of this matrix at and below a specified row.getDiag()
Extracts the diagonal elements of this matrix and returns them as a vector.getRow
(int i) Get the row of this matrix at the specified index.getRowAfter
(int colStart, int rowIdx) Get a specified row of this matrix at and after a specified column.protected CsrMatrix
getSelf()
Simply returns a reference of this tensor.getSlice
(int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified slice of this matrix.H()
Compute the hermitian transpose of this matrix.int
hashCode()
static CsrMatrix
I
(int size) Constructs an identity matrix stored in CSR format with the specified shape.static CsrMatrix
I
(int numRows, int numCols) Constructs an identity-like matrix stored in CSR format with the specified shape.static CsrMatrix
Constructs an identity-like matrix stored in CSR format with the specified shape.boolean
Checks if a matrix is anti-symmetric.boolean
isDiag()
Checks if this matrix is diagonal.boolean
Checks if a matrix has full rank.boolean
isI()
Checks if this matrix is the identity matrix.boolean
Checks if this matrix is orthogonal.boolean
Checks if a matrix is singular.boolean
isSquare()
Checks if this matrix is square.boolean
Checks if a matrix is symmetric.boolean
isTri()
Checks if this matrix is triangular (i.e.boolean
isTriL()
Checks if this matrix is lower triangular.boolean
isTriU()
Checks if this matrix is upper triangular.boolean
isVector()
Checks if a matrix can be represented as a vector.protected CsrCMatrix
makeComplexTensor
(Shape shape, CNumber[] entries, int[][] indices) A factory for creating a complex sparse tensor.protected Matrix
makeDenseTensor
(Shape shape, double[] entries) A factory for creating a real dense tensor.protected CsrMatrix
makeTensor
(Shape shape, double[] entries, int[][] indices) A factory for creating a real sparse tensor.int
Computes the rank of this matrix (i.e.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.mult
(CooCMatrix B) Computes the matrix multiplication between two matrices.mult
(CooCVector b) Computes matrix-vector multiplication.Computes the matrix multiplication between two matrices.Computes the matrix-vector multiplication.mult
(CsrCMatrix B) Computes the matrix multiplication between two sparse CSR matrices.Computes the matrix multiplication between two sparse CSR matrices.Computes the matrix multiplication between two sparse matrices and stores the result in a CSR matrix.Computes the matrix multiplication between two sparse matrices and stores the result in a CSR matrix.Computes the matrix multiplication between two sparse CSR matrices and stores the result in a CSR matrix.Computes the matrix multiplication between two sparse CSR matrices and stores the result in a CSR matrix.int
numCols()
Gets the number of columns in this matrix.int
numRows()
Gets the number of rows in this matrix.pow
(int exponent) Computes the matrix power with a given exponent.removeCol
(int colIndex) Removes a specified column from this matrix.removeCols
(int... colIndices) Removes a specified set of columns from this matrix.removeRow
(int rowIndex) Removes a specified row from this matrix.removeRows
(int... rowIndices) Removes a specified set of rows from this matrix.Copies and reshapes matrix if possible.set
(double value, int... indices) Sets an index of this tensor to a specified value.set
(double value, int row, int col) Sets an index of this matrix to the specified value.Sets an index of this matrix to the specified value.setCol
(double[] values, int colIndex) Sets a column of this matrix at the given index to the specified values.setCol
(int[] values, int colIndex) Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix at the given index to the specified values.Sets a column of this matrix.setRow
(double[] values, int rowIndex) Sets a row of this matrix at the given index to the specified values.setRow
(int[] values, int rowIndex) Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.Sets a row of this matrix at the given index to the specified values.setSlice
(double[][] values, int rowStart, int colStart) Sets a slice of this matrix to the specified values.setSlice
(int[][] values, int rowStart, int colStart) Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.Sets a slice of this matrix to the specified values.shape()
Gets the shape of this matrix.Computes the complex element-wise square root of a tensor.Stacks matrices along columns.Stacks vector to this matrix along columns.Stacks matrices along columns.Stacks vector to this matrix along columns.stack
(CooCMatrix B) Stacks matrices along columns.stack
(CooCVector b) Stacks vector to this matrix along columns.Stacks matrices along columns.Stacks vector to this matrix along columns.stack
(CsrCMatrix B) Stacks matrices along columns.Stacks matrices along columns.sub
(double a) Adds specified value to all entries of this tensor.Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction of two tensors of the same rank.sub
(CooCMatrix B) Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction of two sparse matrices.sub
(CsrCMatrix B) Computes the element-wise subtraction of two tensors of the same rank.Computes the element-wise subtraction between two tensors of the same rank.Subtracts a specified value from all entries of this tensor.sumCols()
Sums together the columns of a matrix as if each column was a column vector.sumRows()
Sums together the rows of a matrix as if each row was a row vector.swapCols
(int colIndex1, int colIndex2) Swaps columns in the matrix.swapRows
(int rowIndex1, int rowIndex2) Swaps two rows in this matrix.T()
Computes the transpose of a tensor.Converts this tensor to an equivalent complex tensor.toCoo()
Converts thisCSR matrix
to an equivalentCOO matrix
.toDense()
Converts this sparse tensor to an equivalent dense tensor.toString()
Formats this sparse CSR matrix as a human-readable string.toTensor()
Converts this matrix to an equivalent sparse tensor.toVector()
Converts this matrix to an equivalent vector.tr()
Computes the trace of this matrix.trace()
Computes the trace of this matrix.int
Checks what type of vector this matrix is.Methods inherited from class org.flag4j.core.sparse_base.RealSparseTensorBase
abs, argMax, argMin, div, div, isNeg, isOnes, isPos, isZeros, max, maxAbs, min, minAbs, mult, mult, nonZeroEntries, recip, reshape, round, round, roundToZero, roundToZero, sortIndices, sqrt, sum
Methods inherited from class org.flag4j.core.sparse_base.SparseTensorBase
density, sparsity
Methods inherited from class org.flag4j.core.TensorBase
allClose, getEntries, getRank, getShape, sameLength, sameShape, tensorEquals, totalEntries
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.MatrixOperationsMixin
mult, multTranspose, multTranspose, multTranspose, multTranspose, multTranspose, multTranspose, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack
Methods inherited from interface org.flag4j.core.MatrixPropertiesMixin
isInvertible
Methods inherited from interface org.flag4j.core.TensorOperationsMixin
transpose
-
Field Details
-
rowPointers
public final int[] rowPointersRow indices of the non-zero entries of the sparse matrix. -
colIndices
public final int[] colIndicesColumn indices of the non-zero entries of the sparse matrix. -
numRows
public final int numRowsThe number of rows in this matrix. -
numCols
public final int numColsThe number of columns in this matrix.
-
-
Constructor Details
-
CsrMatrix
Constructs an empty sparse CSR matrix with the specified shape.- Parameters:
shape
- Shape of the CSR matrix.
-
CsrMatrix
public CsrMatrix(int numRows, int numCols) Constructs an empty sparse CSR matrix with the specified shape.- Parameters:
numRows
- Number of rows in the CSR matrix.numCols
- Number of columns in the CSR matrix.
-
CsrMatrix
Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.- Parameters:
shape
- Shape of the matrix.entries
- Non-zero entries for CSR matrix.rowPointers
- Row pointers for CSR matrix.colIndices
- Column indices for CSR matrix.
-
CsrMatrix
public CsrMatrix(int numRows, int numCols, double[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.- Parameters:
numRows
- Number of rows in the CSR matrix.numCols
- Number of columns in the CSR matrix.entries
- Non-zero entries for CSR matrix.rowPointers
- Row pointers for CSR matrix.colIndices
- Column indices for CSR matrix.
-
CsrMatrix
Constructs a sparse CSR matrix which is a deep copy of thesrc
matrix.- Parameters:
src
- Matrix to create copy of.
-
CsrMatrix
Converts a sparse COO matrix to a sparse CSR matrix.- Parameters:
src
- COO matrix to convert. Indices must be sorted lexicographically.
-
-
Method Details
-
equals
Checks if this CSR matrix is equal to another CSR matrix.- Specified by:
equals
in interfaceTensorComparisonsMixin
- Overrides:
equals
in classObject
- Parameters:
src2
- Object to compare this matrix to.- Returns:
- True if
src2
is an instance ofCsrMatrix
this CSR matrix is equal tosrc2
. False otherwise. Ifsrc2
is null, false is returned.
-
mult2CSR
Computes the matrix multiplication between two sparse CSR matrices and stores the result in a CSR matrix. Warning: This method will likely be slower thanmult(CsrMatrix)
if the result of multiplying this matrix withB
is not very sparse. Further, multiplying two sparse matrices may result in a dense matrix so this method should be used with caution.- Parameters:
B
- Matrix to multiply to this matrix.- Returns:
- The result of matrix multiplying this matrix with
B
as a sparse CSR matrix.
-
mult2CSR
Computes the matrix multiplication between two sparse CSR matrices and stores the result in a CSR matrix. Warning: This method will likely be slower thanmult(CsrCMatrix)
if the result of multiplying this matrix withB
is not very sparse. Further, multiplying two sparse matrices may result in a dense matrix so this method should be used with caution.- Parameters:
B
- Matrix to multiply to this matrix.- Returns:
- The result of matrix multiplying this matrix with
B
as a sparse CSR matrix.
-
mult2CSR
Computes the matrix multiplication between two sparse matrices and stores the result in a CSR matrix. Warning: This method will likely be slower thanmult(CooMatrix)
if the result of multiplying this matrix withB
is not very sparse. Further, multiplying two sparse matrices may result in a dense matrix so this method should be used with caution.- Parameters:
B
- Matrix to multiply to this matrix.- Returns:
- The result of matrix multiplying this matrix with
B
as a sparse CSR matrix.
-
mult2CSR
Computes the matrix multiplication between two sparse matrices and stores the result in a CSR matrix. Warning: This method will likely be slower thanmult(CooCMatrix)
if the result of multiplying this matrix withB
is not very sparse. Further, multiplying two sparse matrices may result in a dense matrix so this method should be used with caution.- Parameters:
B
- Matrix to multiply to this matrix.- Returns:
- The result of matrix multiplying this matrix with
B
as a sparse CSR matrix.
-
add
Computes the element-wise addition between two matrices.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the addition.- Returns:
- The result of adding the matrix B to this matrix element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two sparse matrices. Note that the CooMatrix is simply converted to a csr matrix first.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second sparse matrix in the sum.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two sparse matrices. Note, the CooMatrix is simply converted to a CsrMatrix first.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
sub
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second tensor in the subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If A and B have different shapes.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
B
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrixB
.
-
mult
Computes the matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to multiply this matrix to.- Returns:
- The vector result from multiplying this matrix by the vector
b
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entriesb
.
-
mult
Computes matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
mult
Computes matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
pow
Computes the matrix power with a given exponent. This is equivalent to multiplying a matrix to itself 'exponent' times.- Specified by:
pow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
exponent
- The exponent in the matrix power.- Returns:
- The result of multiplying this matrix with itself 'exponent' times.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Parameters:
B
- Second matrix in the element-wise multiplication.- Returns:
- The result of element-wise multiplication of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
elemDiv
Computes the element-wise division between two matrices.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the element-wise division.- Returns:
- The result of element-wise division of this matrix with the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.ArithmeticException
- If B contains any zero entries.
-
det
Computes the determinant of a square matrix.WARNING: Currently, this method will convert this matrix to a dense matrix.
- Specified by:
det
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The determinant of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
I
-
I
Constructs an identity matrix stored in CSR format with the specified shape.- Parameters:
size
- Number of rows (and columns) in the matrix.- Returns:
- An identity matrix stored in CSR format.
-
I
Constructs an identity-like matrix stored in CSR format with the specified shape.- Parameters:
numRows
- Number of rows in the matrix.numCols
- Number of columns in the matrix.- Returns:
- An identity-like matrix stored in CSR format.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the Frobenius inner product- Returns:
- The Frobenius inner product of this matrix and matrix B.
- Throws:
IllegalArgumentException
- If this matrix and B have different shapes.
-
sumCols
Sums together the columns of a matrix as if each column was a column vector.- Specified by:
sumCols
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The result of summing together all columns of the matrix as column vectors. If this matrix is an m-by-n matrix, then the result will be a vectors of length m.
-
sumRows
Sums together the rows of a matrix as if each row was a row vector.- Specified by:
sumRows
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The result of summing together all rows of the matrix as row vectors. If this matrix is an m-by-n matrix, then the result will be a vector of length n.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachCol
Adds a vector to each column of a matrix. The vector need not be a column vector. If it is a row vector it will be treated as if it were a column vector.- Specified by:
addToEachCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each column of this matrix.- Returns:
- The result of adding the vector b to each column of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
addToEachRow
Adds a vector to each row of a matrix. The vector need not be a row vector. If it is a column vector it will be treated as if it were a row vector for this operation.- Specified by:
addToEachRow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to add to each row of this matrix.- Returns:
- The result of adding the vector b to each row of this matrix.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
stack
Stacks matrices along columns.
Also seeMatrixOperationsMixin.stack(Matrix, int)
andaugment(Matrix)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the matrix B.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of columns.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
augment
- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Matrix to stack to this matrix.- Returns:
- The result of stacking B to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix and matrix B have a different number of rows.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seeMatrixOperationsMixin.stack(Vector, int)
andaugment(Vector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seeMatrixOperationsMixin.stack(CooVector, int)
andaugment(CooVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seeMatrixOperationsMixin.stack(CVector, int)
andaugment(CVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
stack
Stacks vector to this matrix along columns. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. All vectors will be treated as row vectors.
Also seeMatrixOperationsMixin.stack(CooCVector, int)
andaugment(CooCVector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to stack to this matrix.- Returns:
- The result of stacking this matrix on top of the vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix is different from the number of entries in the vector b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(Vector)
andMatrixOperationsMixin.stack(Vector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CooVector)
andMatrixOperationsMixin.stack(CooVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CVector)
andMatrixOperationsMixin.stack(CVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
augment
Augments a matrix with a vector. That is, stacks a vector along the rows to the right side of a matrix. Note that the orientation of the vector (i.e. row/column vector) does not affect the output of this function. The vector will be treated as a column vector regardless of the true orientation.
Also seestack(CooCVector)
andMatrixOperationsMixin.stack(CooCVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- vector to augment to this matrix.- Returns:
- The result of augmenting b to the right of this matrix.
- Throws:
IllegalArgumentException
- If this matrix has a different number of rows as entries in b.
-
getRow
Get the row of this matrix at the specified index.- Specified by:
getRow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
i
- Index of row to get.- Returns:
- The specified row of this matrix.
-
getCol
Get the column of this matrix at the specified index.- Specified by:
getCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
j
- Index of column to get.- Returns:
- The specified column of this matrix.
-
getCol
Gets a specified column of this matrix betweenrowStart
(inclusive) androwEnd
(exclusive).- Specified by:
getCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
colIdx
- Index of the column of this matrix to get.rowStart
- Starting row of the column (inclusive).rowEnd
- Ending row of the column (exclusive).- Returns:
- The column at index
colIdx
of this matrix between therowStart
androwEnd
indices. - Throws:
IllegalArgumentException
- IfrowStart
is less than 0.IllegalArgumentException
- IfrowEnd
is less thanrowStart
.
-
toVector
Converts this matrix to an equivalent vector. If this matrix is not shaped as a row/column vector, it will be flattened then converted to a vector.- Specified by:
toVector
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- A vector equivalent to this matrix.
-
toTensor
Converts this matrix to an equivalent sparse tensor.- Returns:
- A sparse tensor which is equivalent to this matrix.
-
getSlice
Gets a specified slice of this matrix.- Specified by:
getSlice
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
rowStart
- Starting row index of slice (inclusive).rowEnd
- Ending row index of slice (exclusive).colStart
- Starting column index of slice (inclusive).colEnd
- Ending row index of slice (exclusive).- Returns:
- The specified slice of this matrix. This is a completely new matrix and NOT a view into the matrix.
- Throws:
ArrayIndexOutOfBoundsException
- If any of the indices are out of bounds of this matrix.IllegalArgumentException
- IfrowEnd
is not greater thanrowStart
or ifcolEnd
is not greater thancolStart
.
-
getColBelow
Get a specified column of this matrix at and below a specified row.- Specified by:
getColBelow
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
rowStart
- Index of the row to begin at.j
- Index of column to get.- Returns:
- The specified column of this matrix beginning at the specified row.
- Throws:
NegativeArraySizeException
- IfrowStart
is larger than the number of rows in this matrix.ArrayIndexOutOfBoundsException
- IfrowStart
orj
is outside the bounds of this matrix.
-
getRowAfter
Get a specified row of this matrix at and after a specified column.- Specified by:
getRowAfter
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
colStart
- Index of the row to begin at.rowIdx
- Index of the row to get.- Returns:
- The specified row of this matrix beginning at the specified column.
- Throws:
NegativeArraySizeException
- IfcolStart
is larger than the number of columns in this matrix.ArrayIndexOutOfBoundsException
- IfrowIdx
orcolStart
is outside the bounds of this matrix.
-
setCol
Sets a column of this matrix.- Specified by:
setCol
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
values
- Vector containing the new values for the matrix.j
- Index of the column of this matrix to set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the number of entries in thevalues
vector is not the same as the number of rows in this matrix.IndexOutOfBoundsException
- Ifj
is not within the bounds of this matrix.
-
trace
Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astr()
.- Specified by:
trace
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
tr
Computes the trace of this matrix. That is, the sum of elements along the principle diagonal of this matrix. Same astrace()
.- Specified by:
tr
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The trace of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
getDiag
Extracts the diagonal elements of this matrix and returns them as a vector.- Specified by:
getDiag
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- A vector containing the diagonal entries of this matrix.
-
H
Compute the hermitian transpose of this matrix. That is, the complex conjugate transpose of this matrix.- Specified by:
H
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The complex conjugate transpose of this matrix.
-
mult
Computes the matrix multiplication between two sparse CSR matrices. The result is stored as a dense matrix.
If memory is a concern, and you are confident the multiplication result will be sparse, consider usingmult2CSR(CsrMatrix)
which will store the result as aCsrMatrix
. However, the method should be used with caution as it will almost never be faster than this method and sparse matrix multiplication may result in fully dense matrices (even for two very sparse matrices).- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
B
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrixB
.
-
mult
Computes the matrix multiplication between two sparse CSR matrices. The result is stored as a dense matrix.
If memory is a concern, and you are confident the multiplication result will be sparse, consider usingmult2CSR(CsrCMatrix)
which will store the result as aCsrCMatrix
. However, the method should be used with caution as it will almost never be faster than this method and sparse matrix multiplication may result in fully dense matrices (even for two very sparse matrices).- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
B
. - Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrixB
.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
B
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix B.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of rows in matrix B.
-
mult
Computes matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector in the matrix-vector multiplication.- Returns:
- The result of matrix multiplying this matrix with vector b.
- Throws:
IllegalArgumentException
- If the number of columns in this matrix do not equal the number of entries in the vector b.
-
isI
public boolean isI()Checks if this matrix is the identity matrix.- Specified by:
isI
in interfaceMatrixComparisonsMixin<CsrMatrix>
- Returns:
- True if this matrix is the identity matrix. Otherwise, returns false.
-
set
Sets an index of this matrix to the specified value. Note: new entries cannot be inserted into a CSR matrix. This method returns a new matrix. In general, calling this method repeatedly is not considered to be efficient.- Specified by:
set
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A new CSR matrix with the specified value set.
-
set
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A reference to this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the column.colIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of rows of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If the values array has a different length than the number of columns of this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
setSlice
Sets a slice of this matrix to the specified values. The rowStart and colStart parameters specify the upper left index location of the slice to set.- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
values
- New values for the specified slice.rowStart
- Starting row index for the slice (inclusive).colStart
- Starting column index for the slice (inclusive).- Returns:
- A reference to this matrix.
- Throws:
IndexOutOfBoundsException
- If rowStart or colStart are not within the matrix.IllegalArgumentException
- If the values slice, with upper left corner at the specified location, does not fit completely within this matrix.
-
hashCode
-
removeRow
Removes a specified row from this matrix.- Specified by:
removeRow
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
rowIndex
- Index of the row to remove from this matrix.- Returns:
- a copy of this matrix with the specified row removed.
- Throws:
IndexOutOfBoundsException
- IfrowIndex >= this.numRows()
.
-
removeRows
Removes a specified set of rows from this matrix. Note: this will construct an intermediateCooMatrix
.- Specified by:
removeRows
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
rowIndices
- The indices of the rows to remove from this matrix.- Returns:
- a copy of this matrix with the specified rows removed.
-
removeCol
Removes a specified column from this matrix. Note: this will construct an intermediateCooMatrix
.- Specified by:
removeCol
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
colIndex
- Index of the column to remove from this matrix.- Returns:
- a copy of this matrix with the specified column removed.
-
removeCols
Removes a specified set of columns from this matrix.- Specified by:
removeCols
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
colIndices
- Indices of the columns to remove from this matrix.- Returns:
- a copy of this matrix with the specified columns removed.
-
swapRows
Swaps two rows in this matrix.- Specified by:
swapRows
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
rowIndex1
- Index of first row to swap.rowIndex2
- index of second row to swap.- Returns:
- A reference to this matrix.
-
swapCols
Swaps columns in the matrix.- Specified by:
swapCols
in interfaceMatrixManipulationsMixin<CsrMatrix,
Double> - Parameters:
colIndex1
- Index of first column to swap.colIndex2
- index of second column to swap.- Returns:
- A reference to this matrix.
-
numRows
public int numRows()Gets the number of rows in this matrix.- Specified by:
numRows
in interfaceMatrixMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The number of rows in this matrix.
-
numCols
public int numCols()Gets the number of columns in this matrix.- Specified by:
numCols
in interfaceMatrixMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The number of columns in this matrix.
-
shape
Gets the shape of this matrix.- Specified by:
shape
in interfaceMatrixMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Returns:
- The shape of this matrix.
-
isSquare
public boolean isSquare()Checks if this matrix is square.- Specified by:
isSquare
in interfaceMatrixPropertiesMixin
- Returns:
- True if the matrix is square (i.e. the number of rows equals the number of columns). Otherwise, returns false.
-
isVector
public boolean isVector()Checks if a matrix can be represented as a vector. That is, if a matrix has only one row or one column.- Specified by:
isVector
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix can be represented as either a row or column vector.
-
vectorType
public int vectorType()Checks what type of vector this matrix is. i.e. not a vector, a 1x1 matrix, a row vector, or a column vector.- Specified by:
vectorType
in interfaceMatrixPropertiesMixin
- Returns:
- - If this matrix can not be represented as a vector, then returns -1.
- If this matrix is a 1x1 matrix, then returns 0.
- If this matrix is a row vector, then returns 1.
- If this matrix is a column vector, then returns 2.
-
isTri
public boolean isTri()Checks if this matrix is triangular (i.e. upper triangular, diagonal, lower triangular).- Specified by:
isTri
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is triangular. Otherwise, returns false.
- See Also:
-
isTriL
public boolean isTriL()Checks if this matrix is lower triangular.- Specified by:
isTriL
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is lower triangular. Otherwise, returns false.
- See Also:
-
isTriU
public boolean isTriU()Checks if this matrix is upper triangular.- Specified by:
isTriU
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is upper triangular. Otherwise, returns false.
- See Also:
-
isDiag
public boolean isDiag()Checks if this matrix is diagonal.- Specified by:
isDiag
in interfaceMatrixPropertiesMixin
- Returns:
- True is this matrix is diagonal. Otherwise, returns false.
- See Also:
-
isFullRank
public boolean isFullRank()Checks if a matrix has full rank. That is, if a matrices rank is equal to the number of rows in the matrix.- Specified by:
isFullRank
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix has full rank. Otherwise, returns false.
-
isSingular
public boolean isSingular()Checks if a matrix is singular. That is, if the matrix is NOT invertible.- Specified by:
isSingular
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is singular. Otherwise, returns false.
- See Also:
-
matrixRank
public int matrixRank()Computes the rank of this matrix (i.e. the dimension of the column space of this matrix). Note that here, rank is NOT the same as a tensor rank.
WARNING: This method will convert this matrix to a dense matrix to compute the rank.
- Specified by:
matrixRank
in interfaceMatrixPropertiesMixin
- Returns:
- The matrix rank of this matrix.
-
isSymmetric
public boolean isSymmetric()Checks if a matrix is symmetric. That is, if the matrix is equal to its transpose.- Specified by:
isSymmetric
in interfaceRealMatrixMixin<CsrMatrix,
CsrCMatrix> - Returns:
- True if this matrix is symmetric. Otherwise, returns false.
-
isAntiSymmetric
public boolean isAntiSymmetric()Checks if a matrix is anti-symmetric. That is, if the matrix is equal to the negative of its transpose.- Specified by:
isAntiSymmetric
in interfaceRealMatrixMixin<CsrMatrix,
CsrCMatrix> - Returns:
- True if this matrix is anti-symmetric. Otherwise, returns false.
-
isOrthogonal
public boolean isOrthogonal()Checks if this matrix is orthogonal. That is, if the inverse of this matrix is equal to its transpose.- Specified by:
isOrthogonal
in interfaceRealMatrixMixin<CsrMatrix,
CsrCMatrix> - Returns:
- True if this matrix it is orthogonal. Otherwise, returns false.
-
sqrtComplex
Computes the complex element-wise square root of a tensor.- Specified by:
sqrtComplex
in interfaceRealMatrixMixin<CsrMatrix,
CsrCMatrix> - Returns:
- The result of applying an element-wise square root to this tensor. Note, this method will compute the principle square root i.e. the square root with positive real part.
-
toComplex
Converts this tensor to an equivalent complex tensor. That is, the entries of the resultant matrix will be exactly the same value but will have typeCNumber
rather thanDouble
.- Specified by:
toComplex
in interfaceRealTensorMixin<CsrMatrix,
CsrCMatrix> - Returns:
- A complex matrix which is equivalent to this matrix.
-
getSelf
Simply returns a reference of this tensor.- Specified by:
getSelf
in classTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, double[], Double> - Returns:
- A reference to this tensor.
-
toCoo
Converts thisCSR matrix
to an equivalentCOO matrix
.- Returns:
- A
COO matrix
equivalent to thisCSR matrix
.
-
allClose
Checks if all entries of this tensor are close to the entries of the argumenttensor
.- Specified by:
allClose
in classTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, double[], Double> - Parameters:
src
- Tensor to compare this tensor to.relTol
- Relative tolerance.absTol
- Absolute tolerance.- Returns:
- True if the argument
tensor
is the same shape as this tensor and all entries are 'close', i.e. elementsa
andb
at the same positions in the two tensors respectively satisfy|a-b| <= (atol + rtol*|b|)
. Otherwise, returns false. - See Also:
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceTensorManipulationsMixin<CsrMatrix>
- Parameters:
value
- Value to set.indices
- The indices of this tensor for which to set the value.- Returns:
- A reference to this tensor.
-
reshape
Copies and reshapes matrix if possible. The total number of entries in this matrix must match the total number of entries in the reshaped matrix.- Specified by:
reshape
in interfaceTensorManipulationsMixin<CsrMatrix>
- Parameters:
newShape
- Shape of the new matrix.- Returns:
- A matrix which is equivalent to this matrix but with the specified shape.
- Throws:
IllegalArgumentException
- If this matrix cannot be reshaped to the specified dimensions.
-
flatten
Flattens tensor to single dimension. To flatten tensor along a single axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CsrMatrix>
- Returns:
- The flattened tensor.
-
flatten
Flattens a tensor along the specified axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CsrMatrix>
- Parameters:
axis
- Axis along which to flatten tensor.- Throws:
IllegalArgumentException
- If the axis is not positive or larger than the rank of this tensor.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Specified by:
add
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
B
- Second tensor in the addition.- Returns:
- The result of adding the tensor B to this tensor element-wise.
- Throws:
IllegalArgumentException
- If this tensor and B have different shapes.
-
add
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
add
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
sub
Computes the element-wise subtraction between two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Specified by:
sub
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
B
- Second tensor in element-wise subtraction.- Returns:
- The result of subtracting the tensor B from this tensor element-wise.
- Throws:
IllegalArgumentException
- If this tensor and B have different shapes.
-
sub
Adds specified value to all entries of this tensor.- Specified by:
sub
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
a
- Value to add to all entries of this tensor.- Returns:
- The result of adding the specified value to each entry of this tensor.
-
sub
Subtracts a specified value from all entries of this tensor.- Specified by:
sub
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
a
- Value to subtract from all entries of this tensor.- Returns:
- The result of subtracting the specified value from each entry of this tensor.
-
T
Computes the transpose of a tensor. Same asTensorOperationsMixin.transpose()
.- Specified by:
T
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Returns:
- The transpose of this tensor.
-
get
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceMatrixMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Specified by:
get
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
indices
- Indices of element.- Returns:
- The element at the specified indices.
- Throws:
IllegalArgumentException
- If the number of indices does not match the rank of this tensor.
-
copy
Creates a copy of this tensor.- Specified by:
copy
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Specified by:
copy
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Returns:
- A copy of this tensor.
-
elemMult
Computes the element-wise multiplication between two tensors.- Specified by:
elemMult
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
B
- Tensor to element-wise multiply to this tensor.- Returns:
- The result of the element-wise tensor multiplication.
- Throws:
IllegalArgumentException
- If this tensor andB
do not have the same shape.
-
elemDiv
Computes the element-wise division between two tensors.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CsrMatrix,
Matrix, CsrMatrix, CsrCMatrix, CsrCMatrix, Double, CooVector, Vector> - Specified by:
elemDiv
in interfaceTensorOperationsMixin<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, Double> - Parameters:
B
- Tensor to element-wise divide with this tensor.- Returns:
- The result of the element-wise tensor multiplication.
- Throws:
IllegalArgumentException
- If this tensor andB
do not have the same shape.
-
makeTensor
A factory for creating a real sparse tensor.- Specified by:
makeTensor
in classRealSparseTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix> - Parameters:
shape
- Shape of the sparse tensor to make.entries
- Non-zero entries of the sparse tensor to make.indices
- Non-zero indices of the sparse tensor to make.- Returns:
- A tensor created from the specified parameters.
-
makeDenseTensor
A factory for creating a real dense tensor.- Specified by:
makeDenseTensor
in classRealSparseTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix> - Parameters:
shape
- Shape of the tensor to make.entries
- Entries of the dense tensor to make.- Returns:
- A tensor created from the specified parameters.
-
makeComplexTensor
A factory for creating a complex sparse tensor.- Specified by:
makeComplexTensor
in classRealSparseTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix> - Parameters:
shape
- Shape of the tensor to make.entries
- Non-zero entries of the sparse tensor to make.indices
- Non-zero indices of the sparse tensor to make.- Returns:
- A tensor created from the specified parameters.
-
toDense
Converts this sparse tensor to an equivalent dense tensor.- Specified by:
toDense
in classSparseTensorBase<CsrMatrix,
Matrix, CsrCMatrix, CMatrix, CsrMatrix, double[], Double> - Returns:
- A dense tensor which is equivalent to this sparse tensor.
-
toString
-