Package org.flag4j.arrays.sparse
Class CooCMatrix
java.lang.Object
org.flag4j.core.TensorBase<CooCMatrix,CMatrix,CooCMatrix,CMatrix,CooMatrix,CNumber[],CNumber>
org.flag4j.core.sparse_base.SparseTensorBase<CooCMatrix,CMatrix,CooCMatrix,CMatrix,CooMatrix,CNumber[],CNumber>
org.flag4j.core.sparse_base.ComplexSparseTensorBase<CooCMatrix,CMatrix,CooMatrix>
org.flag4j.arrays.sparse.CooCMatrix
- All Implemented Interfaces:
Serializable
,ComplexMatrixMixin<CooCMatrix>
,ComplexTensorMixin<CooCMatrix,
,CooMatrix> MatrixComparisonsMixin<CooCMatrix>
,MatrixManipulationsMixin<CooCMatrix,
,CNumber> MatrixMixin<CooCMatrix,
,CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> MatrixOperationsMixin<CooCMatrix,
,CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> MatrixPropertiesMixin
,SparseTensorMixin
,TensorComparisonsMixin
,TensorManipulationsMixin<CooCMatrix>
,TensorOperationsMixin<CooCMatrix,
,CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber> TensorPropertiesMixin
public class CooCMatrix
extends ComplexSparseTensorBase<CooCMatrix,CMatrix,CooMatrix>
implements MatrixMixin<CooCMatrix,CMatrix,CooCMatrix,CooCMatrix,CooCMatrix,CNumber,CooCVector,CVector>, ComplexMatrixMixin<CooCMatrix>
A Complex sparse matrix. Stored in coordinate list (COO) format.
- 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
ConstructorDescriptionCooCMatrix
(int size) Creates a square sparse matrix filled with zeros.CooCMatrix
(int size, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.CooCMatrix
(int rows, int cols) Creates a sparse matrix of specified size filled with zeros.CooCMatrix
(int size, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.CooCMatrix
(int rows, int cols, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.CooCMatrix
(int rows, int cols, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.CooCMatrix
(int rows, int cols, CNumber[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.CooCMatrix
(int size, CNumber[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a square sparse matrix with specified non-zero entries, row indices, and column indices.Constructs a sparse complex matrix whose non-zero entries, indices, and shape are specified by another complex sparse matrix.CooCMatrix
(Shape shape) Creates a sparse matrix of specified shape filled with zeros.CooCMatrix
(Shape shape, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.CooCMatrix
(Shape shape, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column indices.Creates a complex sparse matrix with specified shape, non-zero entries, and indices.CooCMatrix
(Shape shape, CNumber[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified shape, non-zero entries, row indices, and column 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
allClose
(CooCMatrix 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 between two tensors.Computes the element-wise multiplication (Hadamard product) between two matrices.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 CooCMatrix
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 CooCMatrix
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.Computes the conjugate transpose of this tensor.boolean
Checks if a matrix is anti-Hermitian.boolean
isDiag()
Checks if this matrix is diagonal.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 invertible.
Also seeisSingular()
.boolean
Checks if a matrix is singular.boolean
isSquare()
Checks if this matrix is square.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
Checks if this matrix is unitary.boolean
isVector()
Checks if a matrix can be represented as a vector.protected CooMatrix
makeRealTensor
(Shape shape, double[] entries, int[][] indices) A factory for creating a real sparse tensor.protected CooCMatrix
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.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 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.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.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.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.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 between 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 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.toCsr()
Converts this COO matrix to an equivalent CSR matrix.toDense()
Converts this sparse tensor to an equivalent dense tensor.toReal()
Converts a complex tensor to a real matrix.toString()
Formats this sparse matrix as a human-readable string.toTensor()
Converts this matrix to an equivalent complex 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, sqrt, sum, 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, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.core.ComplexMatrixMixin
conj, conjT, isComplex, isReal
-
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
-
CooCMatrix
public CooCMatrix(int size) Creates a square sparse matrix filled with zeros.- Parameters:
size
- size of the square matrix.
-
CooCMatrix
public CooCMatrix(int rows, int cols) Creates a sparse matrix of specified size filled with zeros.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in the sparse matrix.
-
CooCMatrix
Creates a sparse matrix of specified shape filled with zeros.- Parameters:
shape
- Shape of this sparse matrix.
-
CooCMatrix
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.- 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.
-
CooCMatrix
Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in 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.
-
CooCMatrix
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.
-
CooCMatrix
public CooCMatrix(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 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.
-
CooCMatrix
public CooCMatrix(int rows, int cols, double[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in 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.
-
CooCMatrix
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.
-
CooCMatrix
public CooCMatrix(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.- 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.
-
CooCMatrix
public CooCMatrix(int rows, int cols, int[] nonZeroEntries, int[] rowIndices, int[] colIndices) Creates a sparse matrix with specified size, non-zero entries, row indices, and column indices.- Parameters:
rows
- Number of rows in the sparse matrix.cols
- Number of columns in 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.
-
CooCMatrix
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.
-
CooCMatrix
public CooCMatrix(Shape shape, List<CNumber> entries, List<Integer> rowIndices, List<Integer> colIndices) Creates a complex 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.
-
CooCMatrix
Constructs a sparse complex matrix whose non-zero entries, indices, and shape are specified by another complex sparse matrix.- Parameters:
A
- Complex sparse matrix to copy.
-
-
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
CooCMatrix
, has the same shape as this matrix, and is element-wise equal to this matrix.
-
getSelf
Simply returns a reference of this tensor.- Specified by:
getSelf
in classTensorBase<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber[], CNumber> - 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<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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:
-
numRows
public int numRows()Gets the number of rows in this matrix.- Specified by:
numRows
in interfaceMatrixMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Returns:
- The number of columns in this matrix.
-
shape
Gets the shape of this matrix.- Specified by:
shape
in interfaceMatrixMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Returns:
- The shape of this matrix.
-
add
Computes the element-wise addition between two tensors of the same rank.- Specified by:
add
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
add
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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
Adds specified value to all entries of this tensor.- Specified by:
add
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
sub
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber> - Returns:
- The transpose of this tensor.
-
T
Computes the transpose of a tensor. Same astranspose()
.- Specified by:
T
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber> - Returns:
- The transpose of this tensor.
-
get
Gets the element in this tensor at the specified indices.- Specified by:
get
in interfaceMatrixMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
get
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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.
-
copy
Creates a copy of this tensor.- Specified by:
copy
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
copy
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber> - Returns:
- A copy of this tensor.
-
elemMult
Computes the element-wise multiplication between two tensors.- Specified by:
elemMult
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
elemMult
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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.
-
elemDiv
Computes the element-wise division between two tensors.- Specified by:
elemDiv
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Specified by:
elemDiv
in interfaceTensorOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, 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.
-
makeTensor
A factory for creating a complex sparse tensor.- Specified by:
makeTensor
in classComplexSparseTensorBase<CooCMatrix,
CMatrix, CooMatrix> - 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<CooCMatrix,
CMatrix, CooMatrix> - 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.
-
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 classComplexSparseTensorBase<CooCMatrix,
CMatrix, CooMatrix>
-
toDense
Converts this sparse tensor to an equivalent dense tensor.- Specified by:
toDense
in classSparseTensorBase<CooCMatrix,
CMatrix, CooCMatrix, CMatrix, CooMatrix, CNumber[], CNumber> - Returns:
- A dense tensor which is equivalent to this sparse tensor.
-
toCsr
Converts this COO matrix to an equivalent CSR matrix.- Returns:
- An equivalent matrix in
CSR format
.
-
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<CooCMatrix>
- 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<CooCMatrix>
- Returns:
- True if this matrix is antisymmetric. 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<CooCMatrix>
- 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<CooCMatrix>
- 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.
-
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 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<CooCMatrix>
- 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<CooCMatrix>
- 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.- 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.
-
hermTranspose
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 asH()
.- Specified by:
hermTranspose
in interfaceComplexTensorMixin<CooCMatrix,
CooMatrix> - Returns:
- The complex transpose of this tensor.
-
add
Computes the element-wise addition between two matrices.- Specified by:
add
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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
.
-
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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - 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.- Specified by:
pow
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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.
-
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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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
.
-
toTensor
Converts this matrix to an equivalent complex tensor.- Returns:
- A tensor which is equivalent to this matrix.
-
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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Returns:
- A vector equivalent to this matrix.
-
toReal
Description copied from class:ComplexSparseTensorBase
Converts a complex tensor to a real matrix. The imaginary component of any complex value will be ignored.- Specified by:
toReal
in interfaceComplexTensorMixin<CooCMatrix,
CooMatrix> - Overrides:
toReal
in classComplexSparseTensorBase<CooCMatrix,
CMatrix, CooMatrix> - Returns:
- A tensor of the same size containing only the real components of this tensor.
- See Also:
-
fromDense
Constructs a sparse COO matrix from a dense matrix. Any value that is not exactly zero will be considered a non-zero value.- Parameters:
src
- Dense matrix to convert to sparse COO matrix.- Returns:
- An sparse COO matrix equivalent to the dense
src
matrix.
-
getSlice
Gets a specified slice of this matrix.- Specified by:
getSlice
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - 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 interfaceComplexMatrixMixin<CooCMatrix>
- Specified by:
setCol
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Returns:
- A vector containing the diagonal entries of this matrix.
-
mult
Computes the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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 the matrix multiplication between two matrices.- Specified by:
mult
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, 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.
-
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 ashermTranspose()
andComplexMatrixMixin.conjT()
.- Specified by:
H
in interfaceComplexMatrixMixin<CooCMatrix>
- Specified by:
H
in interfaceComplexTensorMixin<CooCMatrix,
CooMatrix> - Specified by:
H
in interfaceMatrixOperationsMixin<CooCMatrix,
CMatrix, CooCMatrix, CooCMatrix, CooCMatrix, CNumber, CooCVector, CVector> - Returns:
- The complex transpose of this tensor.
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceComplexTensorMixin<CooCMatrix,
CooMatrix> - 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.
-
flatten
Flattens a tensor along the specified axis.- Specified by:
flatten
in interfaceTensorManipulationsMixin<CooCMatrix>
- Parameters:
axis
- Axis along which to flatten tensor.- Throws:
IllegalArgumentException
- If the axis is not positive or larger than the rank of this tensor.
-
isI
public boolean isI()Checks if this matrix is the identity matrix.- Specified by:
isI
in interfaceMatrixComparisonsMixin<CooCMatrix>
- 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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix>
- Specified by:
setCol
in interfaceMatrixManipulationsMixin<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix>
- Specified by:
setRow
in interfaceMatrixManipulationsMixin<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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 interfaceComplexMatrixMixin<CooCMatrix>
- Specified by:
setSlice
in interfaceMatrixManipulationsMixin<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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<CooCMatrix,
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.
-
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.- 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.
Also seeisInvertible()
.- Specified by:
isSingular
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is singular. Otherwise, returns false.
-
isInvertible
public boolean isInvertible()Checks if a matrix is invertible.
Also seeisSingular()
.- Specified by:
isInvertible
in interfaceMatrixPropertiesMixin
- Returns:
- True if this matrix is invertible.
-
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.- Specified by:
matrixRank
in interfaceMatrixPropertiesMixin
- Returns:
- The matrix rank of this matrix.
-
set
Sets an index of this tensor to a specified value.- Specified by:
set
in interfaceTensorManipulationsMixin<CooCMatrix>
- 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<CooCMatrix>
- 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<CooCMatrix>
- Returns:
- The flattened tensor.
-
toString
-