Chalkboard - v3.1.0
    Preparing search index...

    Function contract

    • Calculates the contraction of a tensor over two of its axes, which sums the entries whose indices along both axes are equal and removes those axes (as in NumPy's trace with axis arguments).

      Parameters

      • tens: ChalkboardTensor

        The tensor

      • Optionalaxis1: number = 0

        The first axis

      • Optionalaxis2: number = 1

        The second axis, which must have the same length as the first axis

      Returns ChalkboardTensor

      const result = Chalkboard.tens.contract([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]], 0, 2); // Returns [9, 13, 17]