1 # depends on: module.rb
5 PI = 3.14159_26535_89793_23846
6 E = 2.71828_18284_59045_23536
9 Platform::Math.atan2 Float(y), Float(x)
13 Platform::Math.cos Float(x)
17 Platform::Math.sin Float(x)
21 Platform::Math.tan Float(x)
26 verify_domain('acos') { x.abs <= 1.0 }
28 Platform::POSIX.errno = 0
30 ret = Platform::Math.acos x
37 verify_domain('asin') { x.abs <= 1.0 }
42 Platform::Math.atan Float(x)
46 Platform::Math.cosh Float(x)
50 Platform::Math.sinh Float(x)
54 Platform::Math.tanh Float(x)
59 verify_domain('acosh') { x >= 1.0 }
60 Platform::Math.acosh x
64 Platform::Math.asinh Float(x)
69 verify_domain('atanh') { x.abs <= 1.0 }
71 Platform::POSIX.errno = 0
73 ret = Platform::Math.atanh x
79 Platform::Math.exp Float(x)
84 verify_domain('log') { x >= 0.0 }
85 result = Platform::Math.log x
86 result /= Platorm::Math.log Float(base) if base
92 verify_domain('log2') { x >= 0.0 }
98 verify_domain('log10') { x >= 0.0 }
99 Platform::Math.log10 x
104 verify_domain('sqrt') { x >= 0.0 }
105 Platform::Math.sqrt x
110 MemoryPointer.new :int do |exp|
111 result = Platform::Math.frexp x, exp
112 [result, exp.read_int]
117 n = Type.coerce_to(n, Integer, :to_int)
119 Platform::Math.ldexp Float(x), n
123 Platform::Math.hypot Float(x), Float(y)
127 Platform::Math.erf Float(x)
131 Platform::Math.erfc Float(x)
134 def verify_domain(msg)
136 raise Errno::EDOM, msg if Errno.const_defined?(:EDOM)
137 raise Errno::ERANGE, msg if Errno.const_defined?(:ERANGE)
141 def self.after_loaded
142 module_function :verify_domain, :atan2, :cos, :sin, :tan, :acos, :asin, :atan,
143 :cosh, :sinh, :tanh, :acosh, :asinh, :atanh, :exp, :log, :log2,
144 :log10, :sqrt, :frexp, :ldexp, :hypot, :erf, :erfc
146 private :verify_domain, :atan2, :cos, :sin, :tan, :acos, :asin, :atan,
147 :cosh, :sinh, :tanh, :acosh, :asinh, :atanh, :exp, :log, :log2,
148 :log10, :sqrt, :frexp, :ldexp, :hypot, :erf, :erfc