lib/dydx/algebra.rb in dydx-0.0.4 vs lib/dydx/algebra.rb in dydx-0.0.5

- old
+ new

@@ -1,9 +1,11 @@ require 'dydx/algebra/formula' +require 'dydx/algebra/inverse' require 'dydx/algebra/set' +require 'dydx/algebra/operator/inverse' require 'dydx/algebra/operator/formula' require 'dydx/algebra/operator/symbol' require 'dydx/algebra/operator/num' require 'dydx/algebra/operator/general' @@ -37,7 +39,18 @@ class Sin; include Operator::General; end class Cos; include Operator::General; end class Tan; include Operator::General; end end class Formula; include Operator::Formula; end + class Inverse; include Operator::Inverse; end + + def inverse(x, operator) + if operator == :+ && x.is_0? + e0 + elsif operator == :* && x.is_1? + e1 + else + Inverse.new(x, operator) + end + end end end