Skip to content

module Num #

Extended modules

Num

Constants#

ColMajor = OrderType::ColMajor #

RowMajor = OrderType::RowMajor #

VERSION = "0.5.0" #

Methods#

#acos(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method acos on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
View source

#acos(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function acos for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acos(a)
View source

#acos(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method acos on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
View source

#acos!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method acos on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
View source

#acos!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function acos for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acos!(a)
View source

#acos!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method acos on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
View source

#acosh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method acosh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
View source

#acosh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function acosh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acosh(a)
View source

#acosh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method acosh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
View source

#acosh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method acosh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
View source

#acosh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function acosh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acosh!(a)
View source

#acosh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method acosh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
View source

#acospi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function acospi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acospi(a)
View source

#acospi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function acospi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acospi!(a)
View source

#add(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :+ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add(a, b)
View source

#add(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :+ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(a, b)
View source

#add(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :+ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(b, a)
View source

#add(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Add two Tensors elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, a)
View source

#add(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Add a Tensor and a Number elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
View source

#add(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Add a Number and a Tensor elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
View source

#add(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :+ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add(a, b)
View source

#add(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :+ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(a, b)
View source

#add(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :+ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(b, a)
View source

#add!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :+ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add!(a, b) # a is modified
View source

#add!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :+ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add!(a, b)
View source

#add!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

"Add" two Tensors elementwise, storing the result in the first Tensor

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add!(a, a)
View source

#add!(a : Tensor(U, OCL(U)), b : U) : Nil forall U #

Add a Tensor and a Number elementwise, modifying the Tensor inplace.

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
View source

#add!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :+ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add!(a, b) # a is modified
View source

#add!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :+ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add!(a, b)
View source

#all(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, asserting the truthiness of all values in each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.all(a, 0) # => [false, true]
Num.all(a, 1, dims: true)
# [[false],
#  [ true]]
View source

#all(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, asserting the truthiness of all values in each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.all(a, 0) # => [false, true]
Num.all(a, 1, dims: true)
# [[false],
#  [ true]]
View source

#all(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a boolean by asserting the truthiness of all elements

Arguments#
Examples#
a = [0, 2, 3]
Num.all(a) # => false
View source

#all(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a boolean by asserting the truthiness of all elements

Arguments#
Examples#
a = [0, 2, 3]
Num.all(a) # => false
View source

#all_close(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), epsilon = 1e-6) : Bool forall U, V #

Asserts that two Tensors are equal, allowing for small margins of errors with floating point values using an EPSILON value.

Arguments#
Examples#
a = [0.0, 0.0, 0.0000000001].to_tensor
b = [0.0, 0.0, 0.0].to_tensor
Num.all_close(a, b) # => true
View source

#all_close(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), epsilon = 1e-6) : Bool forall U, V #

Asserts that two Tensors are equal, allowing for small margins of errors with floating point values using an EPSILON value.

Arguments#
Examples#
a = [0.0, 0.0, 0.0000000001].to_tensor
b = [0.0, 0.0, 0.0].to_tensor
Num.all_close(a, b) # => true
View source

#any(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, asserting the truthiness of any values in each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.any(a, 0) # => [true, true]
Num.any(a, 1, dims: true)
# [[true],
#  [ true]]
View source

#any(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, asserting the truthiness of any values in each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.any(a, 0) # => [true, true]
Num.any(a, 1, dims: true)
# [[true],
#  [ true]]
View source

#any(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a boolean by asserting the truthiness of any element

Arguments#
Examples#
a = [0, 2, 3]
Num.any(a) # => true
View source

#any(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a boolean by asserting the truthiness of any element

Arguments#
Examples#
a = [0, 2, 3]
Num.any(a) # => true
View source

#argmax(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Find the maximum index value of a Tensor along an axis

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[2, 1], [1, 2]].to_tensor
puts a.argmax(1) # => [0, 1]
View source

#argmax(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Find the maximum index value of a Tensor along an axis

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[2, 1], [1, 2]].to_tensor
puts a.argmax(1) # => [0, 1]
View source

#argmax(a : Tensor(U, CPU(U))) : Int32 forall U #

Find the maximum index value of a Tensor

Arguments#
Examples#
a = [1, 10, 1].to_tensor
a.argmax # => 1
View source

#argmax(a : Tensor(U, ARROW(U))) : Int32 forall U #

Find the maximum index value of a Tensor

Arguments#
Examples#
a = [1, 10, 1].to_tensor
a.argmax # => 1
View source

#argmin(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Find the minimum index value of a Tensor along an axis

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[2, 1], [1, 2]].to_tensor
puts a.argmin(1) # => [1, 0]
View source

#argmin(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Find the minimum index value of a Tensor along an axis

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[2, 1], [1, 2]].to_tensor
puts a.argmin(1) # => [1, 0]
View source

#argmin(a : Tensor(U, CPU(U))) : Int32 forall U #

Find the minimum index value of a Tensor

Arguments#
Examples#
a = [10, 1, 10].to_tensor
a.argmin # => 1
View source

#argmin(a : Tensor(U, ARROW(U))) : Int32 forall U #

Find the minimum index value of a Tensor

Arguments#
Examples#
a = [10, 1, 10].to_tensor
a.argmin # => 1
View source

#array_split(a : Tensor(U, CPU(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U #

Split a Tensor into multiple sub-Tensors

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, 2) # => [[0, 1, 2, 3, 4], [5, 6, 7, 8]]
View source

#array_split(a : Tensor(U, CPU(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U #

Split a Tensor into multiple sub-Tensors, using an explicit mapping of indices to split the Tensor

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
View source

#array_split(a : Tensor(U, ARROW(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U #

Split a Tensor into multiple sub-Tensors

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, 2) # => [[0, 1, 2, 3, 4], [5, 6, 7, 8]]
View source

#array_split(a : Tensor(U, ARROW(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U #

Split a Tensor into multiple sub-Tensors, using an explicit mapping of indices to split the Tensor

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
View source

#as_strided(arr : Tensor(U, V), shape : Array(Int), strides : Array(Int)) : Tensor(U, V) forall U, V #

as_strided creates a view into the Tensor given the exact strides and shape. This means it manipulates the internal data structure of a Tensor and, if done incorrectly, the array elements can point to invalid memory and can corrupt results or crash your program.

It is advisable to always use the original strides when calculating new strides to avoid reliance on a contiguous memory layout.

Furthermore, Tensors created with this function often contain self overlapping memory, so that two elements are identical. Vectorized write operations on such Tensors will typically be unpredictable. They may even give different results for small, large, or transposed Tensors.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3]
a.as_strided([3, 3], [0, 1])

# [[1, 2, 3],
#  [1, 2, 3],
#  [1, 2, 3]]
View source

#as_tensor(value : Number, like : Tensor(U, V) | Tensor(U, V).class) forall U, V #

Convert a scalar value to a Tensor like the one specified, matching the data type and target compute.

Examples#

