Class CooMatrix
- All Implemented Interfaces:
Serializable
,MatrixComparisonsMixin<CooMatrix>
,MatrixManipulationsMixin<CooMatrix,
,Double> MatrixMixin<CooMatrix,
,Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> MatrixOperationsMixin<CooMatrix,
,Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> MatrixPropertiesMixin
,RealMatrixMixin<CooMatrix,
,CooCMatrix> RealTensorMixin<CooMatrix,
,CooCMatrix> SparseTensorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CooMatrix>
,TensorOperationsMixin<CooMatrix,
,Matrix, CooCMatrix, CMatrix, CooMatrix, Double> TensorPropertiesMixin
Real sparse matrix. Matrix is stored in coordinate list (COO) format.
COO matrices are best suited for efficient modification and construction of sparse matrices. Coo matrices are not well
suited for matrix-matrix or matrix-vector multiplication (see CsrMatrix
).
If a sparse matrix needs to be incrementally constructed, then a COO matrix should be used to construct the matrix as it
allows for efficient modification. If the matrix then needs to be used in a matrix-matrix or matrix-vector multiplication
problem, it should first be converted to a CsrMatrix
in most cases.
- 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
ConstructorDescriptionCooMatrix
(int size) Creates a square sparse matrix of specified size filled with zeros.CooMatrix
(int size, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.CooMatrix
(int rows, int cols) Creates a sparse matrix of specified number of rows and columns filled with zeros.CooMatrix
(int size, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.CooMatrix
(int rows, int cols, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.CooMatrix
(int rows, int cols, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.Constructs a sparse tensor whose shape and values are given by another sparse tensor.Creates a sparse matrix of specified shape filled with zeros.Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.Creates a sparse matrix with specified shape, non-zero entries, and indices. -
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
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 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 between two tensors.boolean
Checks if an object is equal to this sparse COO 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.static CooMatrix
Constructs a sparse COO matrix from a dense matrix.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 i) Get a specified row of this matrix at and after a specified column.protected CooMatrix
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.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 a matrix is invertible.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 CooCMatrix
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 CooMatrix
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 matrices.Computes the matrix multiplication between two matrices.Multiplies this matrix with the transpose of theB
tensor as if by {this.mult(B.T())
.Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
.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 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.shape()
Gets the shape of this matrix.void
Sorts the indices of this tensor in lexicographical order while maintaining the associated value for each index.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.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 between two tensors of the same rank.sub
(CsrCMatrix 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.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.Converts this tensor to an equivalent complex tensor.toCsr()
Converts this COO matrix to an equivalent CSR 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.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, 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, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.MatrixOperationsMixin
augment, augment, mult, multTranspose, multTranspose, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack, stack
Methods inherited from interface org.flag4j.core.TensorOperationsMixin
transpose
-
Field Details
-
rowIndices
public final int[] rowIndicesRow 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
-
CooMatrix
public CooMatrix(int size) Creates a square sparse matrix of specified size filled with zeros.- Parameters:
size
- The number of rows/columns in this sparse matrix.
-
CooMatrix
public CooMatrix(int rows, int cols) Creates a sparse matrix of specified number of rows and columns filled with zeros.- Parameters:
rows
- The number of rows in this sparse matrix.cols
- The number of columns in this sparse matrix.
-
CooMatrix
Creates a sparse matrix of specified shape filled with zeros.- Parameters:
shape
- Shape of this sparse matrix.
-
CooMatrix
public CooMatrix(int size, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.- Parameters:
size
- Size of the square sparse matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.
-
CooMatrix
public CooMatrix(int rows, int cols, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.- Parameters:
rows
- The number of rows in this sparse matrix.cols
- The number of columns in this sparse matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.
-
CooMatrix
Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.- Parameters:
shape
- Shape of the sparse matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.
-
CooMatrix
public CooMatrix(int size, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.- Parameters:
size
- Size of the square matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.
-
CooMatrix
public CooMatrix(int rows, int cols, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.- Parameters:
rows
- The number of rows in this sparse matrix.cols
- The number of columns in this sparse matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.
-
CooMatrix
Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.- Parameters:
shape
- Shape of the sparse matrix.nonZeroEntries
- Non-zero entries of sparse matrix.rowIndices
- Row indices of the non-zero entries.colIndices
- Column indices of the non-zero entries.- Throws:
IllegalArgumentException
- If the number of non-zero entries does not fit within the given shape. Or, if the lengths of the non-zero entries, row indices, and column indices arrays are not all the same.
-
CooMatrix
Constructs a sparse tensor whose shape and values are given by another sparse tensor. This effectively copies the tensor.- Parameters:
A
- Sparse Matrix to copy.
-
CooMatrix
public CooMatrix(Shape shape, List<Double> entries, List<Integer> rowIndices, List<Integer> colIndices) Creates a sparse matrix with specified shape, non-zero entries, and indices.- Parameters:
shape
- Shape of the sparse matrix.entries
- Non-zero entries of the sparse matrix.rowIndices
- Non-zero row indices of the sparse matrix.colIndices
- Non-zero column indices of the sparse matrix.
-
-
Method Details
-
equals
Checks if an object is equal to this sparse COO matrix.- Specified by:
equals
in interfaceTensorComparisonsMixin
- Overrides:
equals
in classObject
- Parameters:
object
- Object to compare this sparse COO matrix to.- Returns:
- True if the object is a
CooMatrix
, has the same shape as this matrix, and is element-wise equal to this matrix.
-
fromDense
-
numRows
public int numRows()Gets the number of rows in this matrix.- Specified by:
numRows
in interfaceMatrixMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Returns:
- The number of columns in this matrix.
-
shape
Gets the shape of this matrix.- Specified by:
shape
in interfaceMatrixMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Returns:
- The shape of this matrix.
-
toCsr
Converts this COO matrix to an equivalent CSR matrix.- Returns:
- An equivalent sparse
CSR Matrix
.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
add
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
sub
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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
Computes the element-wise subtraction of two tensors of the same rank.- Specified by:
sub
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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
Adds specified value to all entries of this tensor.- Specified by:
sub
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, Double> - Returns:
- The transpose of this tensor.
-
get
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceMatrixMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
get
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
copy
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, Double> - Returns:
- A copy of this tensor.
-
elemMult
Computes the element-wise multiplication between two tensors.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
elemMult
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Specified by:
elemDiv
in interfaceTensorOperationsMixin<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, 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<CooMatrix,
Matrix, CooCMatrix, 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<CooMatrix,
Matrix, CooCMatrix, 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<CooMatrix,
Matrix, CooCMatrix, 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.
-
sortIndices
public void sortIndices()Sorts the indices of this tensor in lexicographical order while maintaining the associated value for each index.- Specified by:
sortIndices
in interfaceSparseTensorMixin
- Overrides:
sortIndices
in classRealSparseTensorBase<CooMatrix,
Matrix, CooCMatrix, CMatrix>
-
toDense
Converts this sparse tensor to an equivalent dense tensor.- Specified by:
toDense
in classSparseTensorBase<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, double[], Double> - Returns:
- A dense tensor which is equivalent to this sparse tensor.
-
isI
public boolean isI()Checks if this matrix is the identity matrix.- Specified by:
isI
in interfaceMatrixComparisonsMixin<CooMatrix>
- Returns:
- True if this matrix is the identity matrix. Otherwise, returns false.
-
set
Sets an index of this matrix to the specified value. For sparse matrices, a new copy of this matrix with the specified value set will be returned.- Specified by:
set
in interfaceMatrixManipulationsMixin<CooMatrix,
Double> - Parameters:
value
- Value to set.row
- Row index to set.col
- Column index to set.- Returns:
- A copy of this matrix with the specified value set.
-
set
Sets an index of this matrix to the specified value.- Specified by:
set
in interfaceMatrixManipulationsMixin<CooMatrix,
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<CooMatrix,
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<CooMatrix,
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<CooMatrix,
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.- 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<CooMatrix,
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<CooMatrix,
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<CooMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A copy of this matrix with the specified row set.
- 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<CooMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A copy of this matrix with the specified row set.
- 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<CooMatrix,
Double> - Parameters:
values
- New values for the row.rowIndex
- The index of the column which is to be set.- Returns:
- A copy of this matrix with the specified row set.
- 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<CooMatrix,
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<CooMatrix,
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<CooMatrix,
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<CooMatrix,
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<CooMatrix,
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.
-
removeRow
Removes a specified row from this matrix.- Specified by:
removeRow
in interfaceMatrixManipulationsMixin<CooMatrix,
Double> - 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<CooMatrix,
Double> - Parameters:
rowIndices
- The indices of the rows to remove from this matrix. The indices must be sorted and unique otherwise the behavior of this method is undefined.Arrays.sort(rowIndices)
must be called first if the array is not already sorted.- Returns:
- A copy of this matrix with the specified rows removed.
-
removeCol
Removes a specified column from this matrix.- Specified by:
removeCol
in interfaceMatrixManipulationsMixin<CooMatrix,
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<CooMatrix,
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 rows in the matrix.- Specified by:
swapRows
in interfaceMatrixManipulationsMixin<CooMatrix,
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<CooMatrix,
Double> - Parameters:
colIndex1
- Index of first column to swap.colIndex2
- index of second column to swap.- Returns:
- A reference to 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<CooMatrix,
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.
-
add
Computes the element-wise addition between two matrices.- Specified by:
add
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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 tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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
Description copied from interface:MatrixOperationsMixin
Computes the matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
b
- Vector to multiply this matrix to.- Returns:
- The vector result from multiplying this matrix by the vector
b
.
-
mult
Computes matrix-vector multiplication.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if by {this.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
multTranspose
Multiplies this matrix with the transpose of theB
tensor as if bythis.mult(B.T())
. For large matrices, this method may be significantly faster than directly computing the transpose followed by the multiplication asthis.mult(B.T())
.- Specified by:
multTranspose
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
B
- The second matrix in the multiplication and the matrix to transpose/- Returns:
- The result of multiplying this matrix with the transpose of
B
.
-
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 may be significantly faster for large matrices as it will not make superfluous copies.- Specified by:
pow
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
exponent
- The exponent in the matrix power. Ifexponent = 0
then the identity matrix will be returned.- Returns:
- The result of multiplying this matrix with itself 'exponent' times.
- Throws:
IllegalArgumentException
- Ifexponent
is negative.IllegalArgumentException
- If this sparse matrix is not square.
-
elemMult
Computes the element-wise multiplication (Hadamard product) between two matrices.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
-
elemDiv
Computes the element-wise division between two matrices.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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 vector will be treated as a row vector.
Also seeMatrixOperationsMixin.stack(Vector, int)
andaugment(Vector)
.- Specified by:
stack
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
Also seestack(Vector)
andMatrixOperationsMixin.stack(Vector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
Also seestack(CooVector)
andMatrixOperationsMixin.stack(CooVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
Also seestack(CVector)
andMatrixOperationsMixin.stack(CVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
Also seestack(CooCVector)
andMatrixOperationsMixin.stack(CooCVector, int)
.- Specified by:
augment
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Returns:
- A vector equivalent to this matrix.
-
toTensor
Converts this matrix to an equivalent sparse tensor.- Returns:
- A tensor which is equivalent to this matrix.
-
getSlice
Gets a specified slice of this matrix.- Specified by:
getSlice
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Parameters:
colStart
- Index of the row to begin at.i
- 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
- Ifi
orcolStart
is outside the bounds of this matrix.
-
setCol
Sets a column of this matrix.- Specified by:
setCol
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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. For real matrices, this is equivalent to the standard transpose.- Specified by:
H
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, Double, CooVector, Vector> - Returns:
- The complex conjugate transpose of this matrix.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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<CooMatrix,
Matrix, CooMatrix, CooCMatrix, CooCMatrix, 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.
-
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.
-
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.
-
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.
-
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.WARNING: This method will convert this matrix to a dense 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.WARNING: Currently, this method will convert this matrix to a dense matrix.
- Specified by:
isSingular
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is singular. Otherwise, returns false.
- See Also:
-
isInvertible
public boolean isInvertible()Checks if a matrix is invertible.- Specified by:
isInvertible
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is invertible.
- 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.
- 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<CooMatrix,
CooCMatrix> - 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<CooMatrix,
CooCMatrix> - 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<CooMatrix,
CooCMatrix> - 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<CooMatrix,
CooCMatrix> - 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<CooMatrix,
CooCMatrix> - Returns:
- A complex matrix which is equivalent to this matrix.
-
getSelf
Simply returns a reference of this tensor.- Specified by:
getSelf
in classTensorBase<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, double[], Double> - Returns:
- A reference to this tensor.
-
allClose
Description copied from class:TensorBase
Checks if all entries of this tensor are close to the entries of the argumenttensor
.- Specified by:
allClose
in classTensorBase<CooMatrix,
Matrix, CooCMatrix, CMatrix, CooMatrix, double[], Double> - 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. Note: Unlike with dense matrices, this will return a new copy of the sparse matrix.- Specified by:
set
in interfaceTensorManipulationsMixin<CooMatrix>
- Parameters:
value
- Value to set.indices
- The indices of this tensor for which to set the value.- Returns:
- A copy of this matrix with the specified value set.
- Throws:
IllegalArgumentException
- If there are not exactly twoindices
provided.
-
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<CooMatrix>
- 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<CooMatrix>
- Returns:
- The flattened tensor.
-
flatten
Flattens a tensor along the specified axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CooMatrix>
- Parameters:
axis
- Axis along which to flatten tensor.- Throws:
IllegalArgumentException
- If the axis is not positive or larger than the rank of this tensor.
-
toString
-