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
.Y
- 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.data
of the vector. All other data in the vector are assumed to be zero. Zero values can also explicitly be stored inAbstractTensor.data
. - The
AbstractCooSemiringVector.indices
of 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, sparsity
Fields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCooRingVector
(Shape shape, Y[] entries, int[] indices) Creates a COO vector with the specified data and shape. -
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 exchangingaxis1
andaxis2
.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, 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, toTensor
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, T, 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.ring_arrays.RingTensorMixin
add, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, multEq, norm, norm, prod, sub, subEq, sum
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
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.
-
-
Method Details
-
inner
Computes the inner product between two vectors.
Note: this method is distinct from
AbstractCooSemiringVector.dot(AbstractCooSemiringVector)
. The inner product is equivalent to the dot product of this tensor with the conjugation ofb
.- Specified by:
inner
in 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:
inner
in 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 vectorb
do not have the same number of data.- See Also:
-
sub
Computes the element-wise difference between two tensors of the same shape.- Specified by:
sub
in 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 andb
do not have the same shape.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.- Specified by:
H
in 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 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 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 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:
-