Class: Rational
Overview
Patching Rational with Algebra::Field compliance methods.
Class Method Summary collapse
- .add(other) ⇒ Object
- .additive_identity ⇒ Object (also: zero)
- .additive_inverse ⇒ Object
- .multiplicative_identity ⇒ Object (also: one)
- .multiplicative_inverse ⇒ Object
- .multiply(other) ⇒ Object
Class Method Details
.add(other) ⇒ Object
110 |
# File 'lib/y_support/abstract_algebra.rb', line 110 def add( other ); self + other end |
.additive_identity ⇒ Object Also known as: zero
108 |
# File 'lib/y_support/abstract_algebra.rb', line 108 def additive_identity; Rational 0, 1 end |
.additive_inverse ⇒ Object
111 |
# File 'lib/y_support/abstract_algebra.rb', line 111 def additive_inverse; -self end |
.multiplicative_identity ⇒ Object Also known as: one
113 |
# File 'lib/y_support/abstract_algebra.rb', line 113 def multiplicative_identity; Rational 1, 1 end |
.multiplicative_inverse ⇒ Object
115 |
# File 'lib/y_support/abstract_algebra.rb', line 115 def multiplicative_inverse; Rational( 1, 1 ) / self end |
.multiply(other) ⇒ Object
112 |
# File 'lib/y_support/abstract_algebra.rb', line 112 def multiply( other ); self * other end |