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).
The tensor
Optional
The first axis
The second axis, which must have the same length as the first axis
const result = Chalkboard.tens.contract([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]], 0, 2); // Returns [9, 13, 17] Copy
const result = Chalkboard.tens.contract([[[1, 2], [3, 4], [5, 6]], [[7, 8], [9, 10], [11, 12]]], 0, 2); // Returns [9, 13, 17]
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).