Package org.flag4j.arrays.sparse
Class CsrCMatrix
java.lang.Object
org.flag4j.core.TensorBase<CsrCMatrix,CMatrix,CsrCMatrix,CMatrix,CsrMatrix,CNumber[],CNumber>
org.flag4j.core.sparse_base.SparseTensorBase<CsrCMatrix,CMatrix,CsrCMatrix,CMatrix,CsrMatrix,CNumber[],CNumber>
org.flag4j.core.sparse_base.ComplexSparseTensorBase<CsrCMatrix,CMatrix,CsrMatrix>
org.flag4j.arrays.sparse.CsrCMatrix
- All Implemented Interfaces:
Serializable
,ComplexMatrixMixin<CsrCMatrix>
,ComplexTensorMixin<CsrCMatrix,
,CsrMatrix> MatrixComparisonsMixin<CsrCMatrix>
,MatrixManipulationsMixin<CsrCMatrix,
,CNumber> MatrixMixin<CsrCMatrix,
,CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> MatrixOperationsMixin<CsrCMatrix,
,CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> MatrixPropertiesMixin
,SparseTensorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CsrCMatrix>
,TensorOperationsMixin<CsrCMatrix,
,CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> TensorPropertiesMixin
public class CsrCMatrix
extends ComplexSparseTensorBase<CsrCMatrix,CMatrix,CsrMatrix>
implements MatrixMixin<CsrCMatrix,CMatrix,CsrCMatrix,CsrCMatrix,CsrCMatrix,CNumber,CooCVector,CVector>, ComplexMatrixMixin<CsrCMatrix>
Complex 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 CooCMatrix
).
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
ConstructorDescriptionCsrCMatrix
(int numRows, int numCols) Constructs an empty sparse CSR matrix with the specified shape.CsrCMatrix
(int numRows, int numCols, CNumber[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.CsrCMatrix
(CooCMatrix src) Converts a sparse COO matrix to a sparse CSR matrix.CsrCMatrix
(CooMatrix src) Converts a real sparse COO matrix to a complex sparse CSR matrix.CsrCMatrix
(CsrCMatrix src) Constructs a sparse CSR matrix which is a deep copy of thesrc
matrix.CsrCMatrix
(Shape shape) Constructs an empty sparse CSR matrix with the specified shape.CsrCMatrix
(Shape shape, double[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.CsrCMatrix
(Shape shape, CNumber[] entries, int[] rowPointers, int[] colIndices) 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 tensors of the same rank.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
allClose
(CsrCMatrix tensor, double relTol, double absTol) 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.copy()
Creates a copy of this tensor.det()
Computes the determinant of a square matrix.Computes the element-wise division between two tensors.Computes the element-wise division 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.Computes the element-wise multiplication (Hadamard product) between two matrices.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.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 CsrCMatrix
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()
Computes the conjugate transpose of this tensor.int
hashCode()
boolean
Checks if a matrix is anti-Hermitian.boolean
Checks if a matrix has full rank.boolean
Checks if a matrix is Hermitian.boolean
isI()
Checks if this matrix is the identity matrix.boolean
Checks if a matrix is singular.boolean
isSquare()
Checks if this matrix is square.boolean
isTriL()
Checks if this matrix is lower triangular.boolean
isTriU()
Checks if this matrix is upper triangular.boolean
Checks if this matrix is unitary.boolean
isVector()
Checks if a matrix can be represented as a vector.protected CsrMatrix
makeRealTensor
(Shape shape, double[] entries, int[][] indices) A factory for creating a real sparse tensor.protected CsrCMatrix
makeTensor
(Shape shape, CNumber[] entries, int[][] indices) A factory for creating a complex 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 the matrix-vector multiplication.Computes the matrix multiplication between two matrices.Computes matrix-vector multiplication.mult
(CsrCMatrix B) Computes the matrix multiplication between two matrices.Computes the matrix multiplication between two 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 tensor to a 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 at the given index to the specified values.setCol
(CooCVector values, int j) Sets a column of this matrix.Sets a column of this matrix at the given index to the specified values.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.Sets a row of this matrix at the given index to the specified values.setRow
(CooCVector 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.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.setSlice
(CooCMatrix 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.setSlice
(CsrCMatrix 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.shape()
Gets the shape of this matrix.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.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 tensors of the same rank.sub
(CsrCMatrix B) Computes the element-wise subtraction between two tensors of the same rank.Computes the element-wise subtraction of 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 rows in the matrix.T()
Computes the transpose of a tensor.toCoo()
Converts thisCSR matrix
to an equivalentCOO matrix
.toDense()
Converts this sparse tensor to an equivalent dense tensor.toString()
Formats this sparse 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.Computes the transpose of a tensor.int
Checks what type of vector this matrix is.Methods inherited from class org.flag4j.core.sparse_base.ComplexSparseTensorBase
abs, argMax, argMin, conj, div, div, isComplex, isOnes, isReal, isZeros, max, maxAbs, min, minAbs, mult, mult, nonZeroEntries, recip, reshape, round, round, roundToZero, roundToZero, sortIndices, sqrt, sum, toReal, toRealSafe
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.ComplexMatrixMixin
conj, conjT, isComplex, isReal
Methods inherited from interface org.flag4j.core.ComplexTensorMixin
hermTranspose
Methods inherited from interface org.flag4j.core.MatrixOperationsMixin
augment, augment, mult, multTranspose, multTranspose, multTranspose, multTranspose, multTranspose, multTranspose, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack
Methods inherited from interface org.flag4j.core.MatrixPropertiesMixin
isDiag, isInvertible, isTri
-
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
-
CsrCMatrix
Constructs an empty sparse CSR matrix with the specified shape.- Parameters:
shape
- Shape of the CSR matrix.
-
CsrCMatrix
public CsrCMatrix(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.
-
CsrCMatrix
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.
-
CsrCMatrix
Constructs a sparse matrix in CSR format with specified row-pointers, column indices and non-zero entries.- Parameters:
numRows
- Number of rows for CSR matrix.numCols
- Number of columns for CSR matrix.entries
- Non-zero entries for CSR matrix.rowPointers
- Row pointers for CSR matrix.colIndices
- Column indices for CSR matrix.
-
CsrCMatrix
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.
-
CsrCMatrix
Constructs a sparse CSR matrix which is a deep copy of thesrc
matrix.- Parameters:
src
- Matrix to create copy of.
-
CsrCMatrix
Converts a sparse COO matrix to a sparse CSR matrix.- Parameters:
src
- COO matrix to convert. Indices must be sorted lexicographically.
-
CsrCMatrix
Converts a real sparse COO matrix to a complex sparse CSR matrix.- Parameters:
src
- COO matrix to convert. Indices must be sorted lexicographically.
-
-
Method Details
-
H
Computes the conjugate transpose of this tensor. In the context of a tensor, this swaps the first and last axes and takes the complex conjugate of the elements along these axes. Same asComplexTensorMixin.hermTranspose()
.- Specified by:
H
in interfaceComplexMatrixMixin<CsrCMatrix>
- Specified by:
H
in interfaceComplexTensorMixin<CsrCMatrix,
CsrMatrix> - Specified by:
H
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- The complex transpose of this tensor.
-
isHermitian
public boolean isHermitian()Checks if a matrix is Hermitian. That is, if the matrix is equal to its conjugate transpose.- Specified by:
isHermitian
in interfaceComplexMatrixMixin<CsrCMatrix>
- Returns:
- True if this matrix is Hermitian. Otherwise, returns false.
-
isAntiHermitian
public boolean isAntiHermitian()Checks if a matrix is anti-Hermitian. That is, if the matrix is equal to the negative of its conjugate transpose.- Specified by:
isAntiHermitian
in interfaceComplexMatrixMixin<CsrCMatrix>
- Returns:
- True if this matrix is anti-symmetric. Otherwise, returns false.
-
isUnitary
public boolean isUnitary()Checks if this matrix is unitary. That is, if the inverse of this matrix is equal to its conjugate transpose.- Specified by:
isUnitary
in interfaceComplexMatrixMixin<CsrCMatrix>
- Returns:
- True if this matrix it is unitary. Otherwise, returns false.
-
setCol
Sets a column of this matrix at the given index to the specified values.- Specified by:
setCol
in interfaceComplexMatrixMixin<CsrCMatrix>
- 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 vector has a different length than the number of rows of this matrix.IndexOutOfBoundsException
- IfcolIndex
is not within the matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceComplexMatrixMixin<CsrCMatrix>
- Parameters:
values
- New values for the row.rowIndex
- The index of the row which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If thevalues
vector has a different length than the number of columns of this matrix.IndexOutOfBoundsException
- IfrowIndex
is not within the matrix.
-
setRow
Sets a row of this matrix at the given index to the specified values.- Specified by:
setRow
in interfaceComplexMatrixMixin<CsrCMatrix>
- Parameters:
values
- New values for the row.rowIndex
- The index of the row which is to be set.- Returns:
- A reference to this matrix.
- Throws:
IllegalArgumentException
- If thevalues
vector has a different length than the number of columns of this matrix.IndexOutOfBoundsException
- IfrowIndex
is not within the 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 interfaceComplexMatrixMixin<CsrCMatrix>
- 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
- IfrowStart
orcolStart
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.
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceComplexTensorMixin<CsrCMatrix,
CsrMatrix> - Parameters:
value
- Value to set.indices
- The indices of this tensor for which to set the value.- Returns:
- A reference to this tensor.
- Throws:
IllegalArgumentException
- If the number of indices is not equal to the rank of this tensor.IndexOutOfBoundsException
- If any of the indices are not within this tensor.
-
getSelf
Simply returns a reference of this tensor.- Specified by:
getSelf
in classTensorBase<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber[], CNumber> - Returns:
- A reference to this tensor.
-
allClose
Checks if all entries of this tensor are close to the entries of the argumenttensor
.- Specified by:
allClose
in classTensorBase<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber[], CNumber> - Parameters:
tensor
- 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<CsrCMatrix>
- 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<CsrCMatrix>
- 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<CsrCMatrix>
- Returns:
- The flattened tensor.
-
flatten
Flattens a tensor along the specified axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CsrCMatrix>
- 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Specified by:
add
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Specified by:
sub
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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.
-
transpose
Computes the transpose of a tensor. Same asT()
.- Specified by:
transpose
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - Returns:
- The transpose of this tensor.
- See Also:
-
T
Computes the transpose of a tensor. Same astranspose()
.- Specified by:
T
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - Returns:
- The transpose of this tensor.
- See Also:
-
numRows
public int numRows()Gets the number of rows in this matrix.- Specified by:
numRows
in interfaceMatrixMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- The number of columns in this matrix.
-
get
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceMatrixMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Specified by:
get
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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.
-
shape
Gets the shape of this matrix.- Specified by:
shape
in interfaceMatrixMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- The shape of this matrix.
-
copy
Creates a copy of this tensor.- Specified by:
copy
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Specified by:
copy
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - Returns:
- A copy of this tensor.
-
elemMult
Computes the element-wise multiplication between two tensors.- Specified by:
elemMult
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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.
-
add
Computes the element-wise addition between two matrices.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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 tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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.
-
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.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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
.
-
pow
Computes the matrix power with a given exponent. This is equivalent to multiplying a matrix to itself 'exponent' times. Note, this method is preferred over repeated multiplication of a matrix as this method will be significantly faster.- Specified by:
pow
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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.
-
elemDiv
Computes the element-wise division between two tensors.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Specified by:
elemDiv
in interfaceTensorOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber> - 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.
-
det
Computes the determinant of a square matrix.- Specified by:
det
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- The determinant of this matrix.
- Throws:
IllegalArgumentException
- If this matrix is not square.
-
fib
Computes the Frobenius inner product of two matrices.- Specified by:
fib
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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.NegativeArraySizeException
- 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- A vector equivalent to this matrix.
-
getSlice
Gets a specified slice of this matrix.- Specified by:
getSlice
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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 interfaceComplexMatrixMixin<CsrCMatrix>
- Specified by:
setCol
in interfaceMatrixOperationsMixin<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - 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<CsrCMatrix,
CMatrix, CsrCMatrix, CsrCMatrix, CsrCMatrix, CNumber, CooCVector, CVector> - Returns:
- A vector containing the diagonal entries of this matrix.
-
makeTensor
A factory for creating a complex sparse tensor.- Specified by:
makeTensor
in classComplexSparseTensorBase<CsrCMatrix,
CMatrix, CsrMatrix> - 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.
-
makeRealTensor
A factory for creating a real sparse tensor.- Specified by:
makeRealTensor
in classComplexSparseTensorBase<CsrCMatrix,
CMatrix, CsrMatrix> - 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.
-
toDense
Converts this sparse tensor to an equivalent dense tensor.- Specified by:
toDense
in classSparseTensorBase<CsrCMatrix,
CMatrix, CsrCMatrix, CMatrix, CsrMatrix, CNumber[], CNumber> - Returns:
- A dense tensor which is equivalent to this sparse tensor.
-
toTensor
Converts this matrix to an equivalent sparse tensor.- Returns:
- A sparse tensor which is equivalent to this matrix.
-
toCoo
Converts thisCSR matrix
to an equivalentCOO matrix
.- Returns:
- A
COO matrix
equivalent to thisCSR matrix
.
-
isI
public boolean isI()Checks if this matrix is the identity matrix.- Specified by:
isI
in interfaceMatrixComparisonsMixin<CsrCMatrix>
- Returns:
- True if this matrix is the identity matrix. Otherwise, returns false.
-
set
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A reference to this matrix.
-
set
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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 interfaceComplexMatrixMixin<CsrCMatrix>
- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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 interfaceComplexMatrixMixin<CsrCMatrix>
- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - 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.
-
removeRow
Removes a specified row from this matrix.- Specified by:
removeRow
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - Parameters:
rowIndex
- Index of the row to remove from this matrix.- Returns:
- a copy of this matrix with the specified row removed.
-
removeRows
Removes a specified set of rows from this matrix.- Specified by:
removeRows
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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.- Specified by:
removeCol
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - Parameters:
colIndices
- Indices of the columns to remove from this matrix.- Returns:
- a copy of this matrix with the specified columns removed.
-
swapRows
Swaps rows in the matrix.- Specified by:
swapRows
in interfaceMatrixManipulationsMixin<CsrCMatrix,
CNumber> - 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<CsrCMatrix,
CNumber> - Parameters:
colIndex1
- Index of first column to swap.colIndex2
- index of second column to swap.- Returns:
- A reference to 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.
-
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.
-
hashCode
-
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.
-
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.
-
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.
-
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.
-
toString
-