add#

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

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

New TensorMap with the same metadata as A.

Return type:

TensorMap