Skip to main content

/

Overloads

NameDescription
(const Object lhs / const RealTensor rhs) -> RealTensorElement-wise division of Real tensors or tensor-scalar division.
(const Object lhs / const ComplexTensor rhs) -> ComplexTensorElement-wise division of Complex tensors or tensor-scalar division.

(const Object lhs / const RealTensor rhs) -> RealTensor

Element-wise division of Real tensors or tensor-scalar division.

Divides two tensors element-wise, or divides a tensor by a scalar, or divides a scalar by a tensor.

For tensor-tensor division:

  • Both tensors must have the same shape
  • Result[i,j,k,...] = A[i,j,k,...] / B[i,j,k,...]

For tensor-scalar division:

  • Every element of the tensor is divided by the scalar
  • Result[i,j,k,...] = A[i,j,k,...] / s

For scalar-tensor division:

  • The scalar is divided by every element of the tensor
  • Result[i,j,k,...] = s / B[i,j,k,...].

Parameters

  • rhs: Second operand: real tensor or scalar.

Returns

A new real tensor containing the element-wise quotient.

Example

// Tensor-tensor division
var A = filled_tensor([2, 2], 12.0, as_real)
var B = filled_tensor([2, 2], 3.0, as_real)
var C = A / B // Each element is 12.0 / 3.0 = 4.0
print(C[0, 0]) // 4.0

// Tensor-scalar division
var D = filled_tensor([2, 2], 20.0, as_real)
var E = D / 4.0 // Each element is 20.0 / 4.0 = 5.0
print(E[1, 1]) // 5.0

// Scalar-tensor division
var F = filled_tensor([2, 2], 2.0, as_real)
var G = 10.0 / F // Each element is 10.0 / 2.0 = 5.0
print(G[0, 1]) // 5.0

(const Object lhs / const ComplexTensor rhs) -> ComplexTensor

Element-wise division of Complex tensors or tensor-scalar division.

Divides two tensors element-wise, or divides a tensor by a scalar, or divides a scalar by a tensor.

For tensor-tensor division:

  • Both tensors must have the same shape
  • Result[i,j,k,...] = A[i,j,k,...] / B[i,j,k,...]

For tensor-scalar division:

  • Every element of the tensor is divided by the scalar
  • Result[i,j,k,...] = A[i,j,k,...] / s

For scalar-tensor division:

  • The scalar is divided by every element of the tensor
  • Result[i,j,k,...] = s / B[i,j,k,...].

Parameters

  • rhs: Second operand: complex tensor or scalar.

Returns

A new complex tensor containing the element-wise quotient.

Example

// Tensor-tensor division
var A = filled_tensor([2, 2], 12.0, as_complex)
var B = filled_tensor([2, 2], 3.0, as_complex)
var C = A / B // Each element is 12.0 / 3.0 = 4.0
print(C[0, 0]) // 4.0

// Tensor-scalar division
var D = filled_tensor([2, 2], 20.0, as_complex)
var E = D / 4.0 // Each element is 20.0 / 4.0 = 5.0
print(E[1, 1]) // 5.0

// Scalar-tensor division
var F = filled_tensor([2, 2], 2.0, as_complex)
var G = 10.0 / F // Each element is 10.0 / 2.0 = 5.0
print(G[0, 1]) // 5.0