``` t = Tensor(Float32, OCL(Float32)).from_array([0.5, 0.2]) x = Num.as_tensor(12, like: t) x = Num.as_tensor(12, like: Tensor(Float32, OCL(Float32)))

View source

#as_type(arr : Tensor(U, CPU(U)), dtype : V.class) forall U, V #

Casts a Tensor to a new dtype, by making a copy. Information may be lost when converting between data types, for example Float to Int or Int to Bool.

Arguments#
  • u : U.class - Data type the Tensor will be cast to
Examples#
a = Tensor.from_array [1.5, 2.5, 3.5]

a.astype(Int32)   # => [1, 2, 3]
a.astype(Bool)    # => [true, true, true]
a.astype(Float32) # => [1.5, 2.5, 3.5]
View source

#as_type(arr : Tensor(U, ARROW(U)), dtype : V.class) forall U, V #

Casts a Tensor to a new dtype, by making a copy. Information may be lost when converting between data types, for example Float to Int or Int to Bool.

Arguments#
  • u : U.class - Data type the Tensor will be cast to
Examples#
a = Tensor.from_array [1.5, 2.5, 3.5]

a.astype(Int32)   # => [1, 2, 3]
a.astype(Bool)    # => [true, true, true]
a.astype(Float32) # => [1.5, 2.5, 3.5]
View source

#asin(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method asin on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
View source

#asin(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function asin for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asin(a)
View source

#asin(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method asin on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
View source

#asin!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method asin on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
View source

#asin!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function asin for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asin!(a)
View source

#asin!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method asin on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
View source

#asinh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method asinh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
View source

#asinh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function asinh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinh(a)
View source

#asinh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method asinh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
View source

#asinh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method asinh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
View source

#asinh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function asinh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinh!(a)
View source

#asinh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method asinh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
View source

#asinpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function asinpi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinpi(a)
View source

#asinpi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function asinpi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinpi!(a)
View source

#atan(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method atan on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
View source

#atan(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atan for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan(a)
View source

#atan(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method atan on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
View source

#atan!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method atan on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
View source

#atan!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function atan for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan!(a)
View source

#atan!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method atan on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
View source

#atan2(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method atan2 on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2(a, b)
View source

#atan2(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method atan2 on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2(a, b)
View source

#atan2(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method atan2 on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.atan2(a, b)
View source

#atan2(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atan2 between two Tensors

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.atan2(a, b)
View source

#atan2(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atan2 between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan2(a, 3_f64)
View source

#atan2(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atan2 between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan2(3_f64, a)
View source

#atan2(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method atan2 on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2(a, b)
View source

#atan2(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method atan2 on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2(a, b)
View source

#atan2(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method atan2 on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.atan2(a, b)
View source

#atan2!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method atan2 on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2!(a, b)
View source

#atan2!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method atan2 on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2!(a, b)
View source

#atan2!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function atan2 between two Tensors, mutating the first Tensor, modifying it to store the result of the operation

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.atan2!(a, b)
View source

#atan2!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method atan2 on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2!(a, b)
View source

#atan2!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method atan2 on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2!(a, b)
View source

#atanh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method atanh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
View source

#atanh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atanh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanh(a)
View source

#atanh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method atanh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
View source

#atanh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method atanh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
View source

#atanh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function atanh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanh!(a)
View source

#atanh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method atanh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
View source

#atanpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function atanpi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanpi(a)
View source

#atanpi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function atanpi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanpi!(a)
View source

#besselj(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method besselj on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj(a, b)
View source

#besselj(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method besselj on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj(a, b)
View source

#besselj(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method besselj on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.besselj(a, b)
View source

#besselj(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method besselj on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj(a, b)
View source

#besselj(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method besselj on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj(a, b)
View source

#besselj(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method besselj on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.besselj(a, b)
View source

#besselj!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method besselj on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj!(a, b)
View source

#besselj!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method besselj on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj!(a, b)
View source

#besselj!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method besselj on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj!(a, b)
View source

#besselj!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method besselj on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj!(a, b)
View source

#besselj0(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method besselj0 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
View source

#besselj0(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method besselj0 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
View source

#besselj0!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method besselj0 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
View source

#besselj0!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method besselj0 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
View source

#besselj1(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method besselj1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
View source

#besselj1(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method besselj1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
View source

#besselj1!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method besselj1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
View source

#besselj1!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method besselj1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
View source

#bessely(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method bessely on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely(a, b)
View source

#bessely(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method bessely on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely(a, b)
View source

#bessely(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method bessely on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.bessely(a, b)
View source

#bessely(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method bessely on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely(a, b)
View source

#bessely(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method bessely on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely(a, b)
View source

#bessely(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method bessely on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.bessely(a, b)
View source

#bessely!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method bessely on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely!(a, b)
View source

#bessely!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method bessely on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely!(a, b)
View source

#bessely!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method bessely on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely!(a, b)
View source

#bessely!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method bessely on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely!(a, b)
View source

#bessely0(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method bessely0 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
View source

#bessely0(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method bessely0 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
View source

#bessely0!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method bessely0 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
View source

#bessely0!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method bessely0 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
View source

#bessely1(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method bessely1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
View source

#bessely1(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method bessely1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
View source

#bessely1!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method bessely1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
View source

#bessely1!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method bessely1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
View source

#bitwise_and(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :& operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and(a, b)
View source

#bitwise_and(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :& operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(a, b)
View source

#bitwise_and(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :& operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(b, a)
View source

#bitwise_and(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "&" between two Tensors. Only Int32 and UInt32 Tensors are supported

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_and(a, a)
View source

#bitwise_and(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "&" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "&" operator
  • b : U - RHS argument to the "&" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_and(a, 3)
View source

#bitwise_and(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "&" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : U - LHS argument to the "&" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "&" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_and(3, a)
View source

#bitwise_and(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :& operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and(a, b)
View source

#bitwise_and(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :& operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(a, b)
View source

#bitwise_and(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :& operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(b, a)
View source

#bitwise_and!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :& operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and!(a, b) # a is modified
View source

#bitwise_and!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :& operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and!(a, b)
View source

#bitwise_and!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :& operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and!(a, b) # a is modified
View source

#bitwise_and!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :& operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and!(a, b)
View source

#bitwise_or(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :| operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or(a, b)
View source

#bitwise_or(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :| operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(a, b)
View source

#bitwise_or(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :| operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(b, a)
View source

#bitwise_or(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "|" between two Tensors. Only Int32 and UInt32 Tensors are supported

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_or(a, a)
View source

#bitwise_or(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "|" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "|" operator
  • b : U - RHS argument to the "|" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_or(a, 3)
View source

#bitwise_or(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "|" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : U - LHS argument to the "|" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "|" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_or(3, a)
View source

#bitwise_or(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :| operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or(a, b)
View source

#bitwise_or(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :| operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(a, b)
View source

#bitwise_or(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :| operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(b, a)
View source

#bitwise_or!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :| operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or!(a, b) # a is modified
View source

#bitwise_or!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :| operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or!(a, b)
View source

#bitwise_or!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :| operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or!(a, b) # a is modified
View source

#bitwise_or!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :| operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or!(a, b)
View source

#bitwise_xor(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :^ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor(a, b)
View source

#bitwise_xor(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :^ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(a, b)
View source

#bitwise_xor(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :^ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(b, a)
View source

#bitwise_xor(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "^" between two Tensors. Only Int32 and UInt32 Tensors are supported

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_xor(a, a)
View source

#bitwise_xor(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "^" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "^" operator
  • b : U - RHS argument to the "^" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_xor(a, 3)
View source

#bitwise_xor(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "^" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : U - LHS argument to the "^" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "^" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.bitwise_xor(3, a)
View source

#bitwise_xor(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :^ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor(a, b)
View source

#bitwise_xor(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :^ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(a, b)
View source

#bitwise_xor(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :^ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(b, a)
View source

#bitwise_xor!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :^ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor!(a, b) # a is modified
View source

#bitwise_xor!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :^ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor!(a, b)
View source

#bitwise_xor!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :^ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor!(a, b) # a is modified
View source

#bitwise_xor!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :^ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor!(a, b)
View source

#broadcast(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), c : Tensor(W, CPU(W))) forall U, V, W #

Broadcasts two Tensor's' to a new shape. This allows for elementwise operations between the two Tensors with the new shape.

Broadcasting rules apply, and imcompatible shapes will raise an error.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }
c = Tensor.new([3, 3, 3, 3]) { |i| i }

x, y, z = a.broadcast(b, c)
x.shape # => [3, 3, 3, 3]
View source

#broadcast(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), c : Tensor(W, ARROW(W))) forall U, V, W #

Broadcasts two Tensor's' to a new shape. This allows for elementwise operations between the two Tensors with the new shape.

Broadcasting rules apply, and imcompatible shapes will raise an error.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }
c = Tensor.new([3, 3, 3, 3]) { |i| i }

x, y, z = a.broadcast(b, c)
x.shape # => [3, 3, 3, 3]
View source

#broadcast(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) forall U, V #

Broadcasts two Tensor's' to a new shape. This allows for elementwise operations between the two Tensors with the new shape.

Broadcasting rules apply, and imcompatible shapes will raise an error.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }

x, y = a.broadcast(b)
x.shape # => [3, 3]
View source

#broadcast(a : Tensor(U, OCL(U)), b : Tensor(V, OCL(V))) forall U, V #

Broadcasts two Tensor's' to a new shape. This allows for elementwise operations between the two Tensors with the new shape.

Broadcasting rules apply, and imcompatible shapes will raise an error.

Examples

a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }

x, y = a.broadcast(b)
x.shape # => [3, 3]

View source

#broadcast(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) forall U, V #

Broadcasts two Tensor's' to a new shape. This allows for elementwise operations between the two Tensors with the new shape.

Broadcasting rules apply, and imcompatible shapes will raise an error.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }

x, y = a.broadcast(b)
x.shape # => [3, 3]
View source

#broadcast_to(arr : Tensor(U, V), shape : Array(Int)) forall U, V #

Broadcasts a Tensor to a new shape. Returns a read-only view of the original Tensor. Many elements in the Tensor will refer to the same memory location, and the result is rarely contiguous.

Shapes must be broadcastable, and an error will be raised if broadcasting fails.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
a.broadcast_to([3, 3])

# [[1, 2, 3],
#  [1, 2, 3],
#  [1, 2, 3]]
View source

#cbrt(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method cbrt on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
View source

#cbrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function cbrt for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cbrt(a)
View source

#cbrt(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method cbrt on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
View source

#cbrt!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method cbrt on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
View source

#cbrt!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function cbrt for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cbrt!(a)
View source

#cbrt!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method cbrt on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
View source

#ceil(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function ceil for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.ceil(a)
View source

#ceil!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function ceil for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.ceil!(a)
View source

#concatenate(arrs : Array(Tensor(U, V)), axis : Int) forall U, V #

Join a sequence of Tensors along an existing axis. The Tensors must have the same shape for all axes other than the axis of concatenation

Arguments#
  • arrs : Array(Tensor) - Tensors to concatenate
  • axis : Int - Axis of concatenation, negative axes are allowed
Examples#
a = [1, 2, 3].to_tensor
b = Tensor.from_array [4, 5, 6]
Num.concat([a, b], 0) # => [1, 2, 3, 4, 5, 6]

c = Tensor.new([3, 2, 2]) { |i| i / 2 }
Num.concat([c, c, c], -1)

# [[[0  , 0.5, 0  , 0.5, 0  , 0.5],
#  [1  , 1.5, 1  , 1.5, 1  , 1.5]],
#
# [[2  , 2.5, 2  , 2.5, 2  , 2.5],
#  [3  , 3.5, 3  , 3.5, 3  , 3.5]],
#
# [[4  , 4.5, 4  , 4.5, 4  , 4.5],
#  [5  , 5.5, 5  , 5.5, 5  , 5.5]]]
View source

#concatenate(*arrs : Tensor(U, V), axis : Int) forall U, V #

Join a sequence of Tensors along an existing axis. The Tensors must have the same shape for all axes other than the axis of concatenation

Arguments#
  • arrs : Tuple(Tensor) - Tensors to concatenate
  • axis : Int - Axis of concatenation, negative axes are allowed
Examples#
a = [1, 2, 3].to_tensor
b = Tensor.from_array [4, 5, 6]
Num.concat([a, b], 0) # => [1, 2, 3, 4, 5, 6]

c = Tensor.new([3, 2, 2]) { |i| i / 2 }
Num.concat([c, c, c], -1)

# [[[0  , 0.5, 0  , 0.5, 0  , 0.5],
#  [1  , 1.5, 1  , 1.5, 1  , 1.5]],
#
# [[2  , 2.5, 2  , 2.5, 2  , 2.5],
#  [3  , 3.5, 3  , 3.5, 3  , 3.5]],
#
# [[4  , 4.5, 4  , 4.5, 4  , 4.5],
#  [5  , 5.5, 5  , 5.5, 5  , 5.5]]]
View source

#copysign(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method copysign on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign(a, b)
View source

#copysign(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method copysign on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign(a, b)
View source

#copysign(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method copysign on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.copysign(a, b)
View source

#copysign(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method copysign on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign(a, b)
View source

#copysign(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method copysign on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign(a, b)
View source

#copysign(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method copysign on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.copysign(a, b)
View source

#copysign!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method copysign on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign!(a, b)
View source

#copysign!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method copysign on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign!(a, b)
View source

#copysign!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method copysign on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign!(a, b)
View source

#copysign!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method copysign on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign!(a, b)
View source

#cos(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method cos on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
View source

#cos(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function cos for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cos(a)
View source

#cos(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method cos on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
View source

#cos!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method cos on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
View source

#cos!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function cos for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cos!(a)
View source

#cos!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method cos on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
View source

#cosh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method cosh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
View source

#cosh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function cosh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cosh(a)
View source

#cosh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method cosh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
View source

#cosh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method cosh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
View source

#cosh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function cosh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cosh!(a)
View source

#cosh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method cosh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
View source

#cospi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function cospi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cospi(a)
View source

#cospi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function cospi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cospi!(a)
View source

#cpu(arr : Tensor(U, CPU(U))) forall U #

Converts a CPU Tensor to CPU. Returns the input array, no copy is performed.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
View source

#cpu(arr : Tensor(U, OCL(U))) forall U #

Converts a Tensor stored on an OpenCL device to a Tensor stored on a CPU.

Arguments#
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a.cpu # => [[0, 1], [2, 3]]
View source

#cpu(arr : Tensor(U, ARROW(U))) forall U #

Converts a ARROW Tensor to CPU. Returns the input array, no copy is performed.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
View source

#diagonal(arr : Tensor(U, CPU(U))) forall U #

Returns a view of the diagonal of a Tensor. This method only works for two-dimensional arrays.

Todo

Implement views for offset diagonals

Arguments#
Examples#
a = Tensor.new(3, 3) { |i, _| i }
a.diagonal # => [0, 1, 2]
View source

#diagonal(arr : Tensor(U, ARROW(U))) forall U #

Returns a view of the diagonal of a Tensor. This method only works for two-dimensional arrays.

Todo

Implement views for offset diagonals

Arguments#
Examples#
a = Tensor.new(3, 3) { |i, _| i }
a.diagonal # => [0, 1, 2]
View source

#divide(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :/ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide(a, b)
View source

#divide(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :/ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(a, b)
View source

#divide(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :/ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(b, a)
View source

#divide(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Divide two Tensors elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, a)
View source

#divide(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Divide a Tensor and a Number elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
View source

#divide(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Divide a Number and a Tensor elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
View source

#divide(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :/ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide(a, b)
View source

#divide(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :/ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(a, b)
View source

#divide(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :/ operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(b, a)
View source

#divide!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :/ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide!(a, b) # a is modified
View source

#divide!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :/ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide!(a, b)
View source

#divide!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

"Divide" two Tensors elementwise, storing the result in the first Tensor

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide!(a, a)
View source

#divide!(a : Tensor(U, OCL(U)), b : U) : Nil forall U #

Divide a Tensor and a Number elementwise, modifying the Tensor inplace.

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
View source

#divide!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :/ operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide!(a, b) # a is modified
View source

#divide!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :/ operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide!(a, b)
View source

#dup(t : Tensor(U, CPU(U)), order : Num::OrderType = Num::RowMajor) forall U #

Deep-copies a Tensor. If an order is provided, the returned Tensor's memory layout will respect that order.

If no order is provided, the Tensor will retain it's same memory layout.

Arguments#
Examples#

-

a = Tensor.from_array [1, 2, 3]
a.dup # => [1, 2, 3]

View source

#dup(t : Tensor(U, ARROW(U)), order : Num::OrderType = Num::RowMajor) forall U #

Deep-copies a Tensor. If an order is provided, the returned Tensor's memory layout will respect that order.

If no order is provided, the Tensor will retain it's same memory layout.

Arguments#
Examples#

-

a = Tensor.from_array [1, 2, 3]
a.dup # => [1, 2, 3]

View source

#each(arr : Tensor(U, CPU(U)), &block : U -> _) forall U #

Yields the elements of a Tensor, always in RowMajor order, as if the Tensor was flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each do |el|
  puts el
end

# 0
# 1
# 2
# 3
View source

#each(arr : Tensor(U, CPU(U))) forall U #

Yields the elements of a Tensor lazily, always in RowMajor order, as if the Tensor was flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
iter = a.each
a.size.times do
  puts iter.next.value
end

# 0
# 1
# 2
# 3
View source

#each(arr : Tensor(U, ARROW(U)), &block : U -> _) forall U #

Yields the elements of a Tensor, always in RowMajor order, as if the Tensor was flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each do |el|
  puts el
end

# 0
# 1
# 2
# 3
View source

#each(arr : Tensor(U, ARROW(U))) forall U #

Yields the elements of a Tensor lazily, always in RowMajor order, as if the Tensor was flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
iter = a.each
a.size.times do
  puts iter.next.value
end

# 0
# 1
# 2
# 3
View source

#each_axis(a0 : Tensor(U, CPU(U)), axis : Int, dims : Bool = false, &block : Tensor(U, CPU(U)) -> _) forall U #

Yields a view of each lane of an axis. Changes made in the passed block will be reflected in the original Tensor

Arguments#
  • a0 : Tensor(U, CPU(U)) - Tensor to iterate along
  • axis : Int - Axis of reduction
  • dims : Bool - Indicates if the axis of reduction should be removed from the result
Examples#
a = Tensor.new([3, 3]) { |i| i }
a.each_axis(1) do |ax|
  puts ax
end

# [0, 3, 6]
# [1, 4, 7]
# [2, 5, 8]
View source

#each_axis(arr : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Returns an iterator along each element of an axis. Each element returned by the iterator is a view, not a copy

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to iterate along
  • axis : Int - Axis of reduction
  • dims : Bool - Indicates if the axis of reduction should be removed from the result
Examples#
a = Tensor.new([3, 3]) { |i| i }
a.each_axis(1).next # => [0, 3, 6]
View source

#each_axis(a0 : Tensor(U, OCL(U)), axis : Int, dims : Bool = false, &block : Tensor(U, OCL(U)) -> _) forall U #

Yields a view of each lane of an axis. Changes made in the passed block will be reflected in the original Tensor

Arguments#
  • a0 : Tensor(U, OCL(U)) - Tensor to iterate along
  • axis : Int - Axis of reduction
  • dims : Bool - Indicates if the axis of reduction should be removed from the result
Examples#
a = Tensor.new([3, 3], device: OCL) { |i| i }
a.each_axis(1) do |ax|
  puts ax.cpu
end

# [0, 3, 6]
# [1, 4, 7]
# [2, 5, 8]
View source

#each_axis(a0 : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false, &block : Tensor(U, ARROW(U)) -> _) forall U #

Yields a view of each lane of an axis. Changes made in the passed block will be reflected in the original Tensor

Arguments#
  • a0 : Tensor(U, ARROW(U)) - Tensor to iterate along
  • axis : Int - Axis of reduction
  • dims : Bool - Indicates if the axis of reduction should be removed from the result
Examples#
a = Tensor.new([3, 3]) { |i| i }
a.each_axis(1) do |ax|
  puts ax
end

# [0, 3, 6]
# [1, 4, 7]
# [2, 5, 8]
View source

#each_axis(arr : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Returns an iterator along each element of an axis. Each element returned by the iterator is a view, not a copy

Arguments#
  • arr : Tensor(U, ARROW(U)) - Tensor to iterate along
  • axis : Int - Axis of reduction
  • dims : Bool - Indicates if the axis of reduction should be removed from the result
Examples#
a = Tensor.new([3, 3]) { |i| i }
a.each_axis(1).next # => [0, 3, 6]
View source

#each_pointer(arr : Tensor(U, CPU(U)), &block : Pointer(U) -> _) forall U #

Yields the memory locations of each element of a Tensor, always in RowMajor oder, as if the Tensor was flat.

This should primarily be used by internal methods. Methods such as map! provided more convenient access to editing the values of a Tensor

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
  puts el.value
end

# 0
# 1
# 2
# 3
View source

#each_pointer(arr : Tensor(U, ARROW(U)), &block : Pointer(U) -> _) forall U #

Yields the memory locations of each element of a Tensor, always in RowMajor oder, as if the Tensor was flat.

This should primarily be used by internal methods. Methods such as map! provided more convenient access to editing the values of a Tensor

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
  puts el.value
end

# 0
# 1
# 2
# 3
View source

#each_pointer_with_index(arr : Tensor(U, CPU(U)), &block : Pointer(U), Int32 -> _) forall U #

Yields the memory locations of each element of a Tensor, always in RowMajor oder, as if the Tensor was flat.

This should primarily be used by internal methods. Methods such as map! provided more convenient access to editing the values of a Tensor

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
  puts el.value
end

# 0
# 1
# 2
# 3
View source

#each_pointer_with_index(arr : Tensor(U, ARROW(U)), &block : Pointer(U), Int32 -> _) forall U #

Yields the memory locations of each element of a Tensor, always in RowMajor oder, as if the Tensor was flat.

This should primarily be used by internal methods. Methods such as map! provided more convenient access to editing the values of a Tensor

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
  puts el.value
end

# 0
# 1
# 2
# 3
View source

#each_with_index(arr : Tensor(U, CPU(U)), &block : U, Int32 -> _) forall U #

Yields the elements of a Tensor, always in RowMajor order, as if the Tensor was flat. Also yields the flat index of each element.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_with_index do |el, i|
  puts "#{el}_#{i}"
end

# 0_0
# 1_1
# 2_2
# 3_3
View source

#each_with_index(arr : Tensor(U, ARROW(U)), &block : U, Int32 -> _) forall U #

Yields the elements of a Tensor, always in RowMajor order, as if the Tensor was flat. Also yields the flat index of each element.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_with_index do |el, i|
  puts "#{el}_#{i}"
end

# 0_0
# 1_1
# 2_2
# 3_3
View source

#equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :== operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal(a, b)
View source

#equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :== operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(a, b)
View source

#equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :== operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(b, a)
View source

#equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "==" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.equal(a, a)
View source

#equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "==" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "==" operator
  • b : U - RHS argument to the "==" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.equal(a, 3)
View source

#equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "==" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the "==" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "==" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.equal(3, a)
View source

#equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :== operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal(a, b)
View source

#equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :== operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(a, b)
View source

#equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :== operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(b, a)
View source

#equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :== operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal!(a, b) # a is modified
View source

#equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :== operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal!(a, b)
View source

#equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :== operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal!(a, b) # a is modified
View source

#equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :== operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal!(a, b)
View source

#erf(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method erf on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
View source

#erf(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function erf for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erf(a)
View source

#erf(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method erf on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
View source

#erf!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method erf on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
View source

#erf!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function erf for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erf!(a)
View source

#erf!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method erf on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
View source

#erfc(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method erfc on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
View source

#erfc(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function erfc for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erfc(a)
View source

#erfc(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method erfc on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
View source

#erfc!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method erfc on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
View source

#erfc!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function erfc for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erfc!(a)
View source

#erfc!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method erfc on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
View source

#exp(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method exp on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
View source

#exp(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function exp for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp(a)
View source

#exp(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method exp on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
View source

#exp!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method exp on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
View source

#exp!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function exp for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp!(a)
View source

#exp!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method exp on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
View source

#exp10(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function exp10 for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp10(a)
View source

#exp10!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function exp10 for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp10!(a)
View source

#exp2(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method exp2 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
View source

#exp2(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function exp2 for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp2(a)
View source

#exp2(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method exp2 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
View source

#exp2!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method exp2 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
View source

#exp2!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function exp2 for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp2!(a)
View source

#exp2!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method exp2 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
View source

#expand_dims(arr : Tensor(U, V), axis : Int) : Tensor(U, V) forall U, V #

Expands a Tensor along an axis

Arguments#
  • arr : Tensor - Tensor to expand
  • axis : Int - Axis along which to expand
Examples#
a = [1, 2, 3].to_tensor
a.expand_dims(0) # => [[1, 2, 3]]
View source

#expm1(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method expm1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
View source

#expm1(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function expm1 for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.expm1(a)
View source

#expm1(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method expm1 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
View source

#expm1!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method expm1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
View source

#expm1!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function expm1 for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.expm1!(a)
View source

#expm1!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method expm1 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
View source

#fabs(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fabs for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fabs(a)
View source

#fabs!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function fabs for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fabs!(a)
View source

#flat(arr : Tensor(U, CPU(U))) forall U #

Flattens a Tensor to a single dimension. If a view can be created, the reshape operation will not copy data.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.flat # => [0, 1, 2, 3]
View source

#flat(arr : Tensor(U, ARROW(U))) forall U #

Flattens a Tensor to a single dimension. If a view can be created, the reshape operation will not copy data.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.flat # => [0, 1, 2, 3]
View source

#flip(a : Tensor(U, CPU(U)), axis : Int) forall U #

Flips a Tensor along an axis, returning a view

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a, 1)

# [[3, 2, 1],
#  [6, 5, 4]]
View source

#flip(a : Tensor(U, ARROW(U)), axis : Int) forall U #

Flips a Tensor along an axis, returning a view

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a, 1)

# [[3, 2, 1],
#  [6, 5, 4]]
View source

#flip(a : Tensor(U, CPU(U))) forall U #

Flips a Tensor along all axes, returning a view

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a)

# [[6, 5, 4],
#  [3, 2, 1]]
View source

#flip(a : Tensor(U, ARROW(U))) forall U #

Flips a Tensor along all axes, returning a view

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a)

# [[6, 5, 4],
#  [3, 2, 1]]
View source

#floor(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function floor for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.floor(a)
View source

#floor!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function floor for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.floor!(a)
View source

#floordiv(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :// operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv(a, b)
View source

#floordiv(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :// operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(a, b)
View source

#floordiv(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :// operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(b, a)
View source

#floordiv(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :// operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv(a, b)
View source

#floordiv(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :// operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(a, b)
View source

#floordiv(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :// operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(b, a)
View source

#floordiv!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :// operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv!(a, b) # a is modified
View source

#floordiv!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :// operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv!(a, b)
View source

#floordiv!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :// operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv!(a, b) # a is modified
View source

#floordiv!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :// operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv!(a, b)
View source

#gamma(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method gamma on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
View source

#gamma(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method gamma on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
View source

#gamma!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method gamma on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
View source

#gamma!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method gamma on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
View source

#greater(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater(a, b)
View source

#greater(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(a, b)
View source

#greater(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :> operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(b, a)
View source

#greater(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.greater(a, a)
View source

#greater(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the ">" operator
  • b : U - RHS argument to the ">" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.greater(a, 3)
View source

#greater(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the ">" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the ">" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.greater(3, a)
View source

#greater(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater(a, b)
View source

#greater(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(a, b)
View source

#greater(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :> operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(b, a)
View source

#greater!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater!(a, b) # a is modified
View source

#greater!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater!(a, b)
View source

#greater!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater!(a, b) # a is modified
View source

#greater!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater!(a, b)
View source

#greater_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :>= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal(a, b)
View source

#greater_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :>= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(a, b)
View source

#greater_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :>= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(b, a)
View source

#greater_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">=" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.greater_equal(a, a)
View source

#greater_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">=" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the ">=" operator
  • b : U - RHS argument to the ">=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.greater_equal(a, 3)
View source

#greater_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator ">=" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the ">=" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the ">=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.greater_equal(3, a)
View source

#greater_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :>= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal(a, b)
View source

#greater_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :>= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(a, b)
View source

#greater_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :>= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(b, a)
View source

#greater_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :>= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal!(a, b) # a is modified
View source

#greater_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :>= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal!(a, b)
View source

#greater_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :>= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal!(a, b) # a is modified
View source

#greater_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :>= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal!(a, b)
View source

#hstack(arrs : Array(Tensor(U, V))) forall U, V #

Stack an array of Tensors in sequence column-wise. While this method can take Tensors with any number of dimensions, it makes the most sense with rank <= 3

For one dimensional Tensors, this will still stack along the first axis

Arguments#
Examples#
a = [1, 2, 3].to_tensor
Num.h_concat([a, a]) # => [1, 2, 3, 1, 2, 3]

b = [[1, 2], [3, 4]].to_tensor
Num.h_concat([b, b])

# [[1, 2, 1, 2],
#  [3, 4, 3, 4]]
View source

#hstack(*arrs : Tensor(U, V)) forall U, V #

Stack an array of Tensors in sequence column-wise. While this method can take Tensors with any number of dimensions, it makes the most sense with rank <= 3

For one dimensional Tensors, this will still stack along the first axis

Arguments#
  • arrs : Tuple(Tensor) - Tensors to concatenate
Examples#
a = [1, 2, 3].to_tensor
Num.h_concat([a, a]) # => [1, 2, 3, 1, 2, 3]

b = [[1, 2], [3, 4]].to_tensor
Num.h_concat([b, b])

# [[1, 2, 1, 2],
#  [3, 4, 3, 4]]
View source

#hypot(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method hypot on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot(a, b)
View source

#hypot(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method hypot on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot(a, b)
View source

#hypot(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method hypot on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.hypot(a, b)
View source

#hypot(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method hypot on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot(a, b)
View source

#hypot(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method hypot on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot(a, b)
View source

#hypot(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method hypot on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.hypot(a, b)
View source

#hypot!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method hypot on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot!(a, b)
View source

#hypot!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method hypot on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot!(a, b)
View source

#hypot!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method hypot on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot!(a, b)
View source

#hypot!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method hypot on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot!(a, b)
View source

#ilogb(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method ilogb on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
View source

#ilogb(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method ilogb on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
View source

#ilogb!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method ilogb on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
View source

#ilogb!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method ilogb on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
View source

#ldexp(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method ldexp on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp(a, b)
View source

#ldexp(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method ldexp on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp(a, b)
View source

#ldexp(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method ldexp on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.ldexp(a, b)
View source

#ldexp(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method ldexp on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp(a, b)
View source

#ldexp(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method ldexp on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp(a, b)
View source

#ldexp(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method ldexp on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.ldexp(a, b)
View source

#ldexp!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method ldexp on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp!(a, b)
View source

#ldexp!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method ldexp on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp!(a, b)
View source

#ldexp!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method ldexp on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp!(a, b)
View source

#ldexp!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method ldexp on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp!(a, b)
View source

#left_shift(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :<< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift(a, b)
View source

#left_shift(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :<< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(a, b)
View source

#left_shift(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :<< operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(b, a)
View source

#left_shift(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "<<" between two Tensors. Only Int32 and UInt32 Tensors are supported

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.left_shift(a, a)
View source

#left_shift(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "<<" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "<<" operator
  • b : U - RHS argument to the "<<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.left_shift(a, 3)
View source

#left_shift(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator "<<" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : U - LHS argument to the "<<" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "<<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.left_shift(3, a)
View source

#left_shift(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :<< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift(a, b)
View source

#left_shift(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :<< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(a, b)
View source

#left_shift(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :<< operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(b, a)
View source

#left_shift!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :<< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift!(a, b) # a is modified
View source

#left_shift!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :<< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift!(a, b)
View source

#left_shift!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :<< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift!(a, b) # a is modified
View source

#left_shift!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :<< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift!(a, b)
View source

#less(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less(a, b)
View source

#less(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(a, b)
View source

#less(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :< operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(b, a)
View source

#less(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.less(a, a)
View source

#less(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "<" operator
  • b : U - RHS argument to the "<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.less(a, 3)
View source

#less(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the "<" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.less(3, a)
View source

#less(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less(a, b)
View source

#less(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(a, b)
View source

#less(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :< operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(b, a)
View source

#less!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less!(a, b) # a is modified
View source

#less!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less!(a, b)
View source

#less!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :< operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less!(a, b) # a is modified
View source

#less!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :< operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less!(a, b)
View source

#less_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :<= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal(a, b)
View source

#less_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :<= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(a, b)
View source

#less_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :<= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(b, a)
View source

#less_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<=" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.less_equal(a, a)
View source

#less_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<=" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "<=" operator
  • b : U - RHS argument to the "<=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.less_equal(a, 3)
View source

#less_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "<=" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the "<=" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "<=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.less_equal(3, a)
View source

#less_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :<= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal(a, b)
View source

#less_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :<= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(a, b)
View source

#less_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :<= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(b, a)
View source

#less_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :<= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal!(a, b) # a is modified
View source

#less_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :<= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal!(a, b)
View source

#less_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :<= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal!(a, b) # a is modified
View source

#less_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :<= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal!(a, b)
View source

#lgamma(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method lgamma on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
View source

#lgamma(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function lgamma for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.lgamma(a)
View source

#lgamma(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method lgamma on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
View source

#lgamma!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method lgamma on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
View source

#lgamma!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function lgamma for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.lgamma!(a)
View source

#lgamma!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method lgamma on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
View source

#log(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method log on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
View source

#log(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function log for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log(a)
View source

#log(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method log on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
View source

#log!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method log on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
View source

#log!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function log for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log!(a)
View source

#log!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method log on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
View source

#log10(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method log10 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
View source

#log10(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function log10 for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log10(a)
View source

#log10(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method log10 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
View source

#log10!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method log10 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
View source

#log10!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function log10 for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log10!(a)
View source

#log10!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method log10 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
View source

#log1p(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method log1p on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
View source

#log1p(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function log1p for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log1p(a)
View source

#log1p(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method log1p on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
View source

#log1p!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method log1p on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
View source

#log1p!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function log1p for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log1p!(a)
View source

#log1p!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method log1p on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
View source

#log2(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method log2 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
View source

#log2(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function log2 for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log2(a)
View source

#log2(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method log2 on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
View source

#log2!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method log2 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
View source

#log2!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function log2 for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log2!(a)
View source

#log2!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method log2 on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
View source

#logb(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method logb on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
View source

#logb(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function logb for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.logb(a)
View source

#logb(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method logb on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
View source

#logb!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method logb on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
View source

#logb!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function logb for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.logb!(a)
View source

#logb!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method logb on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
View source

#map(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), a2 : Tensor(W, CPU(W)), &block : U, V, W -> X) : Tensor(X, CPU(X)) forall U, V, W, X #

Maps a block across three Tensors. This is more efficient than zipping iterators since it iterates all Tensor's in a single call, avoiding overhead from tracking multiple iterators.

The generic type of the returned Tensor is inferred from a block

Arguments#
  • a0 : Tensor(U, CPU(U)) - First Tensor for iteration, must be broadcastable against the shape of a1 and a2
  • a1 : Tensor(V, CPU(V)) - Second Tensor for iteration, must be broadcastable against the shape of a0 and a2
  • a2 : Tensor(W, CPU(W)) - Third Tensor for iteration, must be broadcastable against the shape of a0 and a1
  • block : Proc(T, U, V) - The block to map across both Tensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
c = Tensor.new([3]) { |i| i }

a.map(b, c) { |i, j, k| i + j + k } # => [0, 3, 6]
View source

#map(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), a2 : Tensor(W, ARROW(W)), &block : U, V, W -> X) : Tensor(X, ARROW(X)) forall U, V, W, X #

Maps a block across three Tensors. This is more efficient than zipping iterators since it iterates all Tensor's in a single call, avoiding overhead from tracking multiple iterators.

The generic type of the returned Tensor is inferred from a block

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
c = Tensor.new([3]) { |i| i }

a.map(b, c) { |i, j, k| i + j + k } # => [0, 3, 6]
View source

#map(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), &block : U, V -> W) forall U, V, W #

Maps a block across two Tensors. This is more efficient than zipping iterators since it iterates both Tensor's in a single call, avoiding overhead from tracking multiple iterators.

The generic type of the returned Tensor is inferred from a block

Arguments#
  • a0 : Tensor(U, CPU(U)) - First Tensor for iteration, must be broadcastable against the shape of a1
  • a1 : Tensor(V, CPU(V)) - Second Tensor for iteration, must be broadcastable against the shape of a0
  • block : Proc(T, U, V) - The block to map across both Tensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }

a.map(b) { |i, j| i + j } # => [0, 2, 4]
View source

#map(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), &block : U, V -> W) forall U, V, W #

Maps a block across two Tensors. This is more efficient than zipping iterators since it iterates both Tensor's in a single call, avoiding overhead from tracking multiple iterators.

The generic type of the returned Tensor is inferred from a block

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }

a.map(b) { |i, j| i + j } # => [0, 2, 4]
View source

#map(arr : Tensor(U, CPU(U)), &block : U -> V) : Tensor(V, CPU(V)) forall U, V #

Maps a block across a Tensor. The Tensor is treated as flat during iteration, and iteration is always done in RowMajor order

The generic type of the returned Tensor is inferred from the block

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
a.map { |e| e + 5 } # => [5, 6, 7]
View source

#map(arr : Tensor(U, ARROW(U)), &block : U -> V) : Tensor(V, ARROW(V)) forall U, V #

Maps a block across a Tensor. The Tensor is treated as flat during iteration, and iteration is always done in RowMajor order

The generic type of the returned Tensor is inferred from the block

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
a.map { |e| e + 5 } # => [5, 6, 7]
View source

#map!(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), a2 : Tensor(W, CPU(W)), &) forall U, V, W #

Maps a block across three Tensors. This is more efficient than zipping iterators since it iterates all Tensor's in a single call, avoiding overhead from tracking multiple iterators. The result of the block is stored in self.

Broadcasting rules still apply, but since this is an in place operation, the other Tensor's must broadcast to the shape of self

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
c = Tensor.new([3]) { |i| i }

a.map!(b, c) { |i, j, k| i + j + k }
a # => [0, 3, 6]
View source

#map!(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), a2 : Tensor(W, ARROW(W)), &) forall U, V, W #

Maps a block across three Tensors. This is more efficient than zipping iterators since it iterates all Tensor's in a single call, avoiding overhead from tracking multiple iterators. The result of the block is stored in self.

Broadcasting rules still apply, but since this is an in place operation, the other Tensor's must broadcast to the shape of self

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
c = Tensor.new([3]) { |i| i }

a.map!(b, c) { |i, j, k| i + j + k }
a # => [0, 3, 6]
View source

#map!(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), &block : U, V -> _) forall U, V #

Maps a block across two Tensors. This is more efficient than zipping iterators since it iterates both Tensor's in a single call, avoiding overhead from tracking multiple iterators. The result of the block is stored in self.

Broadcasting rules still apply, but since this is an in place operation, the other Tensor must broadcast to the shape of self

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }

a.map!(b) { |i, j| i + j }
a # => [0, 2, 4]
View source

#map!(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), &block : U, V -> _) forall U, V #

Maps a block across two Tensors. This is more efficient than zipping iterators since it iterates both Tensor's in a single call, avoiding overhead from tracking multiple iterators. The result of the block is stored in self.

Broadcasting rules still apply, but since this is an in place operation, the other Tensor must broadcast to the shape of self

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }

a.map!(b) { |i, j| i + j }
a # => [0, 2, 4]
View source

#map!(arr : Tensor(U, CPU(U)), &block : U -> _) forall U #

Maps a block across a Tensor in place. The Tensor is treated as flat during iteration, and iteration is always done in RowMajor order

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
a.map! { |e| e + 5 }
a # => [5, 6, 7]
View source

#map!(arr : Tensor(U, ARROW(U)), &block : U -> _) forall U #

Maps a block across a Tensor in place. The Tensor is treated as flat during iteration, and iteration is always done in RowMajor order

Arguments#
Examples#
a = Tensor.new([3]) { |i| i }
a.map! { |e| e + 5 }
a # => [5, 6, 7]
View source

#max(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method max on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max(a, b)
View source

#max(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the max of each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.max(a, 0) # => [2, 3]
Num.max(a, 1, dims: true)
# [[1],
#  [3]]
View source

#max(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method max on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max(a, b)
View source

#max(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method max on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.max(a, b)
View source

#max(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmax between two Tensors

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.fmax(a, b)
View source

#max(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmax between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmax(a, 3_f64)
View source

#max(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmax between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmax(3_f64, a)
View source

#max(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method max on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max(a, b)
View source

#max(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the max of each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.max(a, 0) # => [2, 3]
Num.max(a, 1, dims: true)
# [[1],
#  [3]]
View source

#max(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method max on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max(a, b)
View source

#max(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method max on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.max(a, b)
View source

#max(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by finding the maximum value

Arguments#
Examples#
a = [1, 2, 3]
Num.max(a) # => 3
View source

#max(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by finding the maximum value

Arguments#
Examples#
a = [1, 2, 3]
Num.max(a) # => 3
View source

#max!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method max on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max!(a, b)
View source

#max!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method max on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max!(a, b)
View source

#max!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function fmax between two Tensors, mutating the first Tensor, modifying it to store the result of the operation

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.fmax!(a, b)
View source

#max!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method max on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max!(a, b)
View source

#max!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method max on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max!(a, b)
View source

#mean(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the average of each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.mean(a, 0) # => [1, 2]
Num.mean(a, 1, dims: true)
# [[0],
#  [2]]
View source

#mean(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the average of each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.mean(a, 0) # => [1, 2]
Num.mean(a, 1, dims: true)
# [[0],
#  [2]]
View source

#mean(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by finding the average

Arguments#
Examples#
a = [1, 2, 3]
Num.mean(a) # => 2.0
View source

#mean(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by finding the average

Arguments#
Examples#
a = [1, 2, 3]
Num.mean(a) # => 2.0
View source

#min(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the stdlib Math method min on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min(a, b)
View source

#min(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the min of each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.min(a, 0) # => [0, 1]
Num.min(a, 1, dims: true)
# [[0],
#  [2]]
View source

#min(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method min on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min(a, b)
View source

#min(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method min on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.min(a, b)
View source

#min(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmin between two Tensors

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.fmin(a, b)
View source

#min(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmin between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmin(a, 3_f64)
View source

#min(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function fmin between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmin(3_f64, a)
View source

#min(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the stdlib Math method min on two Tensors, broadcasting the Tensors together.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min(a, b)
View source

#min(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the min of each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.min(a, 0) # => [0, 1]
Num.min(a, 1, dims: true)
# [[0],
#  [2]]
View source

#min(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the stdlib Math method min on a Tensor and a Number, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min(a, b)
View source

#min(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method min on a Number and a Tensor, broadcasting the method across all elements of a Tensor

Arguments#
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.min(a, b)
View source

#min(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by finding the minimum value

Arguments#
Examples#
a = [1, 2, 3]
Num.min(a) # => 3
View source

#min(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by finding the minimum value

Arguments#
Examples#
a = [1, 2, 3]
Num.min(a) # => 3
View source

#min!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the stdlib Math method min on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min!(a, b)
View source

#min!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U #

Implements the stdlib Math method min on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min!(a, b)
View source

#min!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function fmin between two Tensors, mutating the first Tensor, modifying it to store the result of the operation

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.fmin!(a, b)
View source

#min!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the stdlib Math method min on a Tensor, broadcasting the Tensors together. The second Tensor must broadcast against the shape of the first, as the first Tensor is modified inplace.

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min!(a, b)
View source

#min!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the stdlib Math method min on a Tensor and a Number, broadcasting the method across all elements of a Tensor. The Tensor is modified inplace

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min!(a, b)
View source

#modulo(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :% operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo(a, b)
View source

#modulo(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :% operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(a, b)
View source

#modulo(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :% operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(b, a)
View source

#modulo(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :% operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo(a, b)
View source

#modulo(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :% operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(a, b)
View source

#modulo(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :% operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(b, a)
View source

#modulo!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :% operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo!(a, b) # a is modified
View source

#modulo!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :% operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo!(a, b)
View source

#modulo!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :% operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo!(a, b) # a is modified
View source

#modulo!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :% operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo!(a, b)
View source

#move_axis(arr : Tensor(U, CPU(U)), source : Array(Int), destination : Array(Int)) forall U #

Move axes of a Tensor to new positions, other axes remain in their original order

Arguments#
Examples#
a = Tensor(Int8, CPU(Int8)).new([3, 4, 5])
Num.moveaxis(a, [0], [-1]).shape # => 4, 5, 3
View source

#move_axis(arr : Tensor(U, CPU(U)), source : Int, destination : Int) forall U #

Move axes of a Tensor to new positions, other axes remain in their original order

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to permute
  • source : Int - Original position of axis
  • destination : Int - Destination position of axis
Examples#
a = Tensor(Int8, CPU(Int8)).new([3, 4, 5])
Num.moveaxis(a, 0, 1).shape # => 4, 5, 3
View source

#move_axis(arr : Tensor(U, ARROW(U)), source : Array(Int), destination : Array(Int)) forall U #

Move axes of a Tensor to new positions, other axes remain in their original order

Arguments#
Examples#
a = Tensor(Int8, ARROW(Int8)).new([3, 4, 5])
Num.moveaxis(a, [0], [-1]).shape # => 4, 5, 3
View source

#move_axis(arr : Tensor(U, ARROW(U)), source : Int, destination : Int) forall U #

Move axes of a Tensor to new positions, other axes remain in their original order

Arguments#
  • arr : Tensor(U, ARROW(U)) - Tensor to permute
  • source : Int - Original position of axis
  • destination : Int - Destination position of axis
Examples#
a = Tensor(Int8, ARROW(Int8)).new([3, 4, 5])
Num.moveaxis(a, 0, 1).shape # => 4, 5, 3
View source

#multiply(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :* operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply(a, b)
View source

#multiply(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :* operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(a, b)
View source

#multiply(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :* operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(b, a)
View source

#multiply(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Multiply two Tensors elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, a)
View source

#multiply(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Multiply a Tensor and a Number elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
View source

#multiply(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Multiply a Number and a Tensor elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
View source

#multiply(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :* operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply(a, b)
View source

#multiply(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :* operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(a, b)
View source

#multiply(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :* operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(b, a)
View source

#multiply!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :* operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply!(a, b) # a is modified
View source

#multiply!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :* operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply!(a, b)
View source

#multiply!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

"Multiply" two Tensors elementwise, storing the result in the first Tensor

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply!(a, a)
View source

#multiply!(a : Tensor(U, OCL(U)), b : U) : Nil forall U #

Multiply a Tensor and a Number elementwise, modifying the Tensor inplace.

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
View source

#multiply!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :* operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply!(a, b) # a is modified
View source

#multiply!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :* operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply!(a, b)
View source

#negate(a : Tensor(U, CPU(U))) : Tensor(U, CPU(U)) forall U #

Implements the negation operator on a Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
View source

#negate(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the negation operator on a Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
View source

#negate(a : Tensor(U, ARROW(U))) : Tensor(U, ARROW(U)) forall U #

Implements the negation operator on a Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
View source

#not_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :!= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal(a, b)
View source

#not_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :!= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(a, b)
View source

#not_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :!= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(b, a)
View source

#not_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "!=" between two Tensors. The returned result of OpenCL relational operators will always be Tensor(Int32, OCL(Int32)).

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.not_equal(a, a)
View source

#not_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "!=" between a Tensor and a Number. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the "!=" operator
  • b : U - RHS argument to the "!=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.not_equal(a, 3)
View source

#not_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U #

Implements the comparison operator "!=" between a Number and a Tensor. The returned result of OpenCL relational operators will always beTensor(Int32, OCL(Int32))`.

