Module: CAMath
- Includes:
- Math
- Defined in:
- lib/carray.rb,
lib/carray/math.rb,
ext/carray_operator.c
Overview
Top-level CAMath module -- math namespace for CArrays.
CAMath.sin(ca) works because module functions inherited
from Math (via include) accept any object that responds to
the corresponding instance method; CArray defines those in
C.
Class Method Summary collapse
-
.atan2(y, x) ⇒ CArray
Returns the element-wise arc tangent of
y / xwith quadrant selection. -
.copysign(x, y) ⇒ CArray
Returns
|x|with the sign ofy, element-wise. -
.expm1(x) ⇒ CArray
Returns
exp(x) - 1element-wise as float64. -
.fmod(x, y) ⇒ CArray
Returns the C-style
fmod(x, y)element-wise (sign followsx). -
.hypot(x, y) ⇒ CArray
Returns the element-wise Euclidean distance
sqrt(x^2 + y^2). -
.log1p(x) ⇒ CArray
Returns
log(1 + x)element-wise as float64. -
.logaddexp(x, y) ⇒ CArray
Returns
log(exp(x) + exp(y))computed to avoid overflow, element-wise. -
.max(*argv) ⇒ CArray
Returns the element-wise maximum of the given CArray and other arguments.
-
.min(*argv) ⇒ CArray
Returns the element-wise minimum of the given CArray and other arguments.
-
.nextafter(x, y) ⇒ CArray
Returns the next representable float from
xtowardy, element-wise.
Class Method Details
.atan2(y, x) ⇒ CArray
30 |
# File 'lib/carray/math.rb', line 30 def atan2(y, x); CArray.wrap_readonly(y, :float64).atan2(x); end |
.copysign(x, y) ⇒ CArray
44 |
# File 'lib/carray/math.rb', line 44 def copysign(x, y); CArray.wrap_readonly(x, :float64).copysign(y); end |
.expm1(x) ⇒ CArray
16 |
# File 'lib/carray/math.rb', line 16 def expm1(x); CArray.wrap_readonly(x, :float64).expm1; end |
.fmod(x, y) ⇒ CArray
67 |
# File 'lib/carray/math.rb', line 67 def fmod(x, y); CArray.wrap_readonly(x, :float64).fmod(y); end |
.hypot(x, y) ⇒ CArray
37 |
# File 'lib/carray/math.rb', line 37 def hypot(x, y); CArray.wrap_readonly(x, :float64).hypot(y); end |
.log1p(x) ⇒ CArray
22 |
# File 'lib/carray/math.rb', line 22 def log1p(x); CArray.wrap_readonly(x, :float64).log1p; end |
.logaddexp(x, y) ⇒ CArray
52 |
# File 'lib/carray/math.rb', line 52 def logaddexp(x, y); CArray.wrap_readonly(x, :float64).logaddexp(y); end |
.max(*argv) ⇒ CArray
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/carray/math.rb', line 94 def max (*argv) if ary = argv.find{|x| x.is_a?(CArray) } out = ary.copy argv.delete(ary) argv.each do |x| out.pmax!(x) end else raise "args should contain more than one CArray object" end return out end |