Module: NumRu::Misc::EMath

Defined in:
lib/numru/misc/emath.rb

Overview

To be included instead of the Math predefined module (or NMath in NArray). Unlike Math and NMath, EMath handles unknown classes by calling its native instance method (assuming the same name).

Therefore, if included, its function (module method) is used as:

cos( obj )

and so on. If obj is not of a supported class, EMath calls, obj.cos in this case. (If cos is not a method of obj, then an exception is raised.) Supported classes are Numeric (by Math) and NArray (by NMath). EMath stands for “good Math” (for obvious reason for a Japanese).

Note: as for atan2(a,b), a.atan2(b) will be called if a or b is not supported. This is the case for all functions that take two or more arguments.

require “narray” require “cmath” if RUBY_VERSION.to_f > 1.8

Constant Summary collapse

E =
Math::E
PI =
Math::PI