subtract

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

Return a new TensorMap with the values being the subtract 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:

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

    \[\nabla(A - B) = \nabla A - \nabla B\]
Parameters:
  • A (TensorMap) – First TensorMap for the subtraction.

  • B (float | int | TensorMap) – Second instance for the subtraction. 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