algebramix_doc 0.3
/Users/mourrain/Devel/mmx/algebramix/include/algebramix/quotient_polynomial.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : quotient_polynomial.hpp
00004 * DESCRIPTION: Rational functions
00005 * COPYRIGHT  : (C) 2007  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 } // namespace mmx
00072 #endif // __MMX_QUOTIENT_POLYNOMIAL__HPP
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines