Class SemiringCsrOps

java.lang.Object
org.flag4j.linalg.ops.sparse.csr.semiring_ops.SemiringCsrOps

public final class SemiringCsrOps extends Object
Utility class for computing ops on sparse CSR Semiring tensors.
  • Method Details

    • trace

      public static <T extends Semiring<T>> T trace(T[] entries, int[] rowPointers, int[] colIndices)
      Computes the trace of a sparse CSR matrix. That is, the sum of values along the principle diagonal of the matrix.
      Parameters:
      entries - Non-zero data of the CSR matrix.
      rowPointers - Non-zero row pointers of the CSR matrix.
      colIndices - Non-zero column indices of the CSR matrix.
      Returns:
      The trace of the CSR matrix. If there are no non-zero data in this matrix along the principle diagonal, this method will attempt to return the zero element of the semiring. However, if data.length == 0 then this cannot be determined and null will be returned instead.