multiply

metatensor.multiply(A: TensorMap, B: float | int | TensorMap) TensorMap[source]

Return a new TensorMap with the values being the element-wise multiplication of A and B.

If B is a TensorMap it has to have the same metadata as A.

If gradients are present in A:

  • B is a scalar then:

    \[\nabla(A * B) = B * \nabla A\]
  • B is a TensorMap with the same metadata of A.

    The multiplication is performed with the rule of the derivatives:

    \[\nabla(A * B) = B * \nabla A + A * \nabla B\]
Parameters:
  • A (TensorMap) – First TensorMap for the multiplication.

  • B (float | int | TensorMap) – Second instance for the multiplication. Parameter can be a scalar or a TensorMap. In the latter case B must have the same metadata of A.

Returns:

New TensorMap with the same metadata as A.

Return type:

TensorMap