Class RealDenseSparseVectorOps
java.lang.Object
org.flag4j.linalg.ops.dense_sparse.coo.real.RealDenseSparseVectorOps
This class provides low level methods for computing ops between a real dense/sparse vector and a
real sparse/dense vector.
-
Method Summary
Modifier and TypeMethodDescriptionstatic VectorAdds a real dense vector to a real sparse vector.static voidAdds a real dense vector to a real sparse vector and stores the result in the first vector.static CooVectorCompute the element-wise division between a sparse vector and a dense vector.static CooVectorComputes the element-wise multiplication of a real dense vector with a real sparse vector.static doubleinner(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 VectorSubtracts a real sparse vector from a real dense vector.static VectorSubtracts a real dense vector from a real sparse vector.static voidAdds a real dense vector to a real sparse vector and stores the result in the first vector.
-
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 data of the sparse vector.indices- Indices of non-zero data in the sparse vector.sparseSize- The size of the sparse vector (including zero data).- Returns:
- The inner product of the two vectors.
- Throws:
IllegalArgumentException- If the number of data 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 data of the sparse vector.indices- Indices of non-zero data of sparse vector.sparseSize- Full size of the sparse vector including zero data.- 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 data of the sparse vector.indices- Indices of non-zero data of sparse vector.sparseSize- Full size of the sparse vector including zero data.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:
TensorShapeException- 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.
-