Tensor.prototype.multiply(other: Tensor): Tensor
Performs matrix multiplication with another tensor. The number of columns in the first tensor must match the number of rows in the second tensor.
Example 1
Example 1
const a = new Tensor([[1, 2], [3, 4]]); // 2x2 const b = new Tensor([[5, 6], [7, 8]]); // 2x2 const product = a.multiply(b); // Result: [[19, 22], [43, 50]] const c = new Tensor([[1, 2, 3], [4, 5, 6]]); // 2x3 const d = new Tensor([[7, 8], [9, 10], [11, 12]]); // 3x2 const productCD = c.multiply(d); // Result: [[58, 64], [139, 154]]
other: Tensor
The tensor to multiply with the current tensor.
A new Tensor representing the result of the multiplication.