Class: JBLAS::ReversedArithmetic
Overview
When arguments to arithmetic operators are promoted via coerce, they change their order. This class is a wrapper for the promoted self which has -
and /
overloaded to call rsub
and rdiv
instead of div
and sub
Instance Method Summary collapse
- #*(o) ⇒ Object
- #+(o) ⇒ Object
- #-(o) ⇒ Object
- #/(o) ⇒ Object
-
#initialize(o) ⇒ ReversedArithmetic
constructor
A new instance of ReversedArithmetic.
Constructor Details
#initialize(o) ⇒ ReversedArithmetic
Returns a new instance of ReversedArithmetic.
42 43 44 |
# File 'lib/jblas/arith.rb', line 42 def initialize(o) @value = o; end |
Instance Method Details
#*(o) ⇒ Object
50 51 52 |
# File 'lib/jblas/arith.rb', line 50 def *(o) @value.mul o end |
#+(o) ⇒ Object
46 47 48 |
# File 'lib/jblas/arith.rb', line 46 def +(o) @value.add o end |
#-(o) ⇒ Object
54 55 56 |
# File 'lib/jblas/arith.rb', line 54 def -(o) @value.rsub o end |
#/(o) ⇒ Object
58 59 60 |
# File 'lib/jblas/arith.rb', line 58 def /(o) @value.rdiv o end |