Class CooSemiringVector<T extends Semiring<T>>

Type Parameters:
T - The type of elements stored in this vector, constrained by the Semiring interface.
All Implemented Interfaces:
Serializable, SemiringTensorMixin<CooSemiringVector<T>,SemiringVector<T>,T>, TensorOverSemiring<CooSemiringVector<T>,SemiringVector<T>,T[],T>, VectorMixin<CooSemiringVector<T>,CooSemiringMatrix<T>,SemiringMatrix<T>,T>

public class CooSemiringVector<T extends Semiring<T>> extends AbstractCooSemiringVector<CooSemiringVector<T>,SemiringVector<T>,CooSemiringMatrix<T>,SemiringMatrix<T>,T>
Represents a sparse vector whose non-zero elements are stored in Coordinate List (COO) format, with all data elements belonging to a specified Semiring type.

The COO format stores sparse vector data as a list of coordinates (indices) coupled with their corresponding non-zero values, rather than allocating memory for every element in the full vector shape. This allows efficient representation and manipulation of large vector containing a substantial number of zeros.

A sparse COO vector is stored as:

The total number of non-zero elements (AbstractCooSemiringVector.nnz) and the shape/size is fixed for a given instance, but the values in AbstractTensor.data and their corresponding AbstractCooSemiringVector.indices may be updated. Many operations assume that the indices are sorted lexicographically, but this is not strictly enforced. All provided operations preserve the lexicographical sorting of indices. If there is any doubt about the ordering of indices, use AbstractCooSemiringVector.sortIndices() to ensure they are sorted. COO tensors may also store multiple entries for the same index (referred to as an uncoalesced tensor). To combine all duplicated entries use AbstractCooSemiringVector.coalesce() or AbstractCooSemiringVector.coalesce(BinaryOperator).

COO vectors are optimized for "hyper-sparse" scenarios where the proportion of non-zero elements is extremely low, offering significant memory savings and potentially more efficient computational operations than equivalent dense representations.

Example Usage:


 // shape, data, and indices for COO vector.
 Shape shape = new Shape(512);
 BoolSemiring[] data = {
      new BoolSemiring(true),  new BoolSemiring(false), new BoolSemiring(false),
      new BoolSemiring(false), new BoolSemiring(true),  new BoolSemiring(true)
 };
 int[] indices = {0, 4, 128, 128, 128, 256};

 // Create COO vector.
 CooSemiringVector<BoolSemiring> vector = new CooSemiringVector(shape, data, indices);

 // Sum vectors.
 CooSemiringVector<BoolSemiring> sum = vector.add(vector);

 // Compute vector inner product.
 BoolSemiring prod = vector.inner(vector);

 // Compute vector outer product.
 SemiringMatrix<BoolSemiring> prod = vector.outer(vector);
 
See Also: