module Autodiff::DualNumConvertible

Public Instance Methods

dual_op(op) click to toggle source
# File lib/autodiff/dual_num.rb, line 4
def dual_op(op)
  orig_op = "predual_#{op.to_s}".to_sym
  alias_method orig_op, op
  define_method(op) { |other|
    if other.kind_of?(Autodiff::DualNum)
      self.to_dual.public_send(op, other)
    else
      self.public_send(orig_op, other)
    end
  }
end