struct

Number

Inherits Steppable / Comparable / Value / Object

The top-level number type.

Instance methods

*(other : Tensor)

Multiplies a Tensor with a number. The number is broadcasted across all elements of the Tensor.

Arguments

  • other : Tensor - Tensor on which to perform the operation

Examples

a = [1, 2, 3].to_tensor
3 * a # => [3, 6, 9]
Source
**(other : Tensor)

Raises a number to a Tensor. The number is broadcasted across all elements of the Tensor.

Arguments

  • other : Tensor - Tensor on which to perform the operation

Examples

a = [1, 2, 3].to_tensor
2 ** a # => [2, 4, 8]
Source
+(other : Tensor)

Adds a Tensor to a number. The number is broadcasted across all elements of the Tensor.

Arguments

  • other : Tensor - Tensor on which to perform the operation

Examples

a = [1, 2, 3].to_tensor
3 + a # => [4, 5, 6]
Source
-(other : Tensor)

Subtracts a Tensor from a number. The number is broadcasted across all elements of the Tensor.

Arguments

  • other : Tensor - Tensor on which to perform the operation

Examples

a = [3, 3, 3].to_tensor
3 - a # => [0, 0, 0]
Source
/(other : Tensor)

Divides a number by a Tensor. The number is broadcasted across all elements of the Tensor.

Arguments

  • other : Tensor - Tensor on which to perform the operation

Examples

a = [3, 3, 3].to_tensor
3 / a # => [1, 1, 1]
Source