Module: Math
Class Method Summary
collapse
Instance Method Summary
collapse
define_binary_method, define_unary_method, included
Class Method Details
.acos_without_internalcomplex ⇒ Object
.acosh_without_internalcomplex ⇒ Object
.asin_without_internalcomplex ⇒ Object
.asinh_without_internalcomplex ⇒ Object
.atan2_without_internalcomplex ⇒ Object
.atan_without_internalcomplex ⇒ Object
.atanh_without_internalcomplex ⇒ Object
.cos_without_internalcomplex ⇒ Object
.cosh_without_internalcomplex ⇒ Object
.exp_without_internalcomplex ⇒ Object
.log10_without_internalcomplex ⇒ Object
.log_without_internalcomplex ⇒ Object
.sin_without_internalcomplex ⇒ Object
.sinh_without_internalcomplex ⇒ Object
.sqrt_without_internalcomplex ⇒ Object
.tan_without_internalcomplex ⇒ Object
.tanh_without_internalcomplex ⇒ Object
Instance Method Details
#acos_with_internalcomplex(z) ⇒ Object
348
349
350
351
352
353
354
|
# File 'lib/multiarray/complex.rb', line 348
def acos_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
-1.0.im * log( z + 1.0.im * sqrt( 1.0 - z * z ) )
else
acos_without_internalcomplex z
end
end
|
#acosh_with_internalcomplex(z) ⇒ Object
384
385
386
387
388
389
390
|
# File 'lib/multiarray/complex.rb', line 384
def acosh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
log( z + sqrt( z * z - 1.0 ) )
else
acosh_without_internalcomplex z
end
end
|
#asin_with_internalcomplex(z) ⇒ Object
360
361
362
363
364
365
366
|
# File 'lib/multiarray/complex.rb', line 360
def asin_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
-1.0.im * log( 1.0.im * z + sqrt( 1.0 - z * z ) )
else
asin_without_internalcomplex z
end
end
|
#asinh_with_internalcomplex(z) ⇒ Object
396
397
398
399
400
401
402
|
# File 'lib/multiarray/complex.rb', line 396
def asinh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
log( z + sqrt( 1.0 + z * z ) )
else
asinh_without_internalcomplex z
end
end
|
#atan2_with_internalcomplex(y, x) ⇒ Object
420
421
422
423
424
425
426
|
# File 'lib/multiarray/complex.rb', line 420
def atan2_with_internalcomplex( y, x )
if [ x, y ].any? { |v| v.is_a? Hornetseye::InternalComplex }
-1.0.im * log( ( x + 1.0.im * y ) / sqrt( x * x + y * y ) )
else
atan2_without_internalcomplex y, x
end
end
|
#atan_with_internalcomplex(z) ⇒ Object
372
373
374
375
376
377
378
|
# File 'lib/multiarray/complex.rb', line 372
def atan_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
1.0.im * log( ( 1.0.im + z ) / ( 1.0.im - z ) ) / 2.0
else
atan_without_internalcomplex z
end
end
|
#atanh_with_internalcomplex(z) ⇒ Object
408
409
410
411
412
413
414
|
# File 'lib/multiarray/complex.rb', line 408
def atanh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
log( ( 1.0 + z ) / ( 1.0 - z ) ) / 2.0
else
atanh_without_internalcomplex z
end
end
|
#cos_with_internalcomplex(z) ⇒ Object
243
244
245
246
247
248
249
250
251
|
# File 'lib/multiarray/complex.rb', line 243
def cos_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = cos( z.real ) * cosh( z.imag )
imag = -sin( z.real ) * sinh( z.imag )
Hornetseye::InternalComplex.new real, imag
else
cos_without_internalcomplex z
end
end
|
#cosh_with_internalcomplex(z) ⇒ Object
283
284
285
286
287
288
289
290
291
|
# File 'lib/multiarray/complex.rb', line 283
def cosh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = cosh( z.real ) * cos( z.imag )
imag = sinh( z.real ) * sin( z.imag )
Hornetseye::InternalComplex.new real, imag
else
cosh_without_internalcomplex z
end
end
|
#exp_with_internalcomplex(z) ⇒ Object
229
230
231
232
233
234
235
236
237
|
# File 'lib/multiarray/complex.rb', line 229
def exp_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = exp( z.real ) * cos( z.imag )
imag = exp( z.real ) * sin( z.imag )
Hornetseye::InternalComplex.new real, imag
else
exp_without_internalcomplex z
end
end
|
#log10_with_internalcomplex(z) ⇒ Object
336
337
338
339
340
341
342
|
# File 'lib/multiarray/complex.rb', line 336
def log10_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
log( z ) / log( 10 )
else
log10_without_internalcomplex z
end
end
|
#log_with_internalcomplex(z) ⇒ Object
323
324
325
326
327
328
329
330
|
# File 'lib/multiarray/complex.rb', line 323
def log_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
r, theta = z.polar
Hornetseye::InternalComplex.new log( r.abs ), theta
else
log_without_internalcomplex z
end
end
|
#sin_with_internalcomplex(z) ⇒ Object
257
258
259
260
261
262
263
264
265
|
# File 'lib/multiarray/complex.rb', line 257
def sin_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = sin( z.real ) * cosh( z.imag )
imag = cos( z.real ) * sinh( z.imag )
Hornetseye::InternalComplex.new real, imag
else
sin_without_internalcomplex z
end
end
|
#sinh_with_internalcomplex(z) ⇒ Object
297
298
299
300
301
302
303
304
305
|
# File 'lib/multiarray/complex.rb', line 297
def sinh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = sinh( z.real ) * cos( z.imag )
imag = cosh( z.real ) * sin( z.imag )
Hornetseye::InternalComplex.new real, imag
else
sinh_without_internalcomplex z
end
end
|
#sqrt_with_internalcomplex(z) ⇒ Object
214
215
216
217
218
219
220
221
222
223
|
# File 'lib/multiarray/complex.rb', line 214
def sqrt_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
real = sqrt( ( z.abs + z.real ) / 2 )
imag = ( z.imag < 0 ).conditional -sqrt( ( z.abs - z.real ) / 2 ),
sqrt( ( z.abs - z.real ) / 2 )
Hornetseye::InternalComplex.new real, imag
else
sqrt_without_internalcomplex z
end
end
|
#tan_with_internalcomplex(z) ⇒ Object
271
272
273
274
275
276
277
|
# File 'lib/multiarray/complex.rb', line 271
def tan_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
sin( z ) / cos( z )
else
tan_without_internalcomplex z
end
end
|
#tanh_with_internalcomplex(z) ⇒ Object
311
312
313
314
315
316
317
|
# File 'lib/multiarray/complex.rb', line 311
def tanh_with_internalcomplex( z )
if z.is_a? Hornetseye::InternalComplex
sinh( z ) / cosh( z )
else
tanh_without_internalcomplex z
end
end
|