jet.bindings.add_tensors

add_tensors(*args, **kwargs)

Overloaded function.

  1. add_tensors(A: jet.bindings.TensorC64, B: jet.bindings.TensorC64) -> jet.bindings.TensorC64

Adds two tensor objects with the same index sets. The resulting tensor will have the same indices as the first argument (i.e., A).

Parameters
  • A (Tensor) – Tensor on the LHS of the addition.

  • B (Tensor) – Tensor on the RHS of the addition.

Returns

Element-wise sum of the tensors.

Return type

Tensor

Example

Given a 2x3 tensor \(A(i,j)\) and a 2x3 tensor \(B(i,j)\), the addition of \(A\) and \(B\) is another 2x3 tensor \(C(i,j)\):

import jet

A = jet.Tensor(["i", "j"], [2, 3])
B = jet.Tensor(["i", "j"], [2, 3])

A.fill_random()
B.fill_random()

C = jet.add_tensors(A, B);
  1. add_tensors(A: jet.bindings.TensorC128, B: jet.bindings.TensorC128) -> jet.bindings.TensorC128

Adds two tensor objects with the same index sets. The resulting tensor will have the same indices as the first argument (i.e., A).

Parameters
  • A (Tensor) – Tensor on the LHS of the addition.

  • B (Tensor) – Tensor on the RHS of the addition.

Returns

Element-wise sum of the tensors.

Return type

Tensor

Example

Given a 2x3 tensor \(A(i,j)\) and a 2x3 tensor \(B(i,j)\), the addition of \(A\) and \(B\) is another 2x3 tensor \(C(i,j)\):

import jet

A = jet.Tensor(["i", "j"], [2, 3])
B = jet.Tensor(["i", "j"], [2, 3])

A.fill_random()
B.fill_random()

C = jet.add_tensors(A, B);