Class DenseRingTensorOps

java.lang.Object
org.flag4j.linalg.ops.dense.ring_ops.DenseRingTensorOps

public final class DenseRingTensorOps extends Object
Utility class for computing ops between two dense Ring tensors.
  • Method Details

    • sub

      public static <T extends Ring<T>> void sub(Shape shape1, T[] src1, Shape shape2, T[] src2, T[] dest)
      Computes the element-wise difference between two dense tensors.
      Parameters:
      shape1 - Shape of the first tensor in the element-wise difference.
      src1 - Entries of the first tensor in the element-wise difference.
      shape2 - Shape of the second tensor in the element-wise difference.
      src2 - Entries of the second tensor in the element-wise difference.
      dest - Array to store the resulting element-wise difference. May be the same array as either src1 or src2.
      Throws:
      TensorShapeException - If !shape1.equals(shape2).
      ArrayIndexOutOfBoundsException - If src2.length < src2.length || dest.length < src1.length
    • isHermitian

      public static <T extends Ring<T>> boolean isHermitian(Shape shape, T[] src)
      Checks if a complex dense matrix is Hermitian. That is, if the matrix is equal to its conjugate transpose.
      Parameters:
      shape - Shape of the matrix.
      src - Entries of the matrix.
      Returns:
      true if this matrix is Hermitian; false otherwise.
    • isCloseToIdentity

      public static <T extends Ring<T>> boolean isCloseToIdentity(Shape shape, T[] src)

      Checks if a matrix is the identity matrix approximately.

      Specifically, if the diagonal data are no farther than 1.001E-5 in absolute value from 1.0 and the non-diagonal data are no larger than 1e-08 in absolute value.

      These thresholds correspond to the thresholds from the RingProperties.allClose(Ring[], Ring[]) method.

      Parameters:
      src - Matrix of interest to check if it is the identity matrix.
      Returns:
      True if the src matrix is close the identity matrix or if the matrix has zero data.