Module: Math
- Includes:
- Hornetseye::Methods
- Defined in:
- lib/multiarray/complex.rb,
lib/multiarray/methods.rb,
lib/multiarray/rgb.rb
Overview
The Math
module is extended with a few methods
Class Method Summary collapse
- .acos ⇒ Object
- .acos_without_internalcomplex ⇒ Object
- .acosh ⇒ Object
- .acosh_without_internalcomplex ⇒ Object
- .asin ⇒ Object
- .asin_without_internalcomplex ⇒ Object
- .asinh ⇒ Object
- .asinh_without_internalcomplex ⇒ Object
- .atan ⇒ Object
- .atan2 ⇒ Object
- .atan2_without_internalcomplex ⇒ Object
- .atan_without_internalcomplex ⇒ Object
- .atanh ⇒ Object
- .atanh_without_internalcomplex ⇒ Object
- .cos ⇒ Object
- .cos_without_internalcomplex ⇒ Object
- .cosh ⇒ Object
- .cosh_without_internalcomplex ⇒ Object
- .exp ⇒ Object
- .exp_without_internalcomplex ⇒ Object
- .log ⇒ Object
- .log10 ⇒ Object
- .log10_without_internalcomplex ⇒ Object
- .log_without_internalcomplex ⇒ Object
- .log_without_rgb ⇒ Object
- .sin ⇒ Object
- .sin_without_internalcomplex ⇒ Object
- .sinh ⇒ Object
- .sinh_without_internalcomplex ⇒ Object
- .sqrt ⇒ Object
- .sqrt_without_internalcomplex ⇒ Object
- .sqrt_without_rgb ⇒ Object
- .tan ⇒ Object
- .tan_without_internalcomplex ⇒ Object
- .tanh ⇒ Object
- .tanh_without_internalcomplex ⇒ Object
Instance Method Summary collapse
-
#acos_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus cosinus for internal complex numbers.
-
#acosh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus cosinus hyperbolicus for internal complex numbers.
-
#asin_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus sinus for internal complex numbers.
-
#asinh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus sinus hyperbolicus for internal complex numbers.
-
#atan2_with_internalcomplex(y, x) ⇒ Object, Hornetseye::InternalComplex
Arcus tangens of two internal complex numbers.
-
#atan_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus tangens for internal complex numbers.
-
#atanh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus tangens hyperbolicus for internal complex numbers.
-
#cos_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Cosinus for internal complex numbers.
-
#cosh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Cosinus hyperbolicus for internal complex numbers.
-
#exp_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Exponent for internal complex numbers.
-
#log10_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Base-10 logarithm for internal complex numbers.
-
#log_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Logarithm for internal complex numbers.
- #log_with_rgb(c) ⇒ Object
-
#sin_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Sinus for internal complex numbers.
-
#sinh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Sinus hyperbolicus for internal complex numbers.
-
#sqrt_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Square root for internal complex numbers.
- #sqrt_with_rgb(c) ⇒ Object
-
#tan_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Tangens for internal complex numbers.
-
#tanh_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Tangens hyperbolicus for internal complex numbers.
Methods included from Hornetseye::Methods
define_binary_method, define_unary_method, included
Class Method Details
.acos ⇒ Object
.acos_without_internalcomplex ⇒ Object
.acosh ⇒ Object
.acosh_without_internalcomplex ⇒ Object
.asin ⇒ Object
.asin_without_internalcomplex ⇒ Object
.asinh ⇒ Object
.asinh_without_internalcomplex ⇒ Object
.atan ⇒ Object
.atan2 ⇒ Object
.atan2_without_internalcomplex ⇒ Object
.atan_without_internalcomplex ⇒ Object
.atanh ⇒ Object
.atanh_without_internalcomplex ⇒ Object
.cos ⇒ Object
.cos_without_internalcomplex ⇒ Object
.cosh ⇒ Object
.cosh_without_internalcomplex ⇒ Object
.exp ⇒ Object
.exp_without_internalcomplex ⇒ Object
.log ⇒ Object
.log10 ⇒ Object
.log10_without_internalcomplex ⇒ Object
.log_without_internalcomplex ⇒ Object
.log_without_rgb ⇒ Object
.sin ⇒ Object
.sin_without_internalcomplex ⇒ Object
.sinh ⇒ Object
.sinh_without_internalcomplex ⇒ Object
.sqrt ⇒ Object
.sqrt_without_internalcomplex ⇒ Object
.sqrt_without_rgb ⇒ Object
.tan ⇒ Object
.tan_without_internalcomplex ⇒ Object
.tanh ⇒ Object
.tanh_without_internalcomplex ⇒ Object
Instance Method Details
#acos_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Arcus cosinus for internal complex numbers
556 557 558 559 560 561 562 |
# File 'lib/multiarray/complex.rb', line 556 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, Hornetseye::InternalComplex
Arcus cosinus hyperbolicus for internal complex numbers
613 614 615 616 617 618 619 |
# File 'lib/multiarray/complex.rb', line 613 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, Hornetseye::InternalComplex
Arcus sinus for internal complex numbers
575 576 577 578 579 580 581 |
# File 'lib/multiarray/complex.rb', line 575 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, Hornetseye::InternalComplex
Arcus sinus hyperbolicus for internal complex numbers
632 633 634 635 636 637 638 |
# File 'lib/multiarray/complex.rb', line 632 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, Hornetseye::InternalComplex
Arcus tangens of two internal complex numbers
670 671 672 673 674 675 676 |
# File 'lib/multiarray/complex.rb', line 670 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, Hornetseye::InternalComplex
Arcus tangens for internal complex numbers
594 595 596 597 598 599 600 |
# File 'lib/multiarray/complex.rb', line 594 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, Hornetseye::InternalComplex
Arcus tangens hyperbolicus for internal complex numbers
651 652 653 654 655 656 657 |
# File 'lib/multiarray/complex.rb', line 651 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, Hornetseye::InternalComplex
Cosinus for internal complex numbers
395 396 397 398 399 400 401 402 403 |
# File 'lib/multiarray/complex.rb', line 395 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, Hornetseye::InternalComplex
Cosinus hyperbolicus for internal complex numbers
456 457 458 459 460 461 462 463 464 |
# File 'lib/multiarray/complex.rb', line 456 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, Hornetseye::InternalComplex
Exponent for internal complex numbers
374 375 376 377 378 379 380 381 382 |
# File 'lib/multiarray/complex.rb', line 374 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, Hornetseye::InternalComplex
Base-10 logarithm for internal complex numbers
537 538 539 540 541 542 543 |
# File 'lib/multiarray/complex.rb', line 537 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, Hornetseye::InternalComplex
Logarithm for internal complex numbers
517 518 519 520 521 522 523 524 |
# File 'lib/multiarray/complex.rb', line 517 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 |
#log_with_rgb(c) ⇒ Object
952 953 954 955 956 957 958 |
# File 'lib/multiarray/rgb.rb', line 952 def log_with_rgb(c) if c.is_a? Hornetseye::RGB Hornetseye::RGB.new log( c.r ), log( c.g ), log( c.b ) else log_without_rgb c end end |
#sin_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Sinus for internal complex numbers
416 417 418 419 420 421 422 423 424 |
# File 'lib/multiarray/complex.rb', line 416 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, Hornetseye::InternalComplex
Sinus hyperbolicus for internal complex numbers
477 478 479 480 481 482 483 484 485 |
# File 'lib/multiarray/complex.rb', line 477 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, Hornetseye::InternalComplex
Square root for internal complex numbers
352 353 354 355 356 357 358 359 360 361 |
# File 'lib/multiarray/complex.rb', line 352 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 |
#sqrt_with_rgb(c) ⇒ Object
940 941 942 943 944 945 946 |
# File 'lib/multiarray/rgb.rb', line 940 def sqrt_with_rgb(c) if c.is_a? Hornetseye::RGB Hornetseye::RGB.new sqrt( c.r ), sqrt( c.g ), sqrt( c.b ) else sqrt_without_rgb c end end |
#tan_with_internalcomplex(z) ⇒ Object, Hornetseye::InternalComplex
Tangens for internal complex numbers
437 438 439 440 441 442 443 |
# File 'lib/multiarray/complex.rb', line 437 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, Hornetseye::InternalComplex
Tangens hyperbolicus for internal complex numbers
498 499 500 501 502 503 504 |
# File 'lib/multiarray/complex.rb', line 498 def tanh_with_internalcomplex(z) if z.is_a? Hornetseye::InternalComplex sinh(z) / cosh(z) else tanh_without_internalcomplex z end end |