Class AbstractCsrFieldMatrix<T extends AbstractCsrFieldMatrix<T,U,V,W>,U extends AbstractDenseFieldMatrix<U,?,W>,V extends AbstractCooFieldVector<V,?,?,U,W>,W extends Field<W>>
- All Implemented Interfaces:
Serializable
,FieldTensorMixin<T,
,U, W> TensorOverField<T,
,U, W[], W> MatrixMixin<T,
,U, V, W> RingTensorMixin<T,
,U, W> TensorOverRing<T,
,U, W[], W> SemiringTensorMixin<T,
,U, W> TensorOverSemiring<T,
U, W[], W>
- Direct Known Subclasses:
CsrCMatrix
,CsrFieldMatrix
- See Also:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCsrSemiringMatrix
colIndices, nnz, numCols, numRows, rowPointers, sparsity, zeroElement
Fields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCsrFieldMatrix
(Shape shape, W[] entries, int[] rowPointers, int[] colIndices) Creates a sparse CSR matrix with the specifiedshape
, non-zero data, row pointers, and non-zero column indices. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Computes the element-wise absolute value of this tensor.Computes the element-wise quotient between two tensors.H()
Computes the Hermitian transpose of this matrix.H
(int... axes) Computes the conjugate transpose of this tensor.H
(int axis1, int axis2) Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.boolean
isFinite()
Checks if this tensor only contains finite values.boolean
Checks if a matrix is Hermitian.boolean
Checks if this tensor contains at least one infinite value.boolean
isNaN()
Checks if this tensor contains at least one NaN value.boolean
Checks if this matrix is orthogonal.Computes the matrix multiplication between two sparse CSR matrices and stores the result in a sparse matrix.sqrt()
Computes the element-wise square root of this tensor.Methods inherited from class org.flag4j.arrays.backend.ring_arrays.AbstractCsrRingMatrix
allClose, allClose, sub
Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCsrSemiringMatrix
add, augment, augment, copy, dataLength, density, elemMult, flatten, flatten, get, get, getSlice, getTriL, getTriU, getZeroElement, isI, isOrthogonal, isSymmetric, isTriL, isTriU, makeLikeCooMatrix, makeLikeDenseTensor, makeLikeTensor, makeLikeTensor, mult, multToSparse, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, reshape, set, set, setCol, setRow, setSliceCopy, setZeroElement, sortIndices, sparsity, stack, swapCols, swapRows, T, T, T, tensorTr, toCoo, toDense, toTensor, toTensor, toVector, tr
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntries
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.flag4j.arrays.backend.field_arrays.FieldTensorMixin
add, add, addEq, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, div, div, divEq, divEq, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, mult, multEq, multEq, norm, norm, prod, recip, sub, sub, subEq, subEq, sum
Methods inherited from interface org.flag4j.arrays.backend.MatrixMixin
accept, add, augment, augment, copy, dataLength, elemMult, fib, get, getCol, getCol, getDiag, getDiag, getRow, getRow, getShape, getSlice, getTriL, getTriL, getTriU, getTriU, isDiag, isI, isOrthogonal, isSquare, isSymmetric, isTri, isTriL, isTriU, isVector, mult, mult, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, set, setCol, setRow, setSliceCopy, stack, stack, sub, swapCols, swapRows, T, toVector, tr, trace, vectorType
Methods inherited from interface org.flag4j.arrays.backend.semiring_arrays.SemiringTensorMixin
argmax, argmin, max, min
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
sub
-
Constructor Details
-
AbstractCsrFieldMatrix
Creates a sparse CSR matrix with the specifiedshape
, non-zero data, row pointers, and non-zero column indices.- Parameters:
shape
- Shape of this tensor.entries
- The non-zero data of this CSR matrix.rowPointers
- The row pointers for the non-zero values in the sparse CSR matrix.rowPointers[i]
indicates the starting index withindata
andcolData
of all values in rowi
.colIndices
- Column indices for each non-zero value in this sparse CSR matrix. Must satisfydata.length == colData.length
.
-
-
Method Details
-
mult2Csr
Computes the matrix multiplication between two sparse CSR matrices and stores the result in a sparse matrix.
Warning: this method should be used with caution as sparse-sparse matrix multiplication may result in a dense matrix. In such a case, this method will likely be significantly slower than
AbstractCsrSemiringMatrix.mult(AbstractCsrSemiringMatrix)
.- Parameters:
b
- Second matrix in the matrix multiplication.- Returns:
- The result of matrix multiplying this matrix with matrix
b
as a sparse CSR matrix. - See Also:
-
isHermitian
public boolean isHermitian()Checks if a matrix is Hermitian. That is, if the matrix is square and equal to its conjugate transpose.- Specified by:
isHermitian
in interfaceMatrixMixin<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
isHermitian
in classAbstractCsrSemiringMatrix<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
true
if this matrix is Hermitian;false
otherwise.
-
isUnitary
public boolean isUnitary()Checks if this matrix is orthogonal. That is, if the inverse of this matrix is equal to its transpose.- Returns:
true
if this matrix it is orthogonal;false
otherwise.
-
abs
Computes the element-wise absolute value of this tensor.- Specified by:
abs
in interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
- The element-wise absolute value of this tensor.
-
H
Computes the Hermitian transpose of this matrix.- Specified by:
H
in interfaceMatrixMixin<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Specified by:
H
in interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
H
in classAbstractCsrRingMatrix<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
- The Hermitian transpose of this matrix.
- See Also:
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.- Specified by:
H
in interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
H
in classAbstractCsrRingMatrix<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Parameters:
axis1
- First axis to exchange and conjugate.axis2
- Second axis to exchange and conjugate.- Returns:
- The conjugate transpose of this tensor according to the specified axes.
- Throws:
IndexOutOfBoundsException
- If eitheraxis1
oraxis2
are out of bounds for the rank of this tensor.- See Also:
-
H
Computes the conjugate transpose of this tensor. That is, conjugates and permutes the axes of this tensor so that it matches the permutation specified byaxes
.- Specified by:
H
in interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
H
in classAbstractCsrRingMatrix<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Parameters:
axes
- Permutation of tensor axis. If the tensor has rankN
, then this must be an array of lengthN
which is a permutation of{0, 1, 2, ..., N-1}
.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axes
array. - Throws:
IndexOutOfBoundsException
- If any element ofaxes
is out of bounds for the rank of this tensor.IllegalArgumentException
- Ifaxes
is not a permutation of{1, 2, 3, ... N-1}
.- See Also:
-
div
Computes the element-wise quotient between two tensors.
WARNING: This method is not supported for sparse tensors. If called on a sparse tensor, an
UnsupportedOperationException
will be thrown. Element-wise division is undefined for sparse matrices as it would almost certainly result in a division by zero.- Specified by:
div
in interfaceMatrixMixin<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Specified by:
div
in interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
div
in classAbstractCsrRingMatrix<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Parameters:
b
- Second tensor in the element-wise quotient.- Returns:
- The element-wise quotient of this tensor with
b
. - Throws:
UnsupportedOperationException
- if this method is ever invoked on a sparse tensor.
-
sqrt
Computes the element-wise square root of this tensor.- Specified by:
sqrt
in interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
- The element-wise square root of this tensor.
-
isFinite
public boolean isFinite()Checks if this tensor only contains finite values.- Specified by:
isFinite
in interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
true
if this tensor only contains finite values;false
otherwise.- See Also:
-
isInfinite
public boolean isInfinite()Checks if this tensor contains at least one infinite value.- Specified by:
isInfinite
in interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
true
if this tensor contains at least one infinite value;false
otherwise.- See Also:
-
isNaN
public boolean isNaN()Checks if this tensor contains at least one NaN value.- Specified by:
isNaN
in interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,
U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
true
if this tensor contains at least one NaN value;false
otherwise.- See Also:
-