java.lang.Object
org.flag4j.linalg.ops.sparse.coo.semiring_ops.CooSemiringVectorOps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Semiring<T>>
SparseVectorData<Semiring<T>> add
(Shape shape1, Semiring<T>[] src1, int[] src1Indices, Shape shape2, Semiring<T>[] src2, int[] src2Indices) Computes the element-wise vector addition between two real sparse vectors.dot
(Shape shape1, Semiring<T>[] src1, int[] src1Indices, Shape shape2, Semiring<T>[] src2, int[] src2Indices) Computes the dot product between two sparse COO vectors.static <T extends Semiring<T>>
SparseVectorData<Semiring<T>> Computes the element-wise vector multiplication between two real sparse vectors.static <T extends Semiring<T>>
voidouterProduct
(Semiring<T>[] src1, int[] src1Indices, int src1Size, Semiring<T>[] src2, int[] src2Indices, Semiring<T>[] dest) Computes the vector outer product between two sparse COO vectors.
-
Constructor Details
-
CooSemiringVectorOps
private CooSemiringVectorOps()
-
-
Method Details
-
add
public static <T extends Semiring<T>> SparseVectorData<Semiring<T>> add(Shape shape1, Semiring<T>[] src1, int[] src1Indices, Shape shape2, Semiring<T>[] src2, int[] src2Indices) Computes the element-wise vector addition between two real sparse vectors. Both sparse vectors are assumed to have their indices sorted lexicographically.- Parameters:
src1
- First sparse vector in the addition. Indices assumed to be sorted lexicographically.src2
- Second sparse vector in the addition. Indices assumed to be sorted lexicographically.- Returns:
- A data class containing the non-zero entries and indices of the sparse COO vector resulting from the vector addition.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same size (full size including zeros).
-
elemMult
public static <T extends Semiring<T>> SparseVectorData<Semiring<T>> elemMult(Semiring<T>[] src1, int[] src1Indices, Semiring<T>[] src2, int[] src2Indices) Computes the element-wise vector multiplication between two real sparse vectors. Both sparse vectors are assumed to have their indices sorted lexicographically.- Parameters:
src1
- Non-zero entries of the first vector in the element-wise product.src1Indices
- Non-zero indices of the first vector in the element-wise product.src2
- Non-zero entries of the second vector in the element-wise product.src2Indices
- Non-zero indices of the second vector in the element-wise product.- Returns:
- A data class containing the non-zero entries and indices of the sparse COO vector resulting from the element-wise product.
- Throws:
IllegalArgumentException
- If the two vectors do not have the same size (full size including zeros).
-
dot
public static <T extends Semiring<T>> Semiring<T> dot(Shape shape1, Semiring<T>[] src1, int[] src1Indices, Shape shape2, Semiring<T>[] src2, int[] src2Indices) Computes the dot product between two sparse COO vectors.- Parameters:
shape1
- The shape of the first vector.src1
- The non-zero entries of the first vector.src1Indices
- The non-zero indices of the first vector.shape2
- The shape of the second vector.src2
- The non-zero entries of the second vector.src2Indices
- The non-zero indices of the second vector.- Returns:
- The result of the dot product between the two specified COO vectors.
- Throws:
TensorShapeException
- If!shape1.equals(shape2)
.
-
outerProduct
public static <T extends Semiring<T>> void outerProduct(Semiring<T>[] src1, int[] src1Indices, int src1Size, Semiring<T>[] src2, int[] src2Indices, Semiring<T>[] dest) Computes the vector outer product between two sparse COO vectors.- Parameters:
src1
- Non-zero entries of the first vector.src1Indices
- Non-zero indices in the first vector.src1Size
- The full size of the first vector.src2
- Non-zero entries of the second vector.src2Indices
- Non-zero indices of the second vector.dest
- Array to store the dense matrix resulting from the vector outer product.
-