Module: NumRu::NMath
- Defined in:
- lib/numru/narray_ext.rb
Constant Summary collapse
- PI =
Math::PI
- E =
Math::E
Class Method Summary collapse
- .acot(x) ⇒ Object
- .acoth(x) ⇒ Object
- .acsc(x) ⇒ Object
- .acsch(x) ⇒ Object
- .asec(x) ⇒ Object
- .asech(x) ⇒ Object
- .cot(x) ⇒ Object
- .coth(x) ⇒ Object
-
.covariance(x, y, *ranks) ⇒ Object
Statistics.
-
.csc(x) ⇒ Object
Trigonometric function.
- .csch(x) ⇒ Object
- .recip(x) ⇒ Object
- .sec(x) ⇒ Object
- .sech(x) ⇒ Object
Class Method Details
.acot(x) ⇒ Object
326 327 328 |
# File 'lib/numru/narray_ext.rb', line 326 def acot x atan(1/x.to_f) end |
.acoth(x) ⇒ Object
329 330 331 |
# File 'lib/numru/narray_ext.rb', line 329 def acoth x atanh(1/x.to_f) end |
.acsc(x) ⇒ Object
300 301 302 |
# File 'lib/numru/narray_ext.rb', line 300 def acsc x asin(1/x.to_f) end |
.acsch(x) ⇒ Object
303 304 305 |
# File 'lib/numru/narray_ext.rb', line 303 def acsch x asinh(1/x.to_f) end |
.asec(x) ⇒ Object
313 314 315 |
# File 'lib/numru/narray_ext.rb', line 313 def asec x acos(1/x.to_f) end |
.asech(x) ⇒ Object
316 317 318 |
# File 'lib/numru/narray_ext.rb', line 316 def asech x acosh(1/x.to_f) end |
.cot(x) ⇒ Object
320 321 322 |
# File 'lib/numru/narray_ext.rb', line 320 def cot x 1/tan(x) end |
.coth(x) ⇒ Object
323 324 325 |
# File 'lib/numru/narray_ext.rb', line 323 def coth x 1/tanh(x) end |
.covariance(x, y, *ranks) ⇒ Object
Statistics
334 335 336 337 338 339 340 341 342 343 |
# File 'lib/numru/narray_ext.rb', line 334 def covariance(x,y,*ranks) x = NumRu::NArray.to_na(x) unless x.kind_of?(NumRu::NArray) x = x.to_type(NumRu::NArray::DFLOAT) if x.integer? y = NumRu::NArray.to_na(y) unless y.kind_of?(NumRu::NArray) y = y.to_type(NumRu::NArray::DFLOAT) if y.integer? n = x.rank_total(*ranks) xm = x.accum(*ranks).div!(n) ym = y.accum(*ranks).div!(n) ((x-xm)*(y-ym)).sum(*ranks) / (n-1) end |
.csc(x) ⇒ Object
Trigonometric function
294 295 296 |
# File 'lib/numru/narray_ext.rb', line 294 def csc x 1/sin(x) end |
.csch(x) ⇒ Object
297 298 299 |
# File 'lib/numru/narray_ext.rb', line 297 def csch x 1/sinh(x) end |
.recip(x) ⇒ Object
289 290 291 |
# File 'lib/numru/narray_ext.rb', line 289 def recip x 1/x.to_f end |
.sec(x) ⇒ Object
307 308 309 |
# File 'lib/numru/narray_ext.rb', line 307 def sec x 1/cos(x) end |
.sech(x) ⇒ Object
310 311 312 |
# File 'lib/numru/narray_ext.rb', line 310 def sech x 1/cosh(x) end |