Class: Rational

Inherits:
Object show all
Defined in:
lib/y_support/abstract_algebra.rb

Overview

Patching Rational with Algebra::Field compliance methods.

Class Method Summary collapse

Class Method Details

.add(other) ⇒ Object



110
# File 'lib/y_support/abstract_algebra.rb', line 110

def add( other ); self + other end

.additive_identityObject Also known as: zero



108
# File 'lib/y_support/abstract_algebra.rb', line 108

def additive_identity; Rational 0, 1 end

.additive_inverseObject



111
# File 'lib/y_support/abstract_algebra.rb', line 111

def additive_inverse; -self end

.multiplicative_identityObject Also known as: one



113
# File 'lib/y_support/abstract_algebra.rb', line 113

def multiplicative_identity; Rational 1, 1 end

.multiplicative_inverseObject



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