Class RealDenseSparseVectorOps

java.lang.Object
org.flag4j.linalg.ops.dense_sparse.coo.real.RealDenseSparseVectorOps

public class RealDenseSparseVectorOps extends Object
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 Type
    Method
    Description
    static Vector
    add(Vector src1, CooVector src2)
    Adds a real dense vector to a real sparse vector.
    static void
    addEq(Vector src1, CooVector src2)
    Adds a real dense vector to a real sparse vector and stores the result in the first vector.
    static CooVector
    elemDiv(CooVector src1, Vector src2)
    Compute the element-wise division between a sparse vector and a dense vector.
    static CooVector
    elemMult(Vector src1, CooVector src2)
    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
    sub(Vector src1, CooVector src2)
    Subtracts a real sparse vector from a real dense vector.
    static Vector
    sub(CooVector src1, Vector src2)
    Subtracts a real dense vector from a real sparse vector.
    static void
    subEq(Vector src1, CooVector src2)
    Adds a real dense vector to a real sparse vector and stores the result in the first vector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static Vector sub(Vector src1, CooVector src2)
      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

      public static Vector sub(CooVector src1, Vector src2)
      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

      public static void addEq(Vector src1, CooVector src2)
      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

      public static void subEq(Vector src1, CooVector src2)
      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

      public static CooVector elemMult(Vector src1, CooVector src2)
      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

      public static Vector add(Vector src1, CooVector src2)
      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

      public static CooVector elemDiv(CooVector src1, Vector src2)
      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.