Class DenseSemiringElemMult

java.lang.Object
org.flag4j.linalg.ops.dense.semiring_ops.DenseSemiringElemMult

public final class DenseSemiringElemMult extends Object
Utility class useful for computing element-wise products between two Semiring tensors.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T extends Semiring<T>>
    void
    dispatch(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
    Dynamically chooses and applies an element-wise multiplication algorithm to use based on the number of data in the tensors.
    static <T extends Semiring<T>>
    void
    elemMult(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
    Computes the element-wise multiplication of two tensors.
    static <T extends Semiring<T>>
    void
    elemMultConcurrent(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
    Computes the element-wise multiplication of two tensors using a concurrent algorithm.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • elemMult

      public static <T extends Semiring<T>> void elemMult(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
      Computes the element-wise multiplication of two tensors. Also called the Hadamard product.
      Parameters:
      src1 - First tensor in element-wise multiplication.
      shape1 - Shape of the first tensor.
      src2 - Second tensor in element-wise multiplication.
      shape2 - Shape of the second tensor.
      dest - Array to store the resulting element-wise product in.
      Throws:
      IllegalArgumentException - If the tensors do not have the same shape.
      ArrayIndexOutOfBoundsException - If dest.length < src1.length || dest.length < src2.length.
    • elemMultConcurrent

      public static <T extends Semiring<T>> void elemMultConcurrent(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
      Computes the element-wise multiplication of two tensors using a concurrent algorithm. Also called the Hadamard product.
      Parameters:
      src1 - First tensor in element-wise multiplication.
      shape1 - Shape of the first tensor.
      src2 - Second tensor in element-wise multiplication.
      shape2 - Shape of the second tensor.
      dest - Des
      Throws:
      ArrayIndexOutOfBoundsException - If dest.length < src1.length || dest.length < src2.length.
      IllegalArgumentException - If the tensors do not have the same shape.
    • dispatch

      public static <T extends Semiring<T>> void dispatch(T[] src1, Shape shape1, T[] src2, Shape shape2, T[] dest)
      Dynamically chooses and applies an element-wise multiplication algorithm to use based on the number of data in the tensors.
      Parameters:
      src1 - Entries of first tensor.
      shape1 - Shape of first tensor.
      src2 - Entries of second tensor.
      shape2 - Shape of second tensor.
      dest - Array to store the resulting element-wise product in.
      Throws:
      ArrayIndexOutOfBoundsException - If dest.length < src1.length || dest.length < src2.length.