00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MMX_QUOTIENT_POLYNOMIAL__HPP
00014 #define __MMX_QUOTIENT_POLYNOMIAL__HPP
00015 #include <algebramix/quotient.hpp>
00016 #include <algebramix/polynomial.hpp>
00017 namespace mmx {
00018 #define TMPL template<typename C, typename V>
00019 #define Polynomial polynomial<C,V>
00020 #define Quotient quotient<Polynomial,Polynomial>
00021
00022 TMPL inline Quotient
00023 operator + (const Quotient& x1, const C& x2) {
00024 return Quotient (numerator (x1) + x2 * denominator (x1),
00025 denominator (x1));
00026 }
00027
00028 TMPL inline Quotient
00029 operator + (const C& x1, const Quotient& x2) {
00030 return Quotient (x1 * denominator (x2) + numerator (x2),
00031 denominator (x2));
00032 }
00033
00034 TMPL inline Quotient
00035 operator - (const Quotient& x1, const C& x2) {
00036 return Quotient (numerator (x1) - x2 * denominator (x1),
00037 denominator (x1));
00038 }
00039
00040 TMPL inline Quotient
00041 operator - (const C& x1, const Quotient& x2) {
00042 return Quotient (x1 * denominator (x2) - numerator (x2),
00043 denominator (x2));
00044 }
00045
00046 TMPL inline Quotient
00047 operator * (const C& c, const Quotient& x) {
00048 return Quotient (c * numerator (x), denominator (x));
00049 }
00050
00051 TMPL inline Quotient
00052 operator * (const Quotient& x, const C& c) {
00053 return Quotient (numerator (x) * c, denominator (x));
00054 }
00055
00056 TMPL inline Quotient
00057 operator / (const C& c, const Quotient& x) {
00058 ASSERT (numerator (x) != 0, "division by zero");
00059 return Quotient (c * denominator (x), numerator (x));
00060 }
00061
00062 TMPL inline Quotient
00063 operator / (const Quotient& x, const C& c) {
00064 ASSERT (c != 0, "division by zero");
00065 return Quotient (numerator (x) / c, denominator (x));
00066 }
00067
00068 #undef TMPL
00069 #undef Polynomial
00070 #undef Quotient
00071 }
00072 #endif // __MMX_QUOTIENT_POLYNOMIAL__HPP