Sha256: fa0415ba26421c14f31c9e8bb0ce9305149bb8fa62bb38d03f4eadfe23df37fb
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
require 'symath/definition/function' module SyMath class Definition::Ln < Definition::Function def initialize() super(:ln) @reductions_real = { 1.to_m => 0.to_m, :e.to_m => 1.to_m, 0.to_m => -:oo.to_m, :oo.to_m => :oo.to_m, } @reductions_complex = { 1.to_m => 0.to_m, :e.to_m => 1.to_m, -1.to_m => :pi.to_m*:i, -:e.to_m => 1.to_m + :pi.to_m*:i, :i.to_m => :pi.to_m*:i/2, :e.to_m*:i => 1.to_m + :pi.to_m*:i/2, -:i.to_m => -:pi.to_m*:i/2, -:e.to_m*:i => 1.to_m - :pi.to_m*:i/2, } end def description() return 'ln(x) - natural logarithm' end def reduce_call(c) arg = c.args[0] if SyMath.setting(:complex_arithmetic) return super(c, @reductions_complex) else if arg.is_a?(SyMath::Minus) return :nan.to_m end return super(c, @reductions_real) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
symath-0.1.1 | lib/symath/definition/ln.rb |
symath-0.1.0 | lib/symath/definition/ln.rb |