Arguments#
  • a : U - LHS argument to the "!=" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the "!=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.not_equal(3, a)
View source

#not_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :!= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal(a, b)
View source

#not_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :!= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(a, b)
View source

#not_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :!= operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(b, a)
View source

#not_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :!= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal!(a, b) # a is modified
View source

#not_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :!= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal!(a, b)
View source

#not_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :!= operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal!(a, b) # a is modified
View source

#not_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :!= operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal!(a, b)
View source

#opencl(arr : Tensor(U, CPU(U))) : Tensor(U, OCL(U)) forall U #

Places a Tensor stored on a CPU onto an OpenCL Device.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
View source

#opencl(arr : Tensor(U, ARROW(U))) : Tensor(U, OCL(U)) forall U #

Places a Tensor stored on a ARROW onto an OpenCL Device.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
View source

#power(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :** operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power(a, b)
View source

#power(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :** operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(a, b)
View source

#power(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :** operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(b, a)
View source

#power(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function pow between two Tensors

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.pow(a, b)
View source

#power(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function pow between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.pow(a, 3_f64)
View source

#power(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function pow between two a Tensor and a Number

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.pow(3_f64, a)
View source

#power(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :** operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power(a, b)
View source

#power(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :** operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(a, b)
View source

#power(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :** operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(b, a)
View source

