Class RealCooVectorOps

java.lang.Object
org.flag4j.linalg.ops.sparse.coo.real.RealCooVectorOps

public final class RealCooVectorOps extends Object
This class contains low level implementations for ops on a real sparse COO vector.
  • Method Details

    • add

      public static Vector add(CooVector src, double a)
      Adds a real number to each entry of a sparse vector, including the zero data.
      Parameters:
      src - Sparse vector to add value to.
      a - Value to add to the src sparse vector.
      Returns:
      The result of adding the specified value to the sparse vector.
    • sub

      public static Vector sub(CooVector src, double a)
      Subtracts a real number from each entry of a sparse vector, including the zero data.
      Parameters:
      src - Sparse vector to subtract value from.
      a - Value to subtract from the src sparse vector.
      Returns:
      The result of subtracting the specified value from the sparse vector.
    • add

      public static CooVector add(CooVector src1, CooVector src2)
      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:
      The result of the vector addition.
      Throws:
      IllegalArgumentException - If the two vectors do not have the same size (full size including zeros).
    • sub

      public static CooVector sub(CooVector src1, CooVector src2)
      Computes the element-wise vector subtraction between two real sparse vectors. Both sparse vectors are assumed to have their indices sorted lexicographically.
      Parameters:
      src1 - First sparse vector in the subtraction. Indices assumed to be sorted lexicographically.
      src2 - Second sparse vector in the subtraction. Indices assumed to be sorted lexicographically.
      Returns:
      The result of the vector subtraction.
      Throws:
      IllegalArgumentException - If the two vectors do not have the same size (full size including zeros).
    • elemMult

      public static CooVector elemMult(CooVector src1, CooVector src2)
      Computes the element-wise vector multiplication between two real sparse vectors. Both sparse vectors are assumed to have their indices sorted lexicographically.
      Parameters:
      src1 - First sparse vector in the multiplication. Indices assumed to be sorted lexicographically.
      src2 - Second sparse vector in the multiplication. Indices assumed to be sorted lexicographically.
      Returns:
      The result of the vector multiplication.
      Throws:
      IllegalArgumentException - If the two vectors do not have the same size (full size including zeros).
    • inner

      public static double inner(CooVector src1, CooVector src2)
      Computes the inner product of two real sparse vectors. Both sparse vectors are assumed to have their indices sorted lexicographically.
      Parameters:
      src1 - First sparse vector in the inner product. Indices assumed to be sorted lexicographically.
      src2 - Second sparse vector in the inner product. Indices assumed to be sorted lexicographically.
      Returns:
      The result of the vector inner product.
      Throws:
      IllegalArgumentException - If the two vectors do not have the same size (full size including zeros).
    • outerProduct

      public static Matrix outerProduct(CooVector src1, CooVector src2)
      Computes the vector outer product between two real sparse vectors.
      Parameters:
      src1 - Entries of the first sparse vector in the outer product.
      src2 - Second sparse vector in the outer product.
      Returns:
      The matrix resulting from the vector outer product.
    • repeat

      public static CooMatrix repeat(CooVector src, int n, int axis)
      Repeats a vector n times along a certain axis to create a matrix.
      Parameters:
      src - The vector to repeat.
      n - Number of times to repeat vector.
      axis - Axis along which to repeat vector. If axis=0 then each row of the resulting matrix will be equivalent to this vector. If axis=1 then each column of the resulting matrix will be equivalent to this vector.
      Returns:
      A matrix whose rows/columns are this vector repeated.
    • stack

      public static CooMatrix stack(CooVector src1, CooVector src2)
      Stacks two vectors along columns as if they were row vectors.
      Parameters:
      src1 - First vector in the stack.
      src2 - Vector to stack to the bottom of the src2 vector.
      Returns:
      The result of stacking this vector and vector src2.
      Throws:
      IllegalArgumentException - If the number of data in the src1 vector is different from the number of data in the vector src2.