Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/Dobjects/Numeric_extras.rb,
ext/Tioga/FigureMaker/generic.c
Overview
add some Numeric methods
Direct Known Subclasses
Instance Method Summary collapse
-
#acos ⇒ Object
Math functions.
- #acosh ⇒ Object
- #as_exponent_of(y) ⇒ Object
- #asin ⇒ Object
- #asinh ⇒ Object
- #atan ⇒ Object
- #atan2(n) ⇒ Object
- #atanh ⇒ Object
- #cos ⇒ Object
- #cosh ⇒ Object
- #exp ⇒ Object
- #exp10 ⇒ Object
- #inv ⇒ Object
- #log ⇒ Object
- #log10 ⇒ Object
- #mod(y) ⇒ Object
- #neg ⇒ Object
- #pow(y) ⇒ Object
- #raised_to(y) ⇒ Object
- #safe_acos ⇒ Object
- #safe_asin ⇒ Object
- #safe_inv(cutoff = 1e-99) ⇒ Object
- #safe_log(cutoff = 1e-99) ⇒ Object
- #safe_log10(cutoff = 1e-99) ⇒ Object
- #safe_sqrt ⇒ Object
- #sin ⇒ Object
- #sinh ⇒ Object
- #sqrt ⇒ Object
- #tan ⇒ Object
- #tanh ⇒ Object
- #trim(cutoff = 1e-6) ⇒ Object
Instance Method Details
#acos ⇒ Object
Math functions
9 10 11 |
# File 'lib/Dobjects/Numeric_extras.rb', line 9 def acos Math.acos(self) end |
#acosh ⇒ Object
13 14 15 |
# File 'lib/Dobjects/Numeric_extras.rb', line 13 def acosh Math.acosh(self) end |
#as_exponent_of(y) ⇒ Object
101 102 103 |
# File 'lib/Dobjects/Numeric_extras.rb', line 101 def as_exponent_of(y) y**self end |
#asin ⇒ Object
17 18 19 |
# File 'lib/Dobjects/Numeric_extras.rb', line 17 def asin Math.asin(self) end |
#asinh ⇒ Object
21 22 23 |
# File 'lib/Dobjects/Numeric_extras.rb', line 21 def asinh Math.asinh(self) end |
#atan ⇒ Object
25 26 27 |
# File 'lib/Dobjects/Numeric_extras.rb', line 25 def atan Math.atan(self) end |
#atan2(n) ⇒ Object
33 34 35 |
# File 'lib/Dobjects/Numeric_extras.rb', line 33 def atan2(n) Math.atan2(self,n) end |
#atanh ⇒ Object
29 30 31 |
# File 'lib/Dobjects/Numeric_extras.rb', line 29 def atanh Math.atanh(self) end |
#cos ⇒ Object
37 38 39 |
# File 'lib/Dobjects/Numeric_extras.rb', line 37 def cos Math.cos(self) end |
#cosh ⇒ Object
41 42 43 |
# File 'lib/Dobjects/Numeric_extras.rb', line 41 def cosh Math.cosh(self) end |
#exp ⇒ Object
45 46 47 |
# File 'lib/Dobjects/Numeric_extras.rb', line 45 def exp Math.exp(self) end |
#exp10 ⇒ Object
81 82 83 |
# File 'lib/Dobjects/Numeric_extras.rb', line 81 def exp10 10**self end |
#inv ⇒ Object
85 86 87 |
# File 'lib/Dobjects/Numeric_extras.rb', line 85 def inv 1/self end |
#log ⇒ Object
49 50 51 |
# File 'lib/Dobjects/Numeric_extras.rb', line 49 def log Math.log(self) end |
#log10 ⇒ Object
53 54 55 |
# File 'lib/Dobjects/Numeric_extras.rb', line 53 def log10 Math.log10(self) end |
#mod(y) ⇒ Object
129 130 131 |
# File 'lib/Dobjects/Numeric_extras.rb', line 129 def mod(y) self.modulo(y) end |
#neg ⇒ Object
77 78 79 |
# File 'lib/Dobjects/Numeric_extras.rb', line 77 def neg -self end |
#pow(y) ⇒ Object
93 94 95 |
# File 'lib/Dobjects/Numeric_extras.rb', line 93 def pow(y) self**y end |
#raised_to(y) ⇒ Object
97 98 99 |
# File 'lib/Dobjects/Numeric_extras.rb', line 97 def raised_to(y) self**y end |
#safe_acos ⇒ Object
125 126 127 |
# File 'lib/Dobjects/Numeric_extras.rb', line 125 def safe_acos ((self > 1.0)? 1.0 : (self < -1.0)? -1.0 : self).acos end |
#safe_asin ⇒ Object
121 122 123 |
# File 'lib/Dobjects/Numeric_extras.rb', line 121 def safe_asin ((self > 1.0)? 1.0 : (self < -1.0)? -1.0 : self).asin end |
#safe_inv(cutoff = 1e-99) ⇒ Object
113 114 115 |
# File 'lib/Dobjects/Numeric_extras.rb', line 113 def safe_inv(cutoff=1e-99) (self.abs > cutoff)? 1/self : (self > 0)? 1/cutoff : -1/cutoff end |
#safe_log(cutoff = 1e-99) ⇒ Object
105 106 107 |
# File 'lib/Dobjects/Numeric_extras.rb', line 105 def safe_log(cutoff=1e-99) ((self > cutoff)? self : cutoff).log end |
#safe_log10(cutoff = 1e-99) ⇒ Object
109 110 111 |
# File 'lib/Dobjects/Numeric_extras.rb', line 109 def safe_log10(cutoff=1e-99) ((self > cutoff)? self : cutoff).log10 end |
#safe_sqrt ⇒ Object
117 118 119 |
# File 'lib/Dobjects/Numeric_extras.rb', line 117 def safe_sqrt (self > 0.0)? self.sqrt : 0.0 end |
#sin ⇒ Object
57 58 59 |
# File 'lib/Dobjects/Numeric_extras.rb', line 57 def sin Math.sin(self) end |
#sinh ⇒ Object
61 62 63 |
# File 'lib/Dobjects/Numeric_extras.rb', line 61 def sinh Math.sinh(self) end |
#sqrt ⇒ Object
65 66 67 |
# File 'lib/Dobjects/Numeric_extras.rb', line 65 def sqrt Math.sqrt(self) end |
#tan ⇒ Object
69 70 71 |
# File 'lib/Dobjects/Numeric_extras.rb', line 69 def tan Math.tan(self) end |
#tanh ⇒ Object
73 74 75 |
# File 'lib/Dobjects/Numeric_extras.rb', line 73 def tanh Math.tanh(self) end |
#trim(cutoff = 1e-6) ⇒ Object
89 90 91 |
# File 'lib/Dobjects/Numeric_extras.rb', line 89 def trim(cutoff=1e-6) (self.abs < cutoff)? 0.0 : self end |