11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

130 • Chapter 3: <strong>Programming</strong> with Modulesthe concrete representation of the input integral domain R (other thanthat it is a module that satisfies the required interface) is used in theconstruction. Therefore, it works with any implementation of the GcdRinginterface that:• Implements the correct semantics for its public operations• Satisfies the abstract constraint that it be a software representationof an integral domain. (This constraint is required to ensure that thearithmetic operations are well defined.)Constructing the Rationals as the Quotient Field of Z To constructthe quotient ring of the ring MapleIntegers defined previously, proceedas follows.> FF := QuotientField( MapleIntegers );FF := module()export‘ + ‘, ‘ ∗ ‘, ‘ − ‘, ‘/‘, zero, one, iszero, isone, make,numer, denom, normal , embed ;description “a quotient field”;end module> type( FF, ’Field’ );true> a := FF:-make( 2, 3 );a := FRACTION(2, 3)> b := FF:-make( 2, 4 );b := FRACTION(2, 4)> use FF in> a + b;> a * b;> a / b> end use;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!