Sha256: e96b22144eeca60b1f82d4105650ce545c1463e8e0540896e6ba23200881edb1
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
module Dydx module Algebra module Operator module Parts module Formula %w(+ -).map(&:to_sym).each do |operator| define_method(operator) do |x| if multiplication? && x.multiplication? if f == x.f f * g.send(operator, x.g) elsif g == x.g f.send(operator, x.f) * g else super(x) end elsif ([self.operator, operator].sort == [:+, :-]) && ( f == x || g == x ) if f == x g elsif g == x f end elsif (self.operator == operator) && ( f == x || g == x ) if f == x f.send(operator, x).send(operator, g) elsif g == x f.send(operator, g.send(:+, x)) end else super(x) end end end %w(* /).map(&:to_sym).each do |operator| define_method(operator) do |x| if exponentiation? && x.exponentiation? if f == x.f f ^ g.send({'*'=>'+', '/'=>'-'}[operator.to_s], x.g) elsif g == x.g f.send(operator, x.f) ^ g else super(x) end elsif ([self.operator, operator].sort == [:*, :/]) && ( f == x || g == x ) if f == x g elsif g == x f end elsif (self.operator == operator) && ( f == x || g == x ) if f == x f.send(operator, x).send(operator, g) elsif g == x f.send(operator, g.send(:* , x)) end else super(x) end end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dydx-0.0.3 | lib/dydx/algebra/operator/parts/formula.rb |