|
Rings for MAT 685
Mathematical ring implementation to demonstrate templates and inheritance
|
encapsulates integers under the Ring_Element rubric
More...
#include <integer.hpp>
Public Member Functions | |
| Integer () | |
| initializes to zero | |
| Integer (T) | |
| initializes to the given value | |
| Integer (const Integer< T > &other) | |
| copy constructor | |
| const Integer< T > & | operator= (const Ring_Element &) |
| assignment operator may be needed | |
| virtual bool | is_one () const override |
should be True iff element is multiplicative identity | |
| virtual bool | is_zero () const override |
should be True iff element is additive identity | |
| virtual bool | has_inverse () const override |
should be True iff element has a multiplicative inverse | |
| virtual bool | operator== (const Ring_Element &) const override |
| comparison: other element has same value | |
| virtual bool | operator!= (const Ring_Element &) const override |
| comparison: other element has different value | |
| virtual Ring_Element & | operator+ (const Ring_Element &) const override |
| addition: other element should be of same type, use a cast | |
| virtual Ring_Element & | operator- (const Ring_Element &) const override |
| subtraction: other element should be of same type, use a cast | |
| virtual Ring_Element & | operator* (const Ring_Element &) const override |
| multiplicationL other element should be of same type, use a cast | |
| T | get_value () const |
returns the value of this | |
Public Member Functions inherited from Rings::Integral_Domain_Element | |
| virtual bool | is_cancellable () const override |
| integral domains are commutative rings without zero divisors, so the element should be cancellable (see description of class) | |
Public Member Functions inherited from Rings::Commutative_Ring_Element | |
| virtual bool | is_commutative () const override |
| Duh. | |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T > | |
| ostream & | operator<< (ostream &os, Integer< T > i) |
| prints the value of the given integer | |
encapsulates integers under the Ring_Element rubric
The template is used to specify the base numeric type: int, uint32_t, etc. In theory you could do something stupid like instantiate an Integer<double> but why? Anyway, this class may be extended to have methods that would rule that out; e.g., T could require the % operator and good luck doing that with your silly little double.
1.8.13