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, zeroElementFields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCsrFieldMatrix(Shape shape, W[] data, int[] rowPointers, int[] colIndices) Creates a sparse CSR matrix with the specifiedshape, non-zero data, row pointers, and non-zero column indices.protectedAbstractCsrFieldMatrix(Shape shape, W[] data, int[] rowPointers, int[] colIndices, Object dummy) 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 exchangingaxis1andaxis2.booleanisFinite()Checks if this tensor only contains finite values.booleanChecks if a matrix is Hermitian.booleanChecks if this tensor contains at least one infinite value.booleanisNaN()Checks if this tensor contains at least one NaN value.booleanChecks 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, subMethods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCsrSemiringMatrix
add, augment, augment, coalesce, coalesce, 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, trMethods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, sumMethods 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, vectorTypeMethods inherited from interface org.flag4j.arrays.backend.semiring_arrays.SemiringTensorMixin
argmax, argmin, max, minMethods 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.data- 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 withindataandcolDataof all values in rowi.colIndices- Column indices for each non-zero value in this sparse CSR matrix. Must satisfydata.length == colData.length.
-
AbstractCsrFieldMatrix
protected AbstractCsrFieldMatrix(Shape shape, W[] data, int[] rowPointers, int[] colIndices, Object dummy) Creates a sparse CSR matrix with the specifiedshape, non-zero data, row pointers, and non-zero column indices.- Parameters:
shape- Shape of this tensor.data- 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 withindataandcolDataof all values in rowi.colIndices- Column indices for each non-zero value in this sparse CSR matrix. Must satisfydata.length == colData.length.dummy- Dummy object to distinguish this constructor from the safe variant. It is completely ignored in this constructor.
-
-
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
bas 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:
isHermitianin interfaceMatrixMixin<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
isHermitianin classAbstractCsrSemiringMatrix<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
trueif this matrix is Hermitian;falseotherwise.
-
isUnitary
public boolean isUnitary()Checks if this matrix is orthogonal. That is, if the inverse of this matrix is equal to its transpose.- Returns:
trueif this matrix it is orthogonal;falseotherwise.
-
abs
Computes the element-wise absolute value of this tensor.- Specified by:
absin 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:
Hin 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:
Hin interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
Hin 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 exchangingaxis1andaxis2.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
Hin 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 eitheraxis1oraxis2are 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:
Hin interfaceTensorOverRing<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
Hin 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 lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axesarray. - Throws:
IndexOutOfBoundsException- If any element ofaxesis out of bounds for the rank of this tensor.IllegalArgumentException- Ifaxesis 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
UnsupportedOperationExceptionwill be thrown. Element-wise division is undefined for sparse matrices as it would almost certainly result in a division by zero.- Specified by:
divin 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:
divin interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Overrides:
divin 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:
sqrtin 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:
isFinitein interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
trueif this tensor only contains finite values;falseotherwise.- See Also:
-
isInfinite
public boolean isInfinite()Checks if this tensor contains at least one infinite value.- Specified by:
isInfinitein interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
trueif this tensor contains at least one infinite value;falseotherwise.- See Also:
-
isNaN
public boolean isNaN()Checks if this tensor contains at least one NaN value.- Specified by:
isNaNin interfaceTensorOverField<T extends AbstractCsrFieldMatrix<T,U, V, W>, U extends AbstractDenseFieldMatrix<U, ?, W>, V extends AbstractCooFieldVector<V, ?, ?, U, W>, W extends Field<W>> - Returns:
trueif this tensor contains at least one NaN value;falseotherwise.- See Also:
-