module Num
#
Extended modules
Num
Constants#
ColMajor = OrderType::ColMajor
#
OrderType::ColMajor
RowMajor = OrderType::RowMajor
#
OrderType::RowMajor
VERSION = "0.5.0"
#
"0.5.0"
Methods#
#acos(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
#acos(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acos(a)
#acos(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
#acos!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
#acos!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acos!(a)
#acos!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acos(a)
#acosh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
#acosh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acosh(a)
#acosh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
#acosh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
#acosh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acosh!(a)
#acosh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.acosh(a)
#acospi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acospi(a)
#acospi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.acospi!(a)
#add(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add(a, b)
#add(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#add(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#add(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Add two Tensors elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to add - b :
Tensor(U, OCL(U))- RHS argument to add
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, a)
#add(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
Add a Tensor and a Number elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to add - b :
U- RHS argument to add
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
#add(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Add a Number and a Tensor elementwise
Arguments#
- a :
U- LHS argument to add - b :
Tensor(U, OCL(U))- RHS argument to add
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
#add(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add(a, b)
#add(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(a, b)
#add(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add(b, a)
#add!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add!(a, b) # a is modified
#add!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#add!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to add, will be modified inplace - b :
Tensor(U, OCL(U))- RHS argument to add
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add!(a, a)
#add!(a : Tensor(U, OCL(U)), b : U) : Nil forall U
#
(a : Tensor(U, OCL(U)), b : U) : Nil forall U
Add a Tensor and a Number elementwise,
modifying the Tensor inplace.
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to add - b :
U- RHS argument to add
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.add(a, 3.5)
#add!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.add!(a, b) # a is modified
#add!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.add!(a, b)
#all(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#all(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#all(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a boolean by asserting the truthiness of
all elements
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [0, 2, 3]
Num.all(a) # => false
#all(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a boolean by asserting the truthiness of
all elements
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [0, 2, 3]
Num.all(a) # => false
#all_close(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), epsilon = 1e-6) : Bool forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to compare - b :
Tensor(V, CPU(V))- RHS argument to compare - epsilon :
Number- Allowed variance between numbers
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
#all_close(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), epsilon = 1e-6) : Bool forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to compare - b :
Tensor(V, ARROW(V))- RHS argument to compare - epsilon :
Number- Allowed variance between numbers
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
#any(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#any(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#any(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a boolean by asserting the truthiness of
any element
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [0, 2, 3]
Num.any(a) # => true
#any(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a boolean by asserting the truthiness of
any element
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [0, 2, 3]
Num.any(a) # => true
#argmax(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#argmax(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#argmax(a : Tensor(U, CPU(U))) : Int32 forall U
#
(a : Tensor(U, CPU(U))) : Int32 forall U
Find the maximum index value of a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 10, 1].to_tensor
a.argmax # => 1
#argmax(a : Tensor(U, ARROW(U))) : Int32 forall U
#
(a : Tensor(U, ARROW(U))) : Int32 forall U
Find the maximum index value of a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 10, 1].to_tensor
a.argmax # => 1
#argmin(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#argmin(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#argmin(a : Tensor(U, CPU(U))) : Int32 forall U
#
(a : Tensor(U, CPU(U))) : Int32 forall U
Find the minimum index value of a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [10, 1, 10].to_tensor
a.argmin # => 1
#argmin(a : Tensor(U, ARROW(U))) : Int32 forall U
#
(a : Tensor(U, ARROW(U))) : Int32 forall U
Find the minimum index value of a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [10, 1, 10].to_tensor
a.argmin # => 1
#array_split(a : Tensor(U, CPU(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U
#
(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#
- a :
Tensor(U, CPU(U))-Tensorto split` - ind :
Int- Number of sections of resultingArray - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, 2) # => [[0, 1, 2, 3, 4], [5, 6, 7, 8]]
#array_split(a : Tensor(U, CPU(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U
#
(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#
- a :
Tensor(U, CPU(U))-Tensorto split` - ind :
Int- Array of indices to use when splitting theTensor - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
#array_split(a : Tensor(U, ARROW(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U
#
(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#
- a :
Tensor(U, ARROW(U))-Tensorto split` - ind :
Int- Number of sections of resultingArray - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, 2) # => [[0, 1, 2, 3, 4], [5, 6, 7, 8]]
#array_split(a : Tensor(U, ARROW(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U
#
(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#
- a :
Tensor(U, ARROW(U))-Tensorto split` - ind :
Int- Array of indices to use when splitting theTensor - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
#as_strided(arr : Tensor(U, V), shape : Array(Int), strides : Array(Int)) : Tensor(U, V) forall U, V
#
(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#
- arr :
Tensor-Tensorto broadcast - shape :
Array(Int)- Shape of broadcastedTensor - strides :
Array(Int)- Strides of broadcastedTensor
Examples#
a = Tensor.from_array [1, 2, 3]
a.as_strided([3, 3], [0, 1])
# [[1, 2, 3],
# [1, 2, 3],
# [1, 2, 3]]
#as_tensor(value : Number, like : Tensor(U, V) | Tensor(U, V).class) forall U, V
#
(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)))
#as_type(arr : Tensor(U, CPU(U)), dtype : V.class) forall U, V
#
(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 theTensorwill 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]
#as_type(arr : Tensor(U, ARROW(U)), dtype : V.class) forall U, V
#
(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 theTensorwill 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]
#asin(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
#asin(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asin(a)
#asin(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
#asin!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
#asin!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asin!(a)
#asin!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asin(a)
#asinh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
#asinh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinh(a)
#asinh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
#asinh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
#asinh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinh!(a)
#asinh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.asinh(a)
#asinpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinpi(a)
#asinpi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.asinpi!(a)
#atan(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
#atan(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan(a)
#atan(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
#atan!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
#atan!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan!(a)
#atan!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atan(a)
#atan2(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2(a, b)
#atan2(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2(a, b)
#atan2(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.atan2(a, b)
#atan2(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#atan2(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
U- RHSNumberfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan2(a, 3_f64)
#atan2(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
U- LHSNumberfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atan2(3_f64, a)
#atan2(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2(a, b)
#atan2(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2(a, b)
#atan2(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.atan2(a, b)
#atan2!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2!(a, b)
#atan2!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2!(a, b)
#atan2!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#atan2!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.atan2!(a, b)
#atan2!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.atan2!(a, b)
#atanh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
#atanh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanh(a)
#atanh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
#atanh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
#atanh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanh!(a)
#atanh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.atanh(a)
#atanpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanpi(a)
#atanpi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.atanpi!(a)
#besselj(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj(a, b)
#besselj(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj(a, b)
#besselj(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.besselj(a, b)
#besselj(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj(a, b)
#besselj(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj(a, b)
#besselj(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.besselj(a, b)
#besselj!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj!(a, b)
#besselj!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj!(a, b)
#besselj!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.besselj!(a, b)
#besselj!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.besselj!(a, b)
#besselj0(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
#besselj0(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
#besselj0!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
#besselj0!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj0(a)
#besselj1(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
#besselj1(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
#besselj1!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
#besselj1!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.besselj1(a)
#bessely(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely(a, b)
#bessely(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely(a, b)
#bessely(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.bessely(a, b)
#bessely(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely(a, b)
#bessely(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely(a, b)
#bessely(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.bessely(a, b)
#bessely!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely!(a, b)
#bessely!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely!(a, b)
#bessely!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.bessely!(a, b)
#bessely!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.bessely!(a, b)
#bessely0(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
#bessely0(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
#bessely0!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
#bessely0!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely0(a)
#bessely1(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
#bessely1(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
#bessely1!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
#bessely1!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.bessely1(a)
#bitwise_and(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and(a, b)
#bitwise_and(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#bitwise_and(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#bitwise_and(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "&" operator - b :
Tensor(U, OCL(U))- RHS argument to the "&" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_and(a, a)
#bitwise_and(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_and(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_and(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and(a, b)
#bitwise_and(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(a, b)
#bitwise_and(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and(b, a)
#bitwise_and!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and!(a, b) # a is modified
#bitwise_and!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#bitwise_and!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_and!(a, b) # a is modified
#bitwise_and!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_and!(a, b)
#bitwise_or(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or(a, b)
#bitwise_or(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#bitwise_or(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#bitwise_or(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "|" operator - b :
Tensor(U, OCL(U))- RHS argument to the "|" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_or(a, a)
#bitwise_or(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_or(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_or(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or(a, b)
#bitwise_or(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(a, b)
#bitwise_or(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or(b, a)
#bitwise_or!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or!(a, b) # a is modified
#bitwise_or!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#bitwise_or!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_or!(a, b) # a is modified
#bitwise_or!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_or!(a, b)
#bitwise_xor(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor(a, b)
#bitwise_xor(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#bitwise_xor(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#bitwise_xor(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "^" operator - b :
Tensor(U, OCL(U))- RHS argument to the "^" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.bitwise_xor(a, a)
#bitwise_xor(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_xor(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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)
#bitwise_xor(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor(a, b)
#bitwise_xor(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(a, b)
#bitwise_xor(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor(b, a)
#bitwise_xor!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor!(a, b) # a is modified
#bitwise_xor!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#bitwise_xor!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.bitwise_xor!(a, b) # a is modified
#bitwise_xor!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.bitwise_xor!(a, b)
#broadcast(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), c : Tensor(W, CPU(W))) forall U, V, W
#
(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#
- a :
Tensor(U, CPU(U))- FirstTensorto broadcast - b :
Tensor(V, CPU(V))- SecondTensorto broadcast - c :
Tensor(W, CPU(W))- ThirdTensorto broadcast
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]
#broadcast(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), c : Tensor(W, ARROW(W))) forall U, V, W
#
(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#
- a :
Tensor(U, ARROW(U))- FirstTensorto broadcast - b :
Tensor(V, ARROW(V))- SecondTensorto broadcast - c :
Tensor(W, ARROW(W))- ThirdTensorto broadcast
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]
#broadcast(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- FirstTensorto broadcast - b :
Tensor(V, CPU(V))- SecondTensorto broadcast
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }
x, y = a.broadcast(b)
x.shape # => [3, 3]
#broadcast(a : Tensor(U, OCL(U)), b : Tensor(V, OCL(V))) forall U, V
#
(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]
#broadcast(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- FirstTensorto broadcast - b :
Tensor(V, ARROW(V))- SecondTensorto broadcast
Examples#
a = Tensor.from_array [1, 2, 3]
b = Tensor.new([3, 3]) { |i| i }
x, y = a.broadcast(b)
x.shape # => [3, 3]
#broadcast_to(arr : Tensor(U, V), shape : Array(Int)) forall U, V
#
(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#
- arr :
Tensor-Tensorto broadcast - shape :
Array(Int)- The shape of the desired outputTensor
Examples#
a = [1, 2, 3].to_tensor
a.broadcast_to([3, 3])
# [[1, 2, 3],
# [1, 2, 3],
# [1, 2, 3]]
#cbrt(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
#cbrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cbrt(a)
#cbrt(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
#cbrt!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
#cbrt!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cbrt!(a)
#cbrt!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cbrt(a)
#ceil(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.ceil(a)
#ceil!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.ceil!(a)
#concatenate(arrs : Array(Tensor(U, V)), axis : Int) forall U, V
#
(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]]]
#concatenate(*arrs : Tensor(U, V), axis : Int) forall U, V
#
(*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]]]
#copysign(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign(a, b)
#copysign(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign(a, b)
#copysign(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.copysign(a, b)
#copysign(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign(a, b)
#copysign(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign(a, b)
#copysign(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.copysign(a, b)
#copysign!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign!(a, b)
#copysign!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign!(a, b)
#copysign!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.copysign!(a, b)
#copysign!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.copysign!(a, b)
#cos(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
#cos(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cos(a)
#cos(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
#cos!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
#cos!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cos!(a)
#cos!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cos(a)
#cosh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
#cosh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cosh(a)
#cosh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
#cosh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
#cosh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cosh!(a)
#cosh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.cosh(a)
#cospi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cospi(a)
#cospi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.cospi!(a)
#cpu(arr : Tensor(U, CPU(U))) forall U
#
(arr : Tensor(U, CPU(U))) forall U
Converts a CPU Tensor to CPU. Returns the input array,
no copy is performed.
Arguments#
- arr :
Tensor(U, CPU(U))-Tensorto return
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
#cpu(arr : Tensor(U, OCL(U))) forall U
#
(arr : Tensor(U, OCL(U))) forall U
Converts a Tensor stored on an OpenCL device to a Tensor stored
on a CPU.
Arguments#
- arr :
Tensor(U, OCL(U))-Tensorto place on a CPU
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a.cpu # => [[0, 1], [2, 3]]
#cpu(arr : Tensor(U, ARROW(U))) forall U
#
(arr : Tensor(U, ARROW(U))) forall U
Converts a ARROW Tensor to CPU. Returns the input array,
no copy is performed.
Arguments#
- arr :
Tensor(U, ARROW(U))-Tensorto return
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
#diagonal(arr : Tensor(U, CPU(U))) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto view along the diagonal
Examples#
a = Tensor.new(3, 3) { |i, _| i }
a.diagonal # => [0, 1, 2]
#diagonal(arr : Tensor(U, ARROW(U))) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto view along the diagonal
Examples#
a = Tensor.new(3, 3) { |i, _| i }
a.diagonal # => [0, 1, 2]
#divide(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide(a, b)
#divide(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#divide(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#divide(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Divide two Tensors elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to divide - b :
Tensor(U, OCL(U))- RHS argument to divide
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, a)
#divide(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
Divide a Tensor and a Number elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to divide - b :
U- RHS argument to divide
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
#divide(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Divide a Number and a Tensor elementwise
Arguments#
- a :
U- LHS argument to divide - b :
Tensor(U, OCL(U))- RHS argument to divide
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
#divide(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide(a, b)
#divide(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(a, b)
#divide(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide(b, a)
#divide!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide!(a, b) # a is modified
#divide!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#divide!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to divide, will be modified inplace - b :
Tensor(U, OCL(U))- RHS argument to divide
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide!(a, a)
#divide!(a : Tensor(U, OCL(U)), b : U) : Nil forall U
#
(a : Tensor(U, OCL(U)), b : U) : Nil forall U
Divide a Tensor and a Number elementwise,
modifying the Tensor inplace.
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to divide - b :
U- RHS argument to divide
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.divide(a, 3.5)
#divide!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.divide!(a, b) # a is modified
#divide!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.divide!(a, b)
#dup(t : Tensor(U, CPU(U)), order : Num::OrderType = Num::RowMajor) forall U
#
(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#
- t :
Tensor(U, CPU(U))-Tensorto duplicate - order :
Num::OrderType- Memory layout to use for the returnedTensor
Examples#
-
a = Tensor.from_array [1, 2, 3]
a.dup # => [1, 2, 3]
#dup(t : Tensor(U, ARROW(U)), order : Num::OrderType = Num::RowMajor) forall U
#
(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#
- t :
Tensor(U, CPU(U))-Tensorto duplicate - order :
Num::OrderType- Memory layout to use for the returnedTensor
Examples#
-
a = Tensor.from_array [1, 2, 3]
a.dup # => [1, 2, 3]
#each(arr : Tensor(U, CPU(U)), &block : U -> _) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each do |el|
puts el
end
# 0
# 1
# 2
# 3
#each(arr : Tensor(U, CPU(U))) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorfrom which to create an iterator
Examples#
a = Tensor.new(2, 2) { |i| i }
iter = a.each
a.size.times do
puts iter.next.value
end
# 0
# 1
# 2
# 3
#each(arr : Tensor(U, ARROW(U)), &block : U -> _) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each do |el|
puts el
end
# 0
# 1
# 2
# 3
#each(arr : Tensor(U, ARROW(U))) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorfrom which to create an iterator
Examples#
a = Tensor.new(2, 2) { |i| i }
iter = a.each
a.size.times do
puts iter.next.value
end
# 0
# 1
# 2
# 3
#each_axis(a0 : Tensor(U, CPU(U)), axis : Int, dims : Bool = false, &block : Tensor(U, CPU(U)) -> _) forall U
#
(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))-Tensorto 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]
#each_axis(arr : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#each_axis(a0 : Tensor(U, OCL(U)), axis : Int, dims : Bool = false, &block : Tensor(U, OCL(U)) -> _) forall U
#
(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))-Tensorto 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]
#each_axis(a0 : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false, &block : Tensor(U, ARROW(U)) -> _) forall U
#
(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))-Tensorto 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]
#each_axis(arr : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#each_pointer(arr : Tensor(U, CPU(U)), &block : Pointer(U) -> _) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
puts el.value
end
# 0
# 1
# 2
# 3
#each_pointer(arr : Tensor(U, ARROW(U)), &block : Pointer(U) -> _) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
puts el.value
end
# 0
# 1
# 2
# 3
#each_pointer_with_index(arr : Tensor(U, CPU(U)), &block : Pointer(U), Int32 -> _) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
puts el.value
end
# 0
# 1
# 2
# 3
#each_pointer_with_index(arr : Tensor(U, ARROW(U)), &block : Pointer(U), Int32 -> _) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorfrom which values will be yielded
Examples#
a = Tensor.new(2, 2) { |i| i }
a.each_pointer do |el|
puts el.value
end
# 0
# 1
# 2
# 3
#each_with_index(arr : Tensor(U, CPU(U)), &block : U, Int32 -> _) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorfrom which values will be yielded
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
#each_with_index(arr : Tensor(U, ARROW(U)), &block : U, Int32 -> _) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorfrom which values will be yielded
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
#equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal(a, b)
#equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "==" operator - b :
Tensor(U, OCL(U))- RHS argument to the "==" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.equal(a, a)
#equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal(a, b)
#equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(a, b)
#equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal(b, a)
#equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal!(a, b) # a is modified
#equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.equal!(a, b) # a is modified
#equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.equal!(a, b)
#erf(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
#erf(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erf(a)
#erf(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
#erf!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
#erf!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erf!(a)
#erf!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erf(a)
#erfc(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
#erfc(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erfc(a)
#erfc(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
#erfc!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
#erfc!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.erfc!(a)
#erfc!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.erfc(a)
#exp(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
#exp(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp(a)
#exp(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
#exp!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
#exp!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp!(a)
#exp!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp(a)
#exp10(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp10(a)
#exp10!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp10!(a)
#exp2(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
#exp2(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp2(a)
#exp2(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
#exp2!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
#exp2!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.exp2!(a)
#exp2!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.exp2(a)
#expand_dims(arr : Tensor(U, V), axis : Int) : Tensor(U, V) forall U, V
#
(arr : Tensor(U, V), axis : Int) : Tensor(U, V) forall U, V
Expands a Tensor along an axis
Arguments#
Examples#
a = [1, 2, 3].to_tensor
a.expand_dims(0) # => [[1, 2, 3]]
#expm1(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
#expm1(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.expm1(a)
#expm1(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
#expm1!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
#expm1!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.expm1!(a)
#expm1!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.expm1(a)
#fabs(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fabs(a)
#fabs!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fabs!(a)
#flat(arr : Tensor(U, CPU(U))) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto flatten
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.flat # => [0, 1, 2, 3]
#flat(arr : Tensor(U, ARROW(U))) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto flatten
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.flat # => [0, 1, 2, 3]
#flip(a : Tensor(U, CPU(U)), axis : Int) forall U
#
(a : Tensor(U, CPU(U)), axis : Int) forall U
Flips a Tensor along an axis, returning a view
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto flip - axis :
Int- Axis along which to flip
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a, 1)
# [[3, 2, 1],
# [6, 5, 4]]
#flip(a : Tensor(U, ARROW(U)), axis : Int) forall U
#
(a : Tensor(U, ARROW(U)), axis : Int) forall U
Flips a Tensor along an axis, returning a view
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto flip - axis :
Int- Axis along which to flip
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a, 1)
# [[3, 2, 1],
# [6, 5, 4]]
#flip(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Flips a Tensor along all axes, returning a view
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto flip
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a)
# [[6, 5, 4],
# [3, 2, 1]]
#flip(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Flips a Tensor along all axes, returning a view
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto flip
Examples#
a = [[1, 2, 3], [4, 5, 6]]
puts Num.flip(a)
# [[6, 5, 4],
# [3, 2, 1]]
#floor(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.floor(a)
#floor!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.floor!(a)
#floordiv(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv(a, b)
#floordiv(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#floordiv(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#floordiv(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv(a, b)
#floordiv(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(a, b)
#floordiv(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv(b, a)
#floordiv!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv!(a, b) # a is modified
#floordiv!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#floordiv!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.floordiv!(a, b) # a is modified
#floordiv!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.floordiv!(a, b)
#gamma(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
#gamma(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
#gamma!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
#gamma!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.gamma(a)
#greater(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater(a, b)
#greater(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#greater(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#greater(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the ">" operator - b :
Tensor(U, OCL(U))- RHS argument to the ">" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.greater(a, a)
#greater(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#greater(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#greater(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater(a, b)
#greater(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(a, b)
#greater(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater(b, a)
#greater!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater!(a, b) # a is modified
#greater!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#greater!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater!(a, b) # a is modified
#greater!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater!(a, b)
#greater_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal(a, b)
#greater_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#greater_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#greater_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the ">=" operator - b :
Tensor(U, OCL(U))- RHS argument to the ">=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.greater_equal(a, a)
#greater_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#greater_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#greater_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal(a, b)
#greater_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(a, b)
#greater_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal(b, a)
#greater_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal!(a, b) # a is modified
#greater_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#greater_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.greater_equal!(a, b) # a is modified
#greater_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.greater_equal!(a, b)
#hstack(arrs : Array(Tensor(U, V))) forall U, V
#
(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#
- arrs :
Array(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]]
#hstack(*arrs : Tensor(U, V)) forall U, V
#
(*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]]
#hypot(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot(a, b)
#hypot(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot(a, b)
#hypot(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.hypot(a, b)
#hypot(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot(a, b)
#hypot(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot(a, b)
#hypot(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.hypot(a, b)
#hypot!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot!(a, b)
#hypot!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot!(a, b)
#hypot!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.hypot!(a, b)
#hypot!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.hypot!(a, b)
#ilogb(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
#ilogb(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
#ilogb!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
#ilogb!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.ilogb(a)
#ldexp(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp(a, b)
#ldexp(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp(a, b)
#ldexp(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.ldexp(a, b)
#ldexp(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp(a, b)
#ldexp(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp(a, b)
#ldexp(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.ldexp(a, b)
#ldexp!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp!(a, b)
#ldexp!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp!(a, b)
#ldexp!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.ldexp!(a, b)
#ldexp!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.ldexp!(a, b)
#left_shift(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift(a, b)
#left_shift(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#left_shift(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#left_shift(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "<<" operator - b :
Tensor(U, OCL(U))- RHS argument to the "<<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.left_shift(a, a)
#left_shift(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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)
#left_shift(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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)
#left_shift(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift(a, b)
#left_shift(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(a, b)
#left_shift(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift(b, a)
#left_shift!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift!(a, b) # a is modified
#left_shift!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#left_shift!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.left_shift!(a, b) # a is modified
#left_shift!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.left_shift!(a, b)
#less(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less(a, b)
#less(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#less(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#less(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "<" operator - b :
Tensor(U, OCL(U))- RHS argument to the "<" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.less(a, a)
#less(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#less(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#less(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less(a, b)
#less(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(a, b)
#less(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less(b, a)
#less!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less!(a, b) # a is modified
#less!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#less!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less!(a, b) # a is modified
#less!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less!(a, b)
#less_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal(a, b)
#less_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#less_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#less_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "<=" operator - b :
Tensor(U, OCL(U))- RHS argument to the "<=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.less_equal(a, a)
#less_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#less_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#less_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal(a, b)
#less_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(a, b)
#less_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal(b, a)
#less_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal!(a, b) # a is modified
#less_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#less_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.less_equal!(a, b) # a is modified
#less_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.less_equal!(a, b)
#lgamma(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
#lgamma(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.lgamma(a)
#lgamma(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
#lgamma!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
#lgamma!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.lgamma!(a)
#lgamma!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.lgamma(a)
#log(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
#log(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log(a)
#log(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
#log!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
#log!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log!(a)
#log!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log(a)
#log10(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
#log10(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log10(a)
#log10(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
#log10!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
#log10!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log10!(a)
#log10!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log10(a)
#log1p(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
#log1p(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log1p(a)
#log1p(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
#log1p!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
#log1p!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log1p!(a)
#log1p!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log1p(a)
#log2(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
#log2(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log2(a)
#log2(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
#log2!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
#log2!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.log2!(a)
#log2!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.log2(a)
#logb(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
#logb(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.logb(a)
#logb(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
#logb!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
#logb!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.logb!(a)
#logb!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.logb(a)
#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
#
(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))- FirstTensorfor iteration, must be broadcastable against the shape of a1 and a2 - a1 :
Tensor(V, CPU(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 and a2 - a2 :
Tensor(W, CPU(W))- ThirdTensorfor iteration, must be broadcastable against the shape of a0 and a1 - block :
Proc(T, U, V)- The block to map across bothTensors
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]
#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
#
(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#
- a0 :
Tensor(U, ARROW(U))- FirstTensorfor iteration, must be broadcastable against the shape of a1 and a2 - a1 :
Tensor(V, ARROW(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 and a2 - a2 :
Tensor(W, ARROW(W))- ThirdTensorfor iteration, must be broadcastable against the shape of a0 and a1 - block :
Proc(T, U, V)- The block to map across bothTensors
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]
#map(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), &block : U, V -> W) forall U, V, W
#
(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))- FirstTensorfor iteration, must be broadcastable against the shape of a1 - a1 :
Tensor(V, CPU(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
a.map(b) { |i, j| i + j } # => [0, 2, 4]
#map(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), &block : U, V -> W) forall U, V, W
#
(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#
- a0 :
Tensor(U, ARROW(U))- FirstTensorfor iteration, must be broadcastable against the shape of a1 - a1 :
Tensor(V, ARROW(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
a.map(b) { |i, j| i + j } # => [0, 2, 4]
#map(arr : Tensor(U, CPU(U)), &block : U -> V) : Tensor(V, CPU(V)) forall U, V
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto map theProcacross - block :
Proc(T, U)- Proc to map across theTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.map { |e| e + 5 } # => [5, 6, 7]
#map(arr : Tensor(U, ARROW(U)), &block : U -> V) : Tensor(V, ARROW(V)) forall U, V
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto map theProcacross - block :
Proc(T, U)- Proc to map across theTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.map { |e| e + 5 } # => [5, 6, 7]
#map!(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), a2 : Tensor(W, CPU(W)), &) forall U, V, W
#
(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#
- a0 :
Tensor(U, CPU(U))- FirstTensorfor iteration - a1 :
Tensor(V, CPU(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - a2 :
Tensor(W, CPU(W))- ThirdTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
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]
#map!(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), a2 : Tensor(W, ARROW(W)), &) forall U, V, W
#
(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#
- a0 :
Tensor(U, ARROW(U))- FirstTensorfor iteration - a1 :
Tensor(V, ARROW(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - a2 :
Tensor(W, ARROW(W))- ThirdTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
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]
#map!(a0 : Tensor(U, CPU(U)), a1 : Tensor(V, CPU(V)), &block : U, V -> _) forall U, V
#
(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#
- a0 :
Tensor(U, CPU(U))- FirstTensorfor iteration - a1 :
Tensor(V, CPU(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
a.map!(b) { |i, j| i + j }
a # => [0, 2, 4]
#map!(a0 : Tensor(U, ARROW(U)), a1 : Tensor(V, ARROW(V)), &block : U, V -> _) forall U, V
#
(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#
- a0 :
Tensor(U, ARROW(U))- FirstTensorfor iteration - a1 :
Tensor(V, ARROW(V))- SecondTensorfor iteration, must be broadcastable against the shape of a0 - block :
Proc(T, U, V)- The block to map across bothTensors
Examples#
a = Tensor.new([3]) { |i| i }
b = Tensor.new([3]) { |i| i }
a.map!(b) { |i, j| i + j }
a # => [0, 2, 4]
#map!(arr : Tensor(U, CPU(U)), &block : U -> _) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto map theProcacross - block :
Proc(T, U)- Proc to map across theTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.map! { |e| e + 5 }
a # => [5, 6, 7]
#map!(arr : Tensor(U, ARROW(U)), &block : U -> _) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto map theProcacross - block :
Proc(T, U)- Proc to map across theTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.map! { |e| e + 5 }
a # => [5, 6, 7]
#max(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max(a, b)
#max(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#max(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max(a, b)
#max(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.max(a, b)
#max(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#max(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
U- RHSNumberfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmax(a, 3_f64)
#max(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
U- LHSNumberfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmax(3_f64, a)
#max(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max(a, b)
#max(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#max(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max(a, b)
#max(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.max(a, b)
#max(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by finding the maximum value
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.max(a) # => 3
#max(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by finding the maximum value
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.max(a) # => 3
#max!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max!(a, b)
#max!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max!(a, b)
#max!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#max!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.max!(a, b)
#max!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.max!(a, b)
#mean(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#mean(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#mean(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by finding the average
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.mean(a) # => 2.0
#mean(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by finding the average
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.mean(a) # => 2.0
#min(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min(a, b)
#min(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#min(a : Tensor(U, CPU(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min(a, b)
#min(a : Number, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, CPU(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.min(a, b)
#min(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#min(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
U- RHSNumberfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmin(a, 3_f64)
#min(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
U- LHSNumberfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.fmin(3_f64, a)
#min(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min(a, b)
#min(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#min(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min(a, b)
#min(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS argument to the method - b :
Tensor(U, ARROW(U))- LHS argument to the method
Examples#
a = 1.5
b = [2.0, 3.65, 3.141].to_tensor
Num.min(a, b)
#min(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by finding the minimum value
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.min(a) # => 3
#min(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by finding the minimum value
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.min(a) # => 3
#min!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Tensor(V, CPU(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min!(a, b)
#min!(a : Tensor(U, CPU(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min!(a, b)
#min!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#min!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Tensor(V, ARROW(V))- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = [1.45, 3.2, 1.18]
Num.min!(a, b)
#min!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS argument to the method - b :
Number- RHS argument to the method
Examples#
a = [2.0, 3.65, 3.141].to_tensor
b = 1.5
Num.min!(a, b)
#modulo(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo(a, b)
#modulo(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#modulo(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#modulo(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo(a, b)
#modulo(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(a, b)
#modulo(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo(b, a)
#modulo!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo!(a, b) # a is modified
#modulo!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#modulo!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.modulo!(a, b) # a is modified
#modulo!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.modulo!(a, b)
#move_axis(arr : Tensor(U, CPU(U)), source : Array(Int), destination : Array(Int)) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto permute - source :
Array(Int)- Original positions of axes - destination :
Array(Int)- Destination positions of axes
Examples#
a = Tensor(Int8, CPU(Int8)).new([3, 4, 5])
Num.moveaxis(a, [0], [-1]).shape # => 4, 5, 3
#move_axis(arr : Tensor(U, CPU(U)), source : Int, destination : Int) forall U
#
(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))-Tensorto 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
#move_axis(arr : Tensor(U, ARROW(U)), source : Array(Int), destination : Array(Int)) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto permute - source :
Array(Int)- Original positions of axes - destination :
Array(Int)- Destination positions of axes
Examples#
a = Tensor(Int8, ARROW(Int8)).new([3, 4, 5])
Num.moveaxis(a, [0], [-1]).shape # => 4, 5, 3
#move_axis(arr : Tensor(U, ARROW(U)), source : Int, destination : Int) forall U
#
(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))-Tensorto 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
#multiply(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply(a, b)
#multiply(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#multiply(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#multiply(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Multiply two Tensors elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to multiply - b :
Tensor(U, OCL(U))- RHS argument to multiply
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, a)
#multiply(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
Multiply a Tensor and a Number elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to multiply - b :
U- RHS argument to multiply
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
#multiply(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Multiply a Number and a Tensor elementwise
Arguments#
- a :
U- LHS argument to multiply - b :
Tensor(U, OCL(U))- RHS argument to multiply
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
#multiply(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply(a, b)
#multiply(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(a, b)
#multiply(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply(b, a)
#multiply!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply!(a, b) # a is modified
#multiply!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#multiply!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to multiply, will be modified inplace - b :
Tensor(U, OCL(U))- RHS argument to multiply
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply!(a, a)
#multiply!(a : Tensor(U, OCL(U)), b : U) : Nil forall U
#
(a : Tensor(U, OCL(U)), b : U) : Nil forall U
Multiply a Tensor and a Number elementwise,
modifying the Tensor inplace.
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to multiply - b :
U- RHS argument to multiply
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.multiply(a, 3.5)
#multiply!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.multiply!(a, b) # a is modified
#multiply!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.multiply!(a, b)
#negate(a : Tensor(U, CPU(U))) : Tensor(U, CPU(U)) forall U
#
(a : Tensor(U, CPU(U))) : Tensor(U, CPU(U)) forall U
Implements the negation operator on a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto negate
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
#negate(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Implements the negation operator on a Tensor
Arguments#
- a :
Tensor(U, OCL(U))-Tensorto negate
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
#negate(a : Tensor(U, ARROW(U))) : Tensor(U, ARROW(U)) forall U
#
(a : Tensor(U, ARROW(U))) : Tensor(U, ARROW(U)) forall U
Implements the negation operator on a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto negate
Examples#
a = [1, 2, 3].to_tensor
Num.negate(a) # => [-1, -2, -3]
#not_equal(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal(a, b)
#not_equal(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#not_equal(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#not_equal(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the "!=" operator - b :
Tensor(U, OCL(U))- RHS argument to the "!=" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.not_equal(a, a)
#not_equal(a : Tensor(U, OCL(U)), b : U) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#not_equal(a : U, b : Tensor(U, OCL(U))) : Tensor(Int32, OCL(Int32)) forall U
#
(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)
#not_equal(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal(a, b)
#not_equal(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(a, b)
#not_equal(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal(b, a)
#not_equal!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal!(a, b) # a is modified
#not_equal!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#not_equal!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.not_equal!(a, b) # a is modified
#not_equal!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.not_equal!(a, b)
#opencl(arr : Tensor(U, CPU(U))) : Tensor(U, OCL(U)) forall U
#
(arr : Tensor(U, CPU(U))) : Tensor(U, OCL(U)) forall U
Places a Tensor stored on a CPU onto an OpenCL Device.
Arguments#
- arr :
Tensor(U, CPU(U))-Tensorto place on OpenCL device.
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
#opencl(arr : Tensor(U, ARROW(U))) : Tensor(U, OCL(U)) forall U
#
(arr : Tensor(U, ARROW(U))) : Tensor(U, OCL(U)) forall U
Places a Tensor stored on a ARROW onto an OpenCL Device.
Arguments#
- arr :
Tensor(U, ARROW(U))-Tensorto place on OpenCL device.
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.opencl # => "<4> on OpenCL Backend"
#power(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power(a, b)
#power(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#power(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#power(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#power(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
U- RHSNumberfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.pow(a, 3_f64)
#power(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
U- LHSNumberfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.pow(3_f64, a)
#power(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power(a, b)
#power(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(a, b)
#power(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power(b, a)
#power!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power!(a, b) # a is modified
#power!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#power!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHSTensorfor the operation - b :
Tensor(U, OCL(U))- RHSTensorfor the operation
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)
#power!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.power!(a, b) # a is modified
#power!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.power!(a, b)
#prod(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#prod(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#prod(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by multiplying all of its
elements
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.prod(a) # => 6
#prod(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by multiplying all of its
elements
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.prod(a) # => 6
#ptp(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#ptp(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]
#ptp(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Finds the difference between the maximum and minimum
elements of a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.ptp(a) # => 2
#ptp(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Finds the difference between the maximum and minimum
elements of a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.ptp(a) # => 2
#reduce_axis(a0 : Tensor(U, CPU(U)), axis : Int, dims : Bool = false, &block : U, U -> _) forall U
#
(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))-Tensorto 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, _)-Procto apply to values along an axis
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.reduce_axis(0) { |i, j| i + j } # => [2, 4]
#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
#
(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))-Tensorto 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)), _)-Procto 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"
#reduce_axis(a0 : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false, &block : U, U -> _) forall U
#
(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))-Tensorto 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, _)-Procto apply to values along an axis
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.reduce_axis(0) { |i, j| i + j } # => [2, 4]
#repeat(a : Tensor(U, CPU(U)), n : Int, axis : Int) forall U
#
(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))-Tensorto 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]]
#repeat(a : Tensor(U, ARROW(U)), n : Int, axis : Int) forall U
#
(a : Tensor(U, ARROW(U)), n : Int, axis : Int) forall U
Repeat elements of a Tensor along an axis
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto 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]]
#repeat(a : Tensor(U, CPU(U)), n : Int) forall U
#
(a : Tensor(U, CPU(U)), n : Int) forall U
Repeat elements of a Tensor, treating the Tensor
as flat
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto repeat - n :
Int- Number of times to repeat
Examples#
a = [1, 2, 3]
Num.repeat(a, 2) # => [1, 1, 2, 2, 3, 3]
#repeat(a : Tensor(U, ARROW(U)), n : Int) forall U
#
(a : Tensor(U, ARROW(U)), n : Int) forall U
Repeat elements of a Tensor, treating the Tensor
as flat
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto repeat - n :
Int- Number of times to repeat
Examples#
a = [1, 2, 3]
Num.repeat(a, 2) # => [1, 1, 2, 2, 3, 3]
#reshape(arr : Tensor(U, CPU(U)), shape : Array(Int)) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto reshape - shape :
Array(Int)- New shape for theTensor
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])
# [[1, 2],
# [3, 4]]
#reshape(arr : Tensor(U, ARROW(U)), shape : Array(Int)) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto reshape - shape :
Array(Int)- New shape for theTensor
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])
# [[1, 2],
# [3, 4]]
#reshape(arr : Tensor(U, CPU(U)), *shape : Int) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto reshape - shape :
Array(Int)- New shape for theTensor
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])
# [[1, 2],
# [3, 4]]
#reshape(arr : Tensor(U, ARROW(U)), *shape : Int) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto reshape - shape :
Array(Int)- New shape for theTensor
Examples#
a = Tensor.from_array [1, 2, 3, 4]
a.reshape([2, 2])
# [[1, 2],
# [3, 4]]
#right_shift(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift(a, b)
#right_shift(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#right_shift(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#right_shift(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to the ">>" operator - b :
Tensor(U, OCL(U))- RHS argument to the ">>" operator
Examples#
a = [12, 3, 5].to_tensor(OCL)
b = [1, 8, 5.to_tensor(OCL)
Num.right_shift(a, a)
#right_shift(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(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)
#right_shift(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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)
#right_shift(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift(a, b)
#right_shift(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(a, b)
#right_shift(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift(b, a)
#right_shift!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift!(a, b) # a is modified
#right_shift!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#right_shift!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.right_shift!(a, b) # a is modified
#right_shift!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.right_shift!(a, b)
#rint(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rint(a)
#rint!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rint!(a)
#round(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.round(a)
#round!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.round!(a)
#rsqrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rsqrt(a)
#rsqrt!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.rsqrt!(a)
#set(arr : Tensor(U, CPU(U)), args : Array, t : Tensor(V, CPU(V))) forall U, V
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto which values will be assigned - args :
Array- Array of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor(V, CPU(V))- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, CPU(U)), args : Array, t : V) forall U, V
#
(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))-Tensorto which values will be assigned - args :
Array- Tuple of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
V- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, OCL(U)), args : Array, t : Tensor(U, OCL(U))) forall U
#
(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#
- arr :
Tensor(U, OCL(U))-Tensorto which values will be assigned - args :
Array- Array of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor(U, OCL(U))- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, OCL(U)), args : Array, t : U) forall U
#
(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))-Tensorto which values will be assigned - args :
Array- Array of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
U- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, ARROW(U)), args : Array, t : Tensor(V, ARROW(V))) forall U, V
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto which values will be assigned - args :
Array- Array of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor(V, ARROW(V))- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, ARROW(U)), args : Array, t : V) forall U, V
#
(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))-Tensorto which values will be assigned - args :
Array- Tuple of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
V- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, CPU(U)), *args, value) forall U
#
(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))-Tensorto which values will be assigned - args :
Tuple- Tuple of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor | Number- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, OCL(U)), *args, value) forall U
#
(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))-Tensorto which values will be assigned - args :
Tuple- Tuple of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor | Number- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a[1.., 1..] = 99
a.cpu
# [[ 0, 1],
# [ 2, 99]]
#set(arr : Tensor(U, ARROW(U)), *args, value) forall U
#
(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))-Tensorto which values will be assigned - args :
Tuple- Tuple of arguments. All arguments must be valid indexers, so aRange,Int, orTuple(Range, Int). - value :
Tensor | Number- Argument to assign to theTensor
Examples#
a = Tensor.new([2, 2]) { |i| i }
a[1.., 1..] = 99
a
# [[ 0, 1],
# [ 2, 99]]
#sin(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
#sin(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sin(a)
#sin(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
#sin!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
#sin!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sin!(a)
#sin!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sin(a)
#sinh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
#sinh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinh(a)
#sinh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
#sinh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
#sinh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinh!(a)
#sinh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sinh(a)
#sinpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinpi(a)
#sinpi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sinpi!(a)
#slice(arr : Tensor(U, V), args : Array) forall U, V
#
(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]]
#slice(arr : Tensor(U, V), *args) forall U, V
#
(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]]
#sort(a : Tensor(U, CPU(U)), axis : Int) forall U
#
(a : Tensor(U, CPU(U)), axis : Int) forall U
Sorts a Tensor along an axis.
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto sort - axis :
Int- Axis along which to sort
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]]]
#sort(a : Tensor(U, ARROW(U)), axis : Int) forall U
#
(a : Tensor(U, ARROW(U)), axis : Int) forall U
Sorts a Tensor along an axis.
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto sort - axis :
Int- Axis along which to sort
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]]]
#sort(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Sorts a Tensor, treating it's elements like the Tensor
is flat.
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto sort
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
#sort(a : Tensor(U, CPU(U)), axis : Int, &block : U, U -> _) forall U
#
(a : Tensor(U, CPU(U)), axis : Int, &block : U, U -> _) forall U
Sorts a Tensor along an axis.
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto sort - axis :
Int- Axis along which to sort - block :
Proc(U, U, _)-Procto 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]]]
#sort(a : Tensor(U, ARROW(U)), axis : Int, &block : U, U -> _) forall U
#
(a : Tensor(U, ARROW(U)), axis : Int, &block : U, U -> _) forall U
Sorts a Tensor along an axis.
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto sort - axis :
Int- Axis along which to sort - block :
Proc(U, U, _)-Procto 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]]]
#sort(a : Tensor(U, CPU(U)), &block : U, U -> _) forall U
#
(a : Tensor(U, CPU(U)), &block : U, U -> _) forall U
Sorts a Tensor, treating it's elements like the Tensor
is flat.
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto sort - block :
Proc(U, U, _)-Procto use to compare values
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
#sort(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Sorts a Tensor, treating it's elements like the Tensor
is flat.
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto sort
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
#sort(a : Tensor(U, ARROW(U)), &block : U, U -> _) forall U
#
(a : Tensor(U, ARROW(U)), &block : U, U -> _) forall U
Sorts a Tensor, treating it's elements like the Tensor
is flat.
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto sort - block :
Proc(U, U, _)-Procto use to compare values
Examples#
a = [3, 2, 1].to_tensor
Num.sort(a) # => [1, 2, 3]
#split(a : Tensor(U, CPU(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U
#
(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#
- a :
Tensor(U, CPU(U))-Tensorto split` - ind :
Int- Number of sections of resultingArray - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(1, 9)
puts Num.array_split(a, 2) # => [[1, 2, 3, 4], [5, 6, 7, 8]]
#split(a : Tensor(U, CPU(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, CPU(U))) forall U
#
(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#
- a :
Tensor(U, CPU(U))-Tensorto split` - ind :
Int- Array of indices to use when splitting theTensor - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
#split(a : Tensor(U, ARROW(U)), ind : Int, axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U
#
(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#
- a :
Tensor(U, ARROW(U))-Tensorto split` - ind :
Int- Number of sections of resultingArray - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(1, 9)
puts Num.array_split(a, 2) # => [[1, 2, 3, 4], [5, 6, 7, 8]]
#split(a : Tensor(U, ARROW(U)), ind : Array(Int), axis : Int = 0) : Array(Tensor(U, ARROW(U))) forall U
#
(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#
- a :
Tensor(U, ARROW(U))-Tensorto split` - ind :
Int- Array of indices to use when splitting theTensor - axis :
Int- Axis along which to split
Examples#
a = Tensor.range(9)
puts Num.array_split(a, [1, 3, 5]) # => [[0], [1, 2], [3, 4], [5, 6, 7, 8]]
#sqrt(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
#sqrt(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sqrt(a)
#sqrt(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
#sqrt!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
#sqrt!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.sqrt!(a)
#sqrt!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.sqrt(a)
#std(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#std(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#std(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by finding the standard deviation
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.std(a) # => 0.816496580927726
#std(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by finding the standard deviation
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.std(a) # => 0.816496580927726
#subtract(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract(a, b)
#subtract(a : Tensor(U, CPU(U)), b : Number | Complex) : Tensor forall U
#
(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)
#subtract(a : Number | Complex, b : Tensor(U, CPU(U))) : Tensor forall U
#
(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)
#subtract(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Subtract two Tensors elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to subtract - b :
Tensor(U, OCL(U))- RHS argument to subtract
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, a)
#subtract(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
#
(a : Tensor(U, OCL(U)), b : U) : Tensor(U, OCL(U)) forall U
Subtract a Tensor and a Number elementwise
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to subtract - b :
U- RHS argument to subtract
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
#subtract(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(a : U, b : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
Subtract a Number and a Tensor elementwise
Arguments#
- a :
U- LHS argument to subtract - b :
Tensor(U, OCL(U))- RHS argument to subtract
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
#subtract(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Tensor forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract(a, b)
#subtract(a : Tensor(U, ARROW(U)), b : Number) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(a, b)
#subtract(a : Number, b : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Number- RHS to the operation - b :
Tensor(U, ARROW(U))- LHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract(b, a)
#subtract!(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- LHS to the operation - b :
Tensor(U, CPU(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract!(a, b) # a is modified
#subtract!(a : Tensor(U, CPU(U)), b : Number | Complex) : Nil forall U
#
(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)
#subtract!(a : Tensor(U, OCL(U)), b : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))- LHS argument to subtract, will be modified inplace - b :
Tensor(U, OCL(U))- RHS argument to subtract
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract!(a, a)
#subtract!(a : Tensor(U, OCL(U)), b : U) : Nil forall U
#
(a : Tensor(U, OCL(U)), b : U) : Nil forall U
Subtract a Tensor and a Number elementwise,
modifying the Tensor inplace.
Arguments#
- a :
Tensor(U, OCL(U))- LHS argument to subtract - b :
U- RHS argument to subtract
Examples#
a = [1.5, 2.2, 3.2].to_tensor(OCL)
Num.subtract(a, 3.5)
#subtract!(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V))) : Nil forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Tensor(U, ARROW(U))- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = [4, 5, 6].to_tensor
Num.subtract!(a, b) # a is modified
#subtract!(a : Tensor(U, ARROW(U)), b : Number) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- LHS to the operation - b :
Number- RHS to the operation
Examples#
a = [1, 2, 3].to_tensor
b = 4
Num.subtract!(a, b)
#sum(a : Tensor(U, CPU(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#sum(a : Tensor(U, OCL(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#sum(a : Tensor(U, ARROW(U)), axis : Int, dims : Bool = false) forall U
#
(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))-Tensorto 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]]
#sum(a : Tensor(U, CPU(U))) forall U
#
(a : Tensor(U, CPU(U))) forall U
Reduces a Tensor to a scalar by summing all of its
elements
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.sum(a) # => 6
#sum(a : Tensor(U, ARROW(U))) forall U
#
(a : Tensor(U, ARROW(U))) forall U
Reduces a Tensor to a scalar by summing all of its
elements
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto reduce
Examples#
a = [1, 2, 3]
Num.sum(a) # => 6
#swap_axes(arr : Tensor(U, CPU(U)), a : Int, b : Int) forall U
#
(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))-Tensorto 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]]]
#swap_axes(arr : Tensor(U, ARROW(U)), a : Int, b : Int) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto 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]]]
#tan(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
#tan(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tan(a)
#tan(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
#tan!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
#tan!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tan!(a)
#tan!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tan(a)
#tanh(a : Tensor(U, CPU(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
#tanh(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanh(a)
#tanh(a : Tensor(U, ARROW(U))) : Tensor forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
#tanh!(a : Tensor(U, CPU(U))) : Nil forall U
#
(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#
- a :
Tensor(U, CPU(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
#tanh!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanh!(a)
#tanh!(a : Tensor(U, ARROW(U))) : Nil forall U
#
(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#
- a :
Tensor(U, ARROW(U))- Argument to be operated upon
Examples#
a = [2.0, 3.65, 3.141].to_tensor
Num.tanh(a)
#tanpi(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanpi(a)
#tanpi!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tanpi!(a)
#tgamma(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tgamma(a)
#tgamma!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.tgamma!(a)
#tile(a : Tensor(U, CPU(U)), n : Int) forall U
#
(a : Tensor(U, CPU(U)), n : Int) forall U
Tile elements of a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto repeat - n :
Int- Number of times to tile
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]]
#tile(a : Tensor(U, CPU(U)), n : Array(Int)) forall U
#
(a : Tensor(U, CPU(U)), n : Array(Int)) forall U
Tile elements of a Tensor
Arguments#
- a :
Tensor(U, CPU(U))-Tensorto repeat - n :
Array(Int)- Number of times to repeat
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]]
#tile(a : Tensor(U, ARROW(U)), n : Int) forall U
#
(a : Tensor(U, ARROW(U)), n : Int) forall U
Tile elements of a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto repeat - n :
Int- Number of times to tile
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]]
#tile(a : Tensor(U, ARROW(U)), n : Array(Int)) forall U
#
(a : Tensor(U, ARROW(U)), n : Array(Int)) forall U
Tile elements of a Tensor
Arguments#
- a :
Tensor(U, ARROW(U))-Tensorto repeat - n :
Array(Int)- Number of times to repeat
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]]
#to_a(arr : Tensor(U, CPU(U))) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto convert to anArray
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.to_a # => [0, 1, 2, 3]
#to_a(arr : Tensor(U, OCL(U))) forall U
#
(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#
- arr :
Tensor(U, OCL(U))-Tensorto convert to a stdlib array
Examples#
a = Tensor.new([2, 2], device: OCL) { |i| i }
a.to_a # => [0, 1, 2, 3]
#to_a(arr : Tensor(U, ARROW(U))) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto convert to anArray
Examples#
a = Tensor.new([2, 2]) { |i| i }
a.to_a # => [0, 1, 2, 3]
#transpose(arr : Tensor(U, CPU(U)), axes : Array(Int) = [] of Int32) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto permute - axes :
Array(Int)- Order of axes to permute
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]]]
#transpose(arr : Tensor(U, OCL(U)), axes : Array(Int) = [] of Int32) forall U
#
(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]]]
#transpose(arr : Tensor(U, ARROW(U)), axes : Array(Int) = [] of Int32) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto permute - axes :
Array(Int)- Order of axes to permute
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]]]
#transpose(arr : Tensor(U, CPU(U)), *args : Int) forall U
#
(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#
- arr :
Tensor(U, CPU(U))-Tensorto permute - axes :
Array(Int)- Order of axes to permute
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]]]
#transpose(arr : Tensor(U, OCL(U)), *args : Int) forall U
#
(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]]]
#transpose(arr : Tensor(U, ARROW(U)), *args : Int) forall U
#
(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#
- arr :
Tensor(U, ARROW(U))-Tensorto permute - axes :
Array(Int)- Order of axes to permute
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]]]
#trunc(a : Tensor(U, OCL(U))) : Tensor(U, OCL(U)) forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.trunc(a)
#trunc!(a : Tensor(U, OCL(U))) : Nil forall U
#
(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#
- a :
Tensor(U, OCL(U))-Tensoron which to operate
Examples#
a = [0.45, 0.3, 2.4].to_tensor(OCL)
Num.trunc!(a)
#view(arr : Tensor(U, CPU(U)), dtype : V.class) forall U, V
#
(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))-Tensorto view as a different data type - u :
V.class- The data type used to reintepret the underlying data buffer of aTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.view(Int8) # => [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0]
#view(arr : Tensor(U, ARROW(U)), dtype : V.class) forall U, V
#
(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))-Tensorto view as a different data type - u :
V.class- The data type used to reintepret the underlying data buffer of aTensor
Examples#
a = Tensor.new([3]) { |i| i }
a.view(Int8) # => [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0]
#vstack(arrs : Array(Tensor(U, V))) forall U, V
#
(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#
- arrs :
Array(Tensor)-Tensors to concatenate
Examples#
a = [1, 2, 3].to_tensor
Num.vstack([a, a])
# [[1, 2, 3],
# [1, 2, 3]]
#vstack(*arrs : Tensor(U, V)) forall U, V
#
(*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]]
#with_broadcast(arr : Tensor(U, V), n : Int) : Tensor(U, V) forall U, V
#
(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#
Examples#
a = [1, 2, 3].to_tensor
a.with_broadcast(2)
# [[[1]],
#
# [[2]],
#
# [[3]]]
#yield_along_axis(a0 : Tensor(U, CPU(U)), axis : Int, &) forall U
#
(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#
- a0 :
Tensor(U, CPU(U))-Tensoralong which to iterate - axis :
Int- Axis of reduction
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]
#yield_along_axis(a0 : Tensor(U, ARROW(U)), axis : Int, &) forall U
#
(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#
- a0 :
Tensor(U, ARROW(U))-Tensoralong which to iterate - axis :
Int- Axis of reduction
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]
#zip(a : Tensor(U, CPU(U)), b : Tensor(V, CPU(V)), &block : U, V -> _) forall U, V
#
(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#
- a :
Tensor(U, CPU(U))- FirstTensorof iteration - b :
Tensor(U, CPU(U))- SecondTensorof iteration
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}
#zip(a : Tensor(U, ARROW(U)), b : Tensor(V, ARROW(V)), &block : U, V -> _) forall U, V
#
(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#
- a :
Tensor(U, ARROW(U))- FirstTensorof iteration - b :
Tensor(U, ARROW(U))- SecondTensorof iteration
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}