Class RealDenseSparseVectorOperations
java.lang.Object
org.flag4j.operations.dense_sparse.coo.real.RealDenseSparseVectorOperations
This class provides low level methods for computing operations between a real dense/sparse vector and a
real sparse/dense vector.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector
Adds a real dense vector to a real sparse vector.static void
Adds a real dense vector to a real sparse vector and stores the result in the first vector.static CooVector
Compute the element-wise division between a sparse vector and a dense vector.static CooVector
Computes the element-wise multiplication of a real dense vector with a real sparse vector.static double
inner
(double[] src1, double[] src2, int[] indices, int sparseSize) Computes the vector inner product between a real dense vector and a real sparse vector.static double[]
outerProduct
(double[] src1, double[] src2, int[] indices, int sparseSize) Computes the vector outer product between a real dense vector and a real sparse vector.static double[]
outerProduct
(double[] src1, int[] indices, int sparseSize, double[] src2) Computes the vector outer product between a real dense vector and a real sparse vector.static Vector
Subtracts a real sparse vector from a real dense vector.static Vector
Subtracts a real dense vector from a real sparse vector.static void
Adds a real dense vector to a real sparse vector and stores the result in the first vector.
-
Constructor Details
-
RealDenseSparseVectorOperations
private RealDenseSparseVectorOperations()
-
-
Method Details
-
inner
public static double inner(double[] src1, double[] src2, int[] indices, int sparseSize) Computes the vector inner product between a real dense vector and a real sparse vector.- Parameters:
src1
- Entries of the dense vector.src2
- Non-zero entries of the sparse vector.indices
- Indices of non-zero entries in the sparse vector.sparseSize
- The size of the sparse vector (including zero entries).- Returns:
- The inner product of the two vectors.
- Throws:
IllegalArgumentException
- If the number of entries in the two vectors is not equivalent.
-
outerProduct
public static double[] outerProduct(double[] src1, double[] src2, int[] indices, int sparseSize) Computes the vector outer product between a real dense vector and a real sparse vector.- Parameters:
src1
- Entries of the dense vector.src2
- Non-zero entries of the sparse vector.indices
- Indices of non-zero entries of sparse vector.sparseSize
- Full size of the sparse vector including zero entries.- Returns:
- The matrix resulting from the vector outer product.
-
outerProduct
public static double[] outerProduct(double[] src1, int[] indices, int sparseSize, double[] src2) Computes the vector outer product between a real dense vector and a real sparse vector.- Parameters:
src1
- Non-zero entries of the sparse vector.indices
- Indices of non-zero entries of sparse vector.sparseSize
- Full size of the sparse vector including zero entries.src2
- Entries of the dense vector.- Returns:
- The matrix resulting from the vector outer product.
-
sub
Subtracts a real sparse vector from a real dense vector.- Parameters:
src1
- Dense vector.src2
- Sparse vector.- Returns:
- The result of the vector subtraction.
- Throws:
IllegalArgumentException
- If the vectors do not have the same shape.
-
sub
Subtracts a real dense vector from a real sparse vector.- Parameters:
src1
- Sparse vector.src2
- Dense vector.- Returns:
- The result of the vector subtraction.
- Throws:
IllegalArgumentException
- If the vectors do not have the same shape.
-
addEq
Adds a real dense vector to a real sparse vector and stores the result in the first vector.- Parameters:
src1
- Dense vector. Also, where the result will be stored.src2
- Sparse vector.- Throws:
IllegalArgumentException
- If the vectors do not have the same shape.
-
subEq
Adds a real dense vector to a real sparse vector and stores the result in the first vector.- Parameters:
src1
- Dense vector. Also, where the result will be stored.src2
- Sparse vector.- Throws:
IllegalArgumentException
- If the vectors do not have the same shape.
-
elemMult
Computes the element-wise multiplication of a real dense vector with a real sparse vector.- Parameters:
src1
- Dense vector.src2
- Sparse vector.- Returns:
- The result of the element-wise multiplication.
- Throws:
IllegalArgumentException
- If the two vectors are not the same size.
-
add
Adds a real dense vector to a real sparse vector.- Parameters:
src1
- Entries of first vector in the sum.src2
- Entries of second vector in the sum.- Returns:
- The result of the vector addition.
- Throws:
IllegalArgumentException
- If the vectors do not have the same shape.
-
elemDiv
Compute the element-wise division between a sparse vector and a dense vector.- Parameters:
src1
- First vector in the element-wise division.src2
- Second vector in the element-wise division.- Returns:
- The result of the element-wise vector division.
-