Class AbstractCooRingMatrix<T extends AbstractCooRingMatrix<T,U,V,W>,U extends AbstractDenseRingMatrix<U,?,W>,V extends AbstractCooRingVector<V,?,T,U,W>,W extends Ring<W>>            
- Type Parameters:
- T- Type of this sparse COO matrix.
- U- Type of dense matrix which is similar to- T.
- V- Type of sparse COO vector which is similar to- T.
- W- Type of the arrays element in this matrix.
- All Implemented Interfaces:
- Serializable,- 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:
- AbstractCooFieldMatrix,- CooRingMatrix
A sparse matrix stored in coordinate list (COO) format. The AbstractTensor.data of this COO matrix are
 elements of a Ring.
 
The non-zero data and non-zero indices of a COO matrix are mutable but the AbstractTensor.shape
 and total number of non-zero data is fixed.
 
Sparse matrices allow for the efficient storage of and ops on matrices that contain many zero values.
COO matrices are optimized for hyper-sparse matrices (i.e. matrices which contain almost all zeros relative to the size of the matrix).
COO Representation:
A sparse COO matrix is stored as:- The full shapeof the matrix.
- The non-zero AbstractTensor.dataof the matrix. All other data in the matrix are assumed to be zero. Zero values can also explicitly be stored inAbstractTensor.data.
- The row indicesof the non-zero values in the sparse matrix.
- The column indicesof the non-zero values in the sparse matrix.
Note: many ops assume that the data of the COO matrix are sorted lexicographically by the row and column indices. (i.e.) by row indices first then column indices. However, this is not explicitly verified but any ops implemented in this class will preserve the lexicographical sorting.
If indices need to be sorted, call AbstractCooSemiringMatrix.sortIndices().
- See Also:
- 
Field SummaryFields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringMatrixcolIndices, nnz, numCols, numRows, rowIndices, sparsity, zeroElementFields inherited from class org.flag4j.arrays.backend.AbstractTensordata, rank, shape
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractCooRingMatrix(Shape shape, W[] entries, int[] rowIndices, int[] colIndices) Creates a sparse coo matrix with the specified non-zero data, non-zero indices, and shape.protectedAbstractCooRingMatrix(Shape shape, W[] entries, int[] rowIndices, int[] colIndices, Object dummy) Creates a sparse coo matrix with the specified non-zero data, non-zero indices, and shape.
- 
Method SummaryModifier and TypeMethodDescriptionH()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.booleanChecks if the matrix is "close" to an identity matrix.abstract AbstractCsrRingMatrix<?, U, V, W> makeLikeCsrMatrix(Shape shape, W[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse CSR matrix of a similar type to this sparse COO matrix.Computes the element-wise difference between two tensors of the same shape.AbstractCsrRingMatrix<?, U, V, W> toCsr()Converts this sparse COO matrix to an equivalent sparse CSR matrix.abstract AbstractCooRingTensor<?, ?, W> toTensor()Converts this matrix to an equivalent tensor.abstract AbstractCooRingTensor<?, ?, W> Converts this matrix to an equivalent tensor with the specified shape.Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringMatrixadd, argmax, argmin, augment, augment, coalesce, coalesce, copy, dataLength, density, dropZeros, elemMult, flatten, flatten, get, get, getCol, getDiag, getRow, getSlice, getTriL, getTriU, getZeroElement, isHermitian, isI, isOrthogonal, isSymmetric, isTriL, isTriU, makeLikeDenseTensor, makeLikeTensor, makeLikeTensor, makeLikeVector, max, min, mult, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, reshape, set, set, setCol, setRow, setSliceCopy, setZeroElement, sortIndices, sparsity, stack, swapCols, swapRows, T, T, T, tensorTr, toDense, toVector, trMethods inherited from class org.flag4j.arrays.backend.AbstractTensorgetData, getRank, getShape, makeLikeTensor, reshape, sameShape, totalEntriesMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flag4j.arrays.backend.MatrixMixinaccept, add, augment, augment, copy, dataLength, div, elemMult, fib, get, getCol, getCol, getDiag, getDiag, getRow, getRow, getShape, getSlice, getTriL, getTriL, getTriU, getTriU, isDiag, isHermitian, isI, isOrthogonal, isSquare, isSymmetric, isTri, isTriL, isTriU, isVector, mult, mult, multTranspose, numCols, numRows, removeCol, removeCols, removeRow, removeRows, set, setCol, setRow, setSliceCopy, stack, stack, swapCols, swapRows, T, toVector, tr, trace, vectorTypeMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.RingTensorMixinadd, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, multEq, norm, norm, prod, sub, subEq, sumMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRingabs
- 
Constructor Details- 
AbstractCooRingMatrixCreates a sparse coo matrix with the specified non-zero data, non-zero indices, and shape.- Parameters:
- shape- Shape of this tensor.
- entries- Non-zero data of this sparse matrix.
- rowIndices- Non-zero row indices of this sparse matrix.
- colIndices- Non-zero column indies of this sparse matrix.
 
- 
AbstractCooRingMatrixprotected AbstractCooRingMatrix(Shape shape, W[] entries, int[] rowIndices, int[] colIndices, Object dummy) Creates a sparse coo matrix with the specified non-zero data, non-zero indices, and shape.- Parameters:
- shape- Shape of this tensor.
- entries- Non-zero data of this sparse matrix.
- rowIndices- Non-zero row indices of this sparse matrix.
- colIndices- Non-zero column indies of this sparse matrix.
- dummy- Dummy object to distinguish this constructor from the safe variant.
 
 
- 
- 
Method Details- 
makeLikeCsrMatrixpublic abstract AbstractCsrRingMatrix<?,U, makeLikeCsrMatrixV, W> (Shape shape, W[] entries, int[] rowPointers, int[] colIndices) Constructs a sparse CSR matrix of a similar type to this sparse COO matrix.- Specified by:
- makeLikeCsrMatrixin class- AbstractCooSemiringMatrix<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Parameters:
- shape- Shape of the CSR matrix to construct.
- entries- Non-zero data of the CSR matrix.
- rowPointers- Non-zero row pointers of the CSR matrix.
- colIndices- Non-zero column indices of the CSR matrix.
- Returns:
- A CSR matrix of a similar type to this sparse COO matrix.
 
- 
toCsrConverts this sparse COO matrix to an equivalent sparse CSR matrix.
- 
toTensorConverts this matrix to an equivalent tensor.
- 
toTensorConverts this matrix to an equivalent tensor with the specified shape.- Specified by:
- toTensorin class- AbstractCooSemiringMatrix<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Parameters:
- newShape- New shape for the tensor. Can be any rank but must be broadcastable to- this.shape.
- Returns:
- A tensor equivalent to this matrix which has been reshaped to newShape
 
- 
subComputes the element-wise difference between two tensors of the same shape.- Specified by:
- subin interface- MatrixMixin<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Specified by:
- subin interface- TensorOverRing<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Parameters:
- b- Second tensor in the element-wise difference.
- Returns:
- The difference of this tensor with b.
- Throws:
- TensorShapeException- If this tensor and- bdo not have the same shape.
 
- 
HComputes the Hermitian transpose of this matrix.- Specified by:
- Hin interface- MatrixMixin<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Specified by:
- Hin interface- TensorOverRing<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Overrides:
- Hin class- AbstractCooSemiringMatrix<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Returns:
- The Hermitian transpose of this matrix.
- See Also:
 
- 
HComputes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.- Specified by:
- Hin interface- TensorOverRing<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<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 either- axis1or- axis2are out of bounds for the rank of this tensor.
- See Also:
 
- 
HComputes 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 interface- TensorOverRing<T extends AbstractCooRingMatrix<T,- U, - V, - W>, - U extends AbstractDenseRingMatrix<U, - ?, - W>, - V extends AbstractCooRingVector<V, - ?, - T, - U, - W>, - W extends Ring<W>> 
- Parameters:
- axes- Permutation of tensor axis. If the tensor has rank- N, then this must be an array of length- Nwhich 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 of- axesis out of bounds for the rank of this tensor.
- IllegalArgumentException- If- axesis not a permutation of- {1, 2, 3, ... N-1}.
- See Also:
 
- 
isCloseToIpublic boolean isCloseToI()Checks if the matrix is "close" to an identity matrix. Two entriesxandyare considered "close" if they satisfy the following:|x-y| <= (1E-08 + 1E-05*|y|)- Returns:
- trueif the matrix is approximately an identity matrix, otherwise- false.
 
 
-