Class AbstractCooRingVector<T extends AbstractCooRingVector<T,U,V,W,Y>,U extends AbstractDenseRingVector<U,W,Y>,V extends AbstractCooRingMatrix<V,W,T,Y>,W extends AbstractDenseRingMatrix<W,U,Y>,Y extends Ring<Y>>
- Type Parameters:
T- Type of this vector.U- Type of equivalent dense vector.V- Type of matrix equivalent toT.W- Type of dense matrix equivalent toU.Y- Type of the arrays element in this vector.
- All Implemented Interfaces:
Serializable,RingTensorMixin<T,,U, Y> TensorOverRing<T,,U, Y[], Y> SemiringTensorMixin<T,,U, Y> TensorOverSemiring<T,,U, Y[], Y> VectorMixin<T,V, W, Y>
- Direct Known Subclasses:
AbstractCooFieldVector,CooRingVector
A sparse vector stored in coordinate list (COO) format. The AbstractTensor.data of this COO vector are
elements of a Ring.
The non-zero data and non-zero indices of a COO vector are mutable but the AbstractTensor.shape
and total number of non-zero data is fixed.
Sparse vectors allow for the efficient storage of and ops on large vectors that contain many zero values.
COO vectors are optimized for large hyper-sparse vectors (i.e. vectors which contain almost all zeros relative to the size of the vector).
A sparse COO vector is stored as:
- The full
AbstractTensor.shape/VectorMixin.size()of the vector. - The non-zero
AbstractTensor.dataof the vector. All other data in the vector are assumed to be zero. Zero values can also explicitly be stored inAbstractTensor.data. - The
AbstractCooSemiringVector.indicesof the non-zero values in the sparse vector.
Note: many ops assume that the data of the COO vector are sorted lexicographically. However, this is not explicitly verified. Every operation implemented in this class will preserve the lexicographical sorting.
If indices need to be sorted for any reason, call AbstractCooSemiringVector.sortIndices().
- See Also:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringVector
indices, nnz, size, sparsityFields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCooRingVector(Shape shape, Y[] entries, int[] indices) Creates a COO vector with the specified data and shape.protectedAbstractCooRingVector(Shape shape, Y[] data, int[] indices, Object dummy) Creates a tensor with the specified data and shape without performing any validation on the parameters. -
Method Summary
Modifier and TypeMethodDescriptionH(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.Computes the inner product between two vectors.Computes the element-wise difference between two tensors of the same shape.Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringVector
add, coalesce, coalesce, copy, dataLength, density, dot, dropZeros, elemMult, flatten, flatten, get, get, getZeroElement, join, length, mag, makeLikeDenseMatrix, makeLikeDenseTensor, makeLikeMatrix, makeLikeTensor, makeLikeTensor, normalize, outer, repeat, reshape, set, setZeroElement, sortIndices, sparsity, stack, T, T, tensorDot, tensorTr, toDense, toMatrix, toTensor, toTensorMethods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, T, 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.ring_arrays.RingTensorMixin
add, 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.semiring_arrays.SemiringTensorMixin
argmax, argmin, max, minMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
abs, H
-
Constructor Details
-
AbstractCooRingVector
Creates a COO vector with the specified data and shape.- Parameters:
shape- Shape of the vector.entries- The non-zero entries of the vector.indices- The If this tensor is sparse, this specifies only the non-zero data of the tensor.
-
AbstractCooRingVector
Creates a tensor with the specified data and shape without performing any validation on the parameters.- Parameters:
shape- Shape of this tensor.data- Non-zero entries of the tensor.indices- Non-zero entries of the tensor.dummy- Dummy object to distinguish this constructor from the safe variant.
-
-
Method Details
-
inner
Computes the inner product between two vectors.
Note: this method is distinct from
dot(AbstractCooSemiringVector). The inner product is equivalent to the dot product of this tensor with the conjugation ofb.- Specified by:
innerin interfaceVectorMixin<T extends AbstractCooRingVector<T,U, V, W, Y>, U extends AbstractDenseRingVector<U, W, Y>, V extends AbstractCooRingMatrix<V, W, T, Y>, W extends AbstractDenseRingMatrix<W, U, Y>> - Overrides:
innerin classAbstractCooSemiringVector<T extends AbstractCooRingVector<T,U, V, W, Y>, U extends AbstractDenseRingVector<U, W, Y>, V extends AbstractCooRingMatrix<V, W, T, Y>, W extends AbstractDenseRingMatrix<W, U, Y>, Y extends Ring<Y>> - Parameters:
b- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector
b. - Throws:
IllegalArgumentException- If this vector and vectorbdo not have the same number of data.- See Also:
-
sub
Computes the element-wise difference between two tensors of the same shape.- Specified by:
subin interfaceTensorOverRing<T extends AbstractCooRingVector<T,U, V, W, Y>, U extends AbstractDenseRingVector<U, W, Y>, V extends AbstractCooRingMatrix<V, W, T, Y>, W extends AbstractDenseRingMatrix<W, U, Y>> - Parameters:
b- Second tensor in the element-wise difference.- Returns:
- The difference of this tensor with
b. - Throws:
TensorShapeException- If this tensor andbdo not have the same shape.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractCooRingVector<T,U, V, W, Y>, U extends AbstractDenseRingVector<U, W, Y>, V extends AbstractCooRingMatrix<V, W, T, Y>, W extends AbstractDenseRingMatrix<W, U, Y>> - 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 AbstractCooRingVector<T,U, V, W, Y>, U extends AbstractDenseRingVector<U, W, Y>, V extends AbstractCooRingMatrix<V, W, T, Y>, W extends AbstractDenseRingMatrix<W, U, Y>> - 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:
-