#power!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :** operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power!(a, b) # a is modified
View source

#power!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :** operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power!(a, b)
View source

#power!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function pow between two Tensors, mutating the first Tensor, modifying it to store the result of the operation

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
b = [0.2, 0.5, 0.1].to_tensor(OCL)
Num.pow!(a, b)
View source

#power!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :** operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power!(a, b) # a is modified
View source

#power!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :** operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power!(a, b)
View source

#prod(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, multiplying each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.prod(a, 0) # => [0, 3]
Num.prod(a, 1, dims: true)
# [[0],
#  [6]]
View source

#prod(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, multiplying each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.prod(a, 0) # => [0, 3]
Num.prod(a, 1, dims: true)
# [[0],
#  [6]]
View source

#prod(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by multiplying all of its elements

Arguments#
Examples#
a = [1, 2, 3]
Num.prod(a) # => 6
View source

#prod(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by multiplying all of its elements

Arguments#
Examples#
a = [1, 2, 3]
Num.prod(a) # => 6
View source

#ptp(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Finds the difference between the maximum and minimum elements of a Tensor along an axis

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[3, 4], [1, 2], [6, 2]]
Num.ptp(a, 1) # [1, 1, 4]
View source

#ptp(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Finds the difference between the maximum and minimum elements of a Tensor along an axis

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = [[3, 4], [1, 2], [6, 2]]
Num.ptp(a, 1) # [1, 1, 4]
View source

