Module: Dydx::Algebra
- Includes:
- Set
- Included in:
- Dydx
- Defined in:
- lib/dydx/algebra.rb,
lib/dydx/algebra/set.rb,
lib/dydx/algebra/formula.rb,
lib/dydx/algebra/inverse.rb,
lib/dydx/algebra/operator/num.rb,
lib/dydx/algebra/operator/formula.rb,
lib/dydx/algebra/operator/general.rb,
lib/dydx/algebra/operator/inverse.rb,
lib/dydx/algebra/operator/parts/num.rb,
lib/dydx/algebra/operator/parts/base.rb,
lib/dydx/algebra/operator/parts/symbol.rb,
lib/dydx/algebra/operator/parts/formula.rb,
lib/dydx/algebra/operator/parts/general.rb,
lib/dydx/algebra/operator/parts/inverse.rb
Defined Under Namespace
Modules: Operator, Set Classes: Formula, Inverse
Instance Method Summary collapse
- #-@ ⇒ Object
-
#inverse(x, operator) ⇒ Object
TODO: Cyclomatic complexity for inverse is too high.
Methods included from Set
#cos, #e, #e0, #e1, #log, #log10, #log2, #oo, #pi, #sin, #tan
Instance Method Details
#-@ ⇒ Object
26 27 28 |
# File 'lib/dydx/algebra.rb', line 26 def -@ inverse(self, :+) end |
#inverse(x, operator) ⇒ Object
TODO: Cyclomatic complexity for inverse is too high. [7/6]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dydx/algebra.rb', line 11 def inverse(x, operator) if x.num? x = x.to_numeric if operator == :+ _(- x) else _(Rational(1, x)) end elsif x.is_a?(Inverse) && x.operator == operator x.x else Inverse.new(x, operator) end end |