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.

3.6 Interfaces and Implementations • 129> ‘*‘ := proc( a, b )> use ‘*‘ = R:-‘*‘ in> normal( make( numer( a ) * numer( b ),> denom( a ) * denom( b ) ) )> end use> end proc;> end module> end proc:Note: The source code for QuotientField.mpl is available in thesamples directory of your Maple installation.Most of the exported routines are straightforward. The fraction constructormake accepts two members of the ring R as arguments and returnsthe constructed fraction, which is represented by an unevaluated functioncall of the formFRACTION( numerator, denominator )The exported procedure embed is the canonical embedding η of the integraldomain into its quotient field, described previously. This makes theconstructor functorial. The arithmetic operators are simple implementationsof the familiar rules for fraction arithmetic:ab + c ad + bc=d bdab × c d = acbd( a) −1 b =b a( a)− = −ab bAfter applying these simple formulae, the result is normalized by usinga call to the local routine normal (not the top-level routine :-normal).The normal routine does most of the interesting work in the ring generatedby this constructor. It uses the manifestation of the division algorithm inthe ring R via the exported procedures quo and gcd to reduce each fractionto the lowest terms. The fraction constructor make and the methodnormal represent field elements by the normal form representative of theappropriate equivalence class. The make routine prevents division by zero,and forces denominators to be unit normal representatives. The normalroutine ensures that fractions are reduced to lowest terms.The most important property of the QuotientField functor is thatit is generic. It relies solely on the GcdRing interface. No knowledge of

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

Saved successfully!

Ooh no, something went wrong!