#ptp(a : Tensor(U, CPU(U))) forall U #

Finds the difference between the maximum and minimum elements of a Tensor

Arguments#
Examples#
a = [1, 2, 3]
Num.ptp(a) # => 2
View source

#ptp(a : Tensor(U, ARROW(U))) forall U #

Finds the difference between the maximum and minimum elements of a Tensor

Arguments#
Examples#
a = [1, 2, 3]
Num.ptp(a) # => 2
View source

#reduce_axis(a0 : Tensor(U, CPU(U)), axis : Int, dims : Bool = false, &block : U, U -> _) forall U #

Reduces a Tensor along an axis. Returns a Tensor, with the axis of reduction either removed, or reduced to 1 if dims is True, which allows the result to broadcast against its previous shape

Arguments#
  • a0 : Tensor(U, CPU(U)) - Tensor to reduce along an axis
  • axis : Int - Axis of reduction
  • dims : Bool - Flag determining whether the axis of reduction should be kept in the result
  • block : Proc(U, U, _) - Proc to apply to values along an axis
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.reduce_axis(0) { |i, j| i + j } # => [2, 4]
View source

#reduce_axis(a0 : Tensor(U, OCL(U)), axis : Int, dims : Bool = false, &block : Tensor(U, OCL(U)), Tensor(U, OCL(U)) -> _) : Tensor(U, OCL(U)) forall U #

Reduces a Tensor along an axis. Returns a Tensor, with the axis of reduction either removed, or reduced to 1 if dims is True, which allows the result to broadcast against its previous shape

Arguments#
  • a0 : Tensor(U, OCL(U)) - Tensor to reduce along an axis
  • axis : Int - Axis of reduction
  • dims : Bool - Flag determining whether the axis of reduction should be kept in the result
  • block : Proc(Tensor(U, OCL(U)), Tensor(U, OCL(U)), _) - Proc to apply to values along an axis
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.reduce_axis(0) { |i, j| Num.add!(i, j) } # => "<2> on OpenCL Backend"
View source

#reduce_axis(a0 : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false, &block : U, U -> _) forall U #

Reduces a Tensor along an axis. Returns a Tensor, with the axis of reduction either removed, or reduced to 1 if dims is True, which allows the result to broadcast against its previous shape

Arguments#
  • a0 : Tensor(U, ARROW(U)) - Tensor to reduce along an axis
  • axis : Int - Axis of reduction
  • dims : Bool - Flag determining whether the axis of reduction should be kept in the result
  • block : Proc(U, U, _) - Proc to apply to values along an axis
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.reduce_axis(0) { |i, j| i + j } # => [2, 4]
View source

#repeat(a : Tensor(U, CPU(U)), n : Int, axis : Int) forall U #

Repeat elements of a Tensor along an axis

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to repeat
  • n : Int - Number of times to repeat
  • axis : Int - Axis along which to repeat
Examples#
a = [[1, 2, 3], [4, 5, 6]]
Num.repeat(a, 2, 1)

# [[1, 1, 2, 2, 3, 3],
#  [4, 4, 5, 5, 6, 6]]
View source

#repeat(a : Tensor(U, ARROW(U)), n : Int, axis : Int) forall U #

Repeat elements of a Tensor along an axis

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
Num.repeat(a, 2, 1)

# [[1, 1, 2, 2, 3, 3],
#  [4, 4, 5, 5, 6, 6]]
View source

#repeat(a : Tensor(U, CPU(U)), n : Int) forall U #

Repeat elements of a Tensor, treating the Tensor as flat

Arguments#
Examples#
a = [1, 2, 3]
Num.repeat(a, 2) # => [1, 1, 2, 2, 3, 3]
View source

#repeat(a : Tensor(U, ARROW(U)), n : Int) forall U #

Repeat elements of a Tensor, treating the Tensor as flat

Arguments#
Examples#
a = [1, 2, 3]
Num.repeat(a, 2) # => [1, 1, 2, 2, 3, 3]
View source

#reshape(arr : Tensor(U, CPU(U)), shape : Array(Int)) forall U #

Transform's a Tensor's shape. If a view can be created, the reshape will not copy data. The number of elements in the Tensor must remain the same.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])

# [[1, 2],
#  [3, 4]]
View source

#reshape(arr : Tensor(U, ARROW(U)), shape : Array(Int)) forall U #

Transform's a Tensor's shape. If a view can be created, the reshape will not copy data. The number of elements in the Tensor must remain the same.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])

# [[1, 2],
#  [3, 4]]
View source

#reshape(arr : Tensor(U, CPU(U)), *shape : Int) forall U #

Transform's a Tensor's shape. If a view can be created, the reshape will not copy data. The number of elements in the Tensor must remain the same.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])

# [[1, 2],
#  [3, 4]]
View source

#reshape(arr : Tensor(U, ARROW(U)), *shape : Int) forall U #

Transform's a Tensor's shape. If a view can be created, the reshape will not copy data. The number of elements in the Tensor must remain the same.

Arguments#
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])

# [[1, 2],
#  [3, 4]]
View source

#right_shift(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :>> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift(a, b)
View source

#right_shift(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :>> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(a, b)
View source

#right_shift(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :>> operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(b, a)
View source

#right_shift(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator ">>" between two Tensors. Only Int32 and UInt32 Tensors are supported

Arguments#
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.right_shift(a, a)
View source

#right_shift(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator ">>" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : Tensor(U, OCL(U)) - LHS argument to the ">>" operator
  • b : U - RHS argument to the ">>" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.right_shift(a, 3)
View source

#right_shift(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the bitwise operator ">>" between a Tensor and a Number

Only Int32 and UInt32 Tensors are supported

Arguments#
  • a : U - LHS argument to the ">>" operator
  • b : Tensor(U, OCL(U)) - RHS argument to the ">>" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
Num.right_shift(3, a)
View source

#right_shift(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :>> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift(a, b)
View source

#right_shift(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :>> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(a, b)
View source

#right_shift(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :>> operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(b, a)
View source

#right_shift!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :>> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift!(a, b) # a is modified
View source

#right_shift!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :>> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift!(a, b)
View source

#right_shift!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :>> operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift!(a, b) # a is modified
View source

#right_shift!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :>> operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift!(a, b)
View source

#rint(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function rint for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rint(a)
View source

#rint!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function rint for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rint!(a)
View source

#round(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function round for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.round(a)
View source

#round!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function round for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.round!(a)
View source

#rsqrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function rsqrt for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rsqrt(a)
View source

#rsqrt!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function rsqrt for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rsqrt!(a)
View source

#set(arr : Tensor(U, CPU(U)), args : Array, t : Tensor(V, CPU(V))) forall U, V #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, CPU(U)), args : Array, t : V) forall U, V #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to which values will be assigned
  • args : Array - Tuple of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : V - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, OCL(U)), args : Array, t : Tensor(U, OCL(U))) forall U #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, OCL(U)), args : Array, t : U) forall U #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, OCL(U)) - Tensor to which values will be assigned
  • args : Array - Array of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : U - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, ARROW(U)), args : Array, t : Tensor(V, ARROW(V))) forall U, V #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, ARROW(U)), args : Array, t : V) forall U, V #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, ARROW(U)) - Tensor to which values will be assigned
  • args : Array - Tuple of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : V - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, CPU(U)), *args, value) forall U #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to which values will be assigned
  • args : Tuple - Tuple of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : Tensor | Number - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, OCL(U)), *args, value) forall U #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, OCL(U)) - Tensor to which values will be assigned
  • args : Tuple - Tuple of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : Tensor | Number - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a.cpu

# [[ 0,  1],
#  [ 2, 99]]
View source

#set(arr : Tensor(U, ARROW(U)), *args, value) forall U #

The primary method of setting Tensor values. The slicing behavior for this method is identical to the [] method.

If a Tensor is passed as the value to set, it will be broadcast to the shape of the slice if possible. If a scalar is passed, it will be tiled across the slice.

Arguments#
  • arr : Tensor(U, ARROW(U)) - Tensor to which values will be assigned
  • args : Tuple - Tuple of arguments. All arguments must be valid indexers, so a Range, Int, or Tuple(Range, Int).
  • value : Tensor | Number - Argument to assign to the Tensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a

# [[ 0,  1],
#  [ 2, 99]]
View source

#sin(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method sin on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
View source

#sin(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function sin for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sin(a)
View source

#sin(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method sin on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
View source

#sin!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method sin on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
View source

#sin!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function sin for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sin!(a)
View source

#sin!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method sin on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
View source

#sinh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method sinh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
View source

#sinh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function sinh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinh(a)
View source

#sinh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method sinh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
View source

#sinh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method sinh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
View source

#sinh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function sinh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinh!(a)
View source

#sinh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method sinh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
View source

#sinpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function sinpi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinpi(a)
View source

#sinpi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function sinpi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinpi!(a)
View source

#slice(arr : Tensor(U, V), args : Array) forall U, V #

Returns a view of a Tensor from any valid indexers. This view must be able to be represented as valid strided/shaped view, slicing as a copy is not supported.

When an Integer argument is passed, an axis will be removed from the Tensor, and a view at that index will be returned.

a = Tensor.new([2, 2]) { |i| i }
a[0] # => [0, 1]

When a Range argument is passed, an axis will be sliced based on the endpoints of the range.

a = Tensor.new([2, 2, 2]) { |i| i }
a[1...]

# [[[4, 5],
#   [6, 7]]]

When a Tuple containing a Range and an Integer step is passed, an axis is sliced based on the endpoints of the range, and the strides of the axis are updated to reflect the step. Negative steps will reflect the array along an axis.

a = Tensor.new([2, 2]) { |i| i }
a[{..., -1}]

# [[2, 3],
#  [0, 1]]
View source

#slice(arr : Tensor(U, V), *args) forall U, V #

Returns a view of a Tensor from any valid indexers. This view must be able to be represented as valid strided/shaped view, slicing as a copy is not supported.

When an Integer argument is passed, an axis will be removed from the Tensor, and a view at that index will be returned.

a = Tensor.new([2, 2]) { |i| i }
a[0] # => [0, 1]

When a Range argument is passed, an axis will be sliced based on the endpoints of the range.

a = Tensor.new([2, 2, 2]) { |i| i }
a[1...]

# [[[4, 5],
#   [6, 7]]]

When a Tuple containing a Range and an Integer step is passed, an axis is sliced based on the endpoints of the range, and the strides of the axis are updated to reflect the step. Negative steps will reflect the array along an axis.

a = Tensor.new([2, 2]) { |i| i }
a[{..., -1}]

# [[2, 3],
#  [0, 1]]
View source

#sort(a : Tensor(U, CPU(U)), axis : Int) forall U #

Sorts a Tensor along an axis.

Arguments#
Examples#
t = Tensor.random(0...10, [3, 3, 2])
puts Num.sort(t, axis: 1)

# [[[1, 1],
#   [4, 5],
#   [5, 7]],
#
#  [[0, 0],
#   [2, 3],
#   [8, 4]],
#
#  [[2, 5],
#   [5, 7],
#   [5, 7]]]
View source

#sort(a : Tensor(U, ARROW(U)), axis : Int) forall U #

Sorts a Tensor along an axis.

Arguments#
Examples#
t = Tensor.random(0...10, [3, 3, 2])
puts Num.sort(t, axis: 1)

# [[[1, 1],
#   [4, 5],
#   [5, 7]],
#
#  [[0, 0],
#   [2, 3],
#   [8, 4]],
#
#  [[2, 5],
#   [5, 7],
#   [5, 7]]]
View source

#sort(a : Tensor(U, CPU(U))) forall U #

Sorts a Tensor, treating it's elements like the Tensor is flat.

Arguments#
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
View source

#sort(a : Tensor(U, CPU(U)), axis : Int, &block : U, U -> _) forall U #

Sorts a Tensor along an axis.

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to sort
  • axis : Int - Axis along which to sort
  • block : Proc(U, U, _) - Proc to use to sort
Examples#
t = Tensor.random(0...10, [3, 3, 2])
puts Num.sort(t, axis: 1) { |i, j| i <=> j }
# [[[3, 1],
#   [4, 3],
#   [6, 8]],
#
#  [[4, 2],
#   [5, 3],
#   [9, 7]],
#
#  [[0, 1],
#   [2, 2],
#   [4, 9]]]
View source

#sort(a : Tensor(U, ARROW(U)), axis : Int, &block : U, U -> _) forall U #

Sorts a Tensor along an axis.

Arguments#
Examples#
t = Tensor.random(0...10, [3, 3, 2])
puts Num.sort(t, axis: 1) { |i, j| i <=> j }
# [[[3, 1],
#   [4, 3],
#   [6, 8]],
#
#  [[4, 2],
#   [5, 3],
#   [9, 7]],
#
#  [[0, 1],
#   [2, 2],
#   [4, 9]]]
View source

#sort(a : Tensor(U, CPU(U)), &block : U, U -> _) forall U #

Sorts a Tensor, treating it's elements like the Tensor is flat.

Arguments#
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
View source

#sort(a : Tensor(U, ARROW(U))) forall U #

Sorts a Tensor, treating it's elements like the Tensor is flat.

Arguments#
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
View source

#sort(a : Tensor(U, ARROW(U)), &block : U, U -> _) forall U #

Sorts a Tensor, treating it's elements like the Tensor is flat.

Arguments#
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
View source

#split(a : Tensor(U, CPU(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U #

Split a Tensor into multiple sub-Tensors. The number of sections must divide the Tensor equally.

Arguments#
Examples#
a = Tensor.range(1, 9)
puts Num.array_split(a, 2) # => [[1, 2, 3, 4], [5, 6, 7, 8]]
View source

#split(a : Tensor(U, CPU(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U #

Split a Tensor into multiple sub-Tensors, using an explicit mapping of indices to split the Tensor

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
View source

#split(a : Tensor(U, ARROW(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U #

Split a Tensor into multiple sub-Tensors. The number of sections must divide the Tensor equally.

Arguments#
Examples#
a = Tensor.range(1, 9)
puts Num.array_split(a, 2) # => [[1, 2, 3, 4], [5, 6, 7, 8]]
View source

#split(a : Tensor(U, ARROW(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U #

Split a Tensor into multiple sub-Tensors, using an explicit mapping of indices to split the Tensor

Arguments#
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
View source

#sqrt(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method sqrt on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
View source

#sqrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function sqrt for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sqrt(a)
View source

#sqrt(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method sqrt on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
View source

#sqrt!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method sqrt on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
View source

#sqrt!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function sqrt for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sqrt!(a)
View source

#sqrt!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method sqrt on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
View source

#std(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the std of each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.std(a, 0) # => [1, 1]
Num.std(a, 1, dims: true)
# [[0.707107],
#  [0.707107]]
View source

#std(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, finding the std of each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.std(a, 0) # => [1, 1]
Num.std(a, 1, dims: true)
# [[0.707107],
#  [0.707107]]
View source

#std(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by finding the standard deviation

Arguments#
Examples#
a = [1, 2, 3]
Num.std(a) # => 0.816496580927726
View source

#std(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by finding the standard deviation

Arguments#
Examples#
a = [1, 2, 3]
Num.std(a) # => 0.816496580927726
View source

#subtract(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V #

Implements the :- operator between two Tensors. Broadcasting rules apply, the method is applied elementwise.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract(a, b)
View source

#subtract(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U #

Implements the :- operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(a, b)
View source

#subtract(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U #

Implements the :- operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
  • a : Number | Complex - RHS to the operation
  • b : Tensor(U, CPU(U)) - LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(b, a)
View source

#subtract(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Subtract two Tensors elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, a)
View source

#subtract(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U #

Subtract a Tensor and a Number elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
View source

#subtract(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Subtract a Number and a Tensor elementwise

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
View source

#subtract(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V #

Implements the :- operator between two Tensors. Broadcasting rules apply, the method is applied elementwise_arrow.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract(a, b)
View source

#subtract(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U #

Implements the :- operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(a, b)
View source

#subtract(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the :- operator between a scalar and Tensor. The scalar is broadcasted across all elements of the Tensor

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(b, a)
View source

#subtract!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V #

Implements the :- operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract!(a, b) # a is modified
View source

#subtract!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U #

Implements the :- operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
  • a : Tensor(U, CPU(U)) - LHS to the operation
  • b : Number | Complex - RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract!(a, b)
View source

#subtract!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U #

"Subtract" two Tensors elementwise, storing the result in the first Tensor

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract!(a, a)
View source

#subtract!(a : Tensor(U, OCL(U)), b : U) : Nil forall U #

Subtract a Tensor and a Number elementwise, modifying the Tensor inplace.

Arguments#
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
View source

#subtract!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V #

Implements the :- operator between two Tensors. Broadcasting rules apply, the method is applied elementwise. This method applies the operation inplace, storing the result in the LHS argument. Broadcasting cannot occur for the LHS operand, so the second argument must broadcast to the first operand's shape.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract!(a, b) # a is modified
View source

#subtract!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U #

Implements the :- operator between a Tensor and scalar. The scalar is broadcasted across all elements of the Tensor, and the Tensor is modified inplace.

Arguments#
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract!(a, b)
View source

#sum(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, summing each view into the Tensor

Arguments#
  • a : Tensor(U, CPU(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.sum(a, 0) # => [2, 4]
Num.sum(a, 1, dims: true)
# [[1],
#  [5]]
View source

#sum(a : Tensor(U, OCL(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, summing each view into the Tensor

Arguments#
  • a : Tensor(U, OCL(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
Num.sum(a, 0).cpu # => [2, 4]
Num.sum(a, 1, dims: true).cpu
# [[1],
#  [5]]
View source

#sum(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U #

Reduces a Tensor along an axis, summing each view into the Tensor

Arguments#
  • a : Tensor(U, ARROW(U)) - Tensor to reduce
  • axis : Int - Axis of reduction
  • dims : Bool - Indicate if the axis of reduction should remain in the result
Examples#
a = Tensor.new([2, 2]) { |i| i }
Num.sum(a, 0) # => [2, 4]
Num.sum(a, 1, dims: true)
# [[1],
#  [5]]
View source

#sum(a : Tensor(U, CPU(U))) forall U #

Reduces a Tensor to a scalar by summing all of its elements

Arguments#
Examples#
a = [1, 2, 3]
Num.sum(a) # => 6
View source

#sum(a : Tensor(U, ARROW(U))) forall U #

Reduces a Tensor to a scalar by summing all of its elements

Arguments#
Examples#
a = [1, 2, 3]
Num.sum(a) # => 6
View source

#swap_axes(arr : Tensor(U, CPU(U)), a : Int, b : Int) forall U #

Permutes two axes of a Tensor. This will always create a view of the permuted Tensor

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to permute
  • source : Int - First axis to swap
  • destination : Int - Second axis to swap
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.swap_axes(2, 0)

# [[[ 0,  6, 12, 18]
#   [ 2,  8, 14, 20]
#   [ 4, 10, 16, 22]]
#
#  [[ 1,  7, 13, 19]
#   [ 3,  9, 15, 21]
#   [ 5, 11, 17, 23]]]
View source

#swap_axes(arr : Tensor(U, ARROW(U)), a : Int, b : Int) forall U #

Permutes two axes of a Tensor. This will always create a view of the permuted Tensor

Arguments#
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.swap_axes(2, 0)

# [[[ 0,  6, 12, 18]
#   [ 2,  8, 14, 20]
#   [ 4, 10, 16, 22]]
#
#  [[ 1,  7, 13, 19]
#   [ 3,  9, 15, 21]
#   [ 5, 11, 17, 23]]]
View source

#tan(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method tan on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
View source

#tan(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function tan for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tan(a)
View source

#tan(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method tan on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
View source

#tan!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method tan on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
View source

#tan!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function tan for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tan!(a)
View source

#tan!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method tan on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
View source

#tanh(a : Tensor(U, CPU(U))) : Tensor forall U #

Implements the stdlib Math method tanh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
View source

#tanh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function tanh for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanh(a)
View source

#tanh(a : Tensor(U, ARROW(U))) : Tensor forall U #

Implements the stdlib Math method tanh on a Tensor, broadcasting the operation across all elements of the Tensor

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
View source

#tanh!(a : Tensor(U, CPU(U))) : Nil forall U #

Implements the stdlib Math method tanh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
View source

#tanh!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function tanh for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanh!(a)
View source

#tanh!(a : Tensor(U, ARROW(U))) : Nil forall U #

Implements the stdlib Math method tanh on a Tensor, broadcasting the operation across all elements of the Tensor. The Tensor is modified inplace to store the result

Arguments#
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
View source

#tanpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function tanpi for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanpi(a)
View source

#tanpi!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function tanpi for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanpi!(a)
View source

#tgamma(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function tgamma for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tgamma(a)
View source

#tgamma!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function tgamma for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tgamma!(a)
View source

#tile(a : Tensor(U, CPU(U)), n : Int) forall U #

Tile elements of a Tensor

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.tile(a, 2)

# [[1, 2, 3, 1, 2, 3],
#  [4, 5, 6, 4, 5, 6]]
View source

#tile(a : Tensor(U, CPU(U)), n : Array(Int)) forall U #

Tile elements of a Tensor

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.tile(a, 2)

# [[1, 2, 3, 1, 2, 3],
#  [4, 5, 6, 4, 5, 6]]
View source

#tile(a : Tensor(U, ARROW(U)), n : Int) forall U #

Tile elements of a Tensor

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.tile(a, 2)

# [[1, 2, 3, 1, 2, 3],
#  [4, 5, 6, 4, 5, 6]]
View source

#tile(a : Tensor(U, ARROW(U)), n : Array(Int)) forall U #

Tile elements of a Tensor

Arguments#
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.tile(a, 2)

# [[1, 2, 3, 1, 2, 3],
#  [4, 5, 6, 4, 5, 6]]
View source

#to_a(arr : Tensor(U, CPU(U))) forall U #

Converts a Tensor to a standard library array. The returned array will always be one-dimensional to avoid return type ambiguity

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.to_a # => [0, 1, 2, 3]
View source

#to_a(arr : Tensor(U, OCL(U))) forall U #

Converts a Tensor to a standard library array. The returned array will always be one-dimensional to avoid return type ambiguity

Arguments#
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a.to_a # => [0, 1, 2, 3]
View source

#to_a(arr : Tensor(U, ARROW(U))) forall U #

Converts a Tensor to a standard library array. The returned array will always be one-dimensional to avoid return type ambiguity

Arguments#
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.to_a # => [0, 1, 2, 3]
View source

#transpose(arr : Tensor(U, CPU(U)), axes : Array(Int) = [] of Int32) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#
Arguments#
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#transpose(arr : Tensor(U, OCL(U)), axes : Array(Int) = [] of Int32) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#

axes : Array(Int) New ordering of axes for the permuted Tensor. If empty, a full transpose will occur

Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#transpose(arr : Tensor(U, ARROW(U)), axes : Array(Int) = [] of Int32) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#
Arguments#
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#transpose(arr : Tensor(U, CPU(U)), *args : Int) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#
Arguments#
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#transpose(arr : Tensor(U, OCL(U)), *args : Int) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#

axes : Array(Int) New ordering of axes for the permuted Tensor. If empty, a full transpose will occur

Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#transpose(arr : Tensor(U, ARROW(U)), *args : Int) forall U #

Permutes a Tensor's axes to a different order. This will always create a view of the permuted Tensor.

Arguments#
Arguments#
Examples#
a = Tensor.new([4, 3, 2]) { |i| i }
a.transpose([2, 0, 1])

# [[[ 0,  2,  4],
#   [ 6,  8, 10],
#   [12, 14, 16],
#   [18, 20, 22]],
#
#  [[ 1,  3,  5],
#   [ 7,  9, 11],
#   [13, 15, 17],
#   [19, 21, 23]]]
View source

#trunc(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U #

Implements the OpenCL builtin function trunc for a single Tensor. Only Float32 and Float64 Tensors are supported.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.trunc(a)
View source

#trunc!(a : Tensor(U, OCL(U))) : Nil forall U #

Implements the OpenCL builtin function trunc for a single Tensor. Only Float32 and Float64 Tensors are supported. This method mutates the original Tensor, modifying it in place.

Arguments#
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.trunc!(a)
View source

#view(arr : Tensor(U, CPU(U)), dtype : V.class) forall U, V #

Return a shallow copy of a Tensor with a new dtype. The underlying data buffer is shared, but the Tensor owns its other attributes. The size of the new dtype must be a multiple of the current dtype

Arguments#
  • arr : Tensor(U, CPU(U)) - Tensor to view as a different data type
  • u : V.class - The data type used to reintepret the underlying data buffer of a Tensor
Examples#
a = Tensor.new([3]) { |i| i }
a.view(Int8) # => [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0]
View source

#view(arr : Tensor(U, ARROW(U)), dtype : V.class) forall U, V #

Return a shallow copy of a Tensor with a new dtype. The underlying data buffer is shared, but the Tensor owns its other attributes. The size of the new dtype must be a multiple of the current dtype

Arguments#
  • arr : Tensor(U, ARROW(U)) - Tensor to view as a different data type
  • u : V.class - The data type used to reintepret the underlying data buffer of a Tensor
Examples#
a = Tensor.new([3]) { |i| i }
a.view(Int8) # => [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0]
View source

#vstack(arrs : Array(Tensor(U, V))) forall U, V #

Stack an array of Tensors in sequence row-wise. While this method can take Tensors with any number of dimensions, it makes the most sense with rank <= 3

Arguments#
Examples#
a = [1, 2, 3].to_tensor
Num.vstack([a, a])

# [[1, 2, 3],
#  [1, 2, 3]]
View source

#vstack(*arrs : Tensor(U, V)) forall U, V #

Stack an array of Tensors in sequence row-wise. While this method can take Tensors with any number of dimensions, it makes the most sense with rank <= 3

Arguments#
  • arrs : Tuple(Tensor) - Tensors to concatenate
Examples#
a = [1, 2, 3].to_tensor
Num.vstack([a, a])

# [[1, 2, 3],
#  [1, 2, 3]]
View source

#with_broadcast(arr : Tensor(U, V), n : Int) : Tensor(U, V) forall U, V #

Expands a Tensors dimensions n times by broadcasting the shape and strides. No data is copied, and the result is a read-only view of the original Tensor

Arguments#
  • arr : Tensor - Tensor to broadcast
  • n : Int - Number of dimensions to broadcast
Examples#
a = [1, 2, 3].to_tensor
a.with_broadcast(2)

# [[[1]],
#
#  [[2]],
#
#  [[3]]]
View source

#yield_along_axis(a0 : Tensor(U, CPU(U)), axis : Int, &) forall U #

Similar to each_axis, but instead of yielding slices of an axis, it yields slices along an axis, useful for methods that require an entire view of an axis slice for a reduction operation, such as std, rather than being able to incrementally reduce.

Arguments#
Examples#
a = Tensor.new([3, 3, 3]) { |i| i }
a.yield_along_axis(0) do |ax|
  puts ax
end

# [ 0,  9, 18]
# [ 1, 10, 19]
# [ 2, 11, 20]
# [ 3, 12, 21]
# [ 4, 13, 22]
# [ 5, 14, 23]
# [ 6, 15, 24]
# [ 7, 16, 25]
# [ 8, 17, 26]
View source

#yield_along_axis(a0 : Tensor(U, ARROW(U)), axis : Int, &) forall U #

Similar to each_axis, but instead of yielding slices of an axis, it yields slices along an axis, useful for methods that require an entire view of an axis slice for a reduction operation, such as std, rather than being able to incrementally reduce.

Arguments#
Examples#
a = Tensor.new([3, 3, 3]) { |i| i }
a.yield_along_axis(0) do |ax|
  puts ax
end

# [ 0,  9, 18]
# [ 1, 10, 19]
# [ 2, 11, 20]
# [ 3, 12, 21]
# [ 4, 13, 22]
# [ 5, 14, 23]
# [ 6, 15, 24]
# [ 7, 16, 25]
# [ 8, 17, 26]
View source

#zip(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), &block : U, V -> _) forall U, V #

Yields the elements of two Tensors, always in RowMajor order, as if the Tensors were flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
b = Tensor.new(2, 2) { |i| i + 2 }
a.zip(b) do |el|
  puts el
end

# { 0, 2}
# { 1, 3}
# { 2, 4}
# { 3, 5}
View source

#zip(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), &block : U, V -> _) forall U, V #

Yields the elements of two Tensors, always in RowMajor order, as if the Tensors were flat.

Arguments#
Examples#
a = Tensor.new(2, 2) { |i| i }
b = Tensor.new(2, 2) { |i| i + 2 }
a.zip(b) do |el|
  puts el
end

# { 0, 2}
# { 1, 3}
# { 2, 4}
# { 3, 5}
View source