realroot_doc 0.1.1
/Users/mourrain/Devel/mmx/realroot/glue/glue_polynomial_tensor_integer.cpp
Go to the documentation of this file.
00001 
00002 #include <basix/int.hpp>
00003 #include <basix/vector.hpp>
00004 #include <basix/port.hpp>
00005 #include <numerix/integer.hpp>
00006 #include <numerix/rational.hpp>
00007 #include <numerix/floating.hpp>
00008 #include <numerix/kernel.hpp>
00009 #include <realroot/polynomial.hpp>
00010 #include <realroot/polynomial_glue.hpp>
00011 #include <realroot/polynomial_sparse_glue.hpp>
00012 #include <realroot/polynomial_tensor_glue.hpp>
00013 #include <basix/tuple.hpp>
00014 #include <basix/glue.hpp>
00015 
00016 #define int_literal(x) as_int (as_string (x))
00017 #define set_of_generic set_of(generic)
00018 #define set_of_double set_of(double)
00019 #define set_of_integer set_of(integer)
00020 #define set_of_rational set_of(rational)
00021 #define set_of_bigfloat set_of(bigfloat)
00022 #define set_of_complex_bigfloat set_of(complex_bigfloat)
00023 
00024 namespace mmx {
00025   static integer
00026   GLUE_1 (const ring<integer, MonomialTensor> &arg_1) {
00027     return sample (arg_1);
00028   }
00029   
00030   static ring<integer, MonomialTensor>
00031   GLUE_2 (const ring<integer, Sparse, DegRevLex> &arg_1) {
00032     return ring_tensor_of (arg_1);
00033   }
00034   
00035   static ring<integer, MonomialTensor>
00036   GLUE_3 (const ring<integer, MonomialTensor> &arg_1, const tuple<generic> &arg_2) {
00037     return ring_tensor_extend_generic (arg_1, as_vector (arg_2));
00038   }
00039   
00040   static int
00041   GLUE_4 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00042     return size (arg_1);
00043   }
00044   
00045   static int
00046   GLUE_5 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00047     return degree (arg_1);
00048   }
00049   
00050   static int
00051   GLUE_6 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00052     return nbvar (arg_1);
00053   }
00054   
00055   static ring<integer, MonomialTensor>::Polynomial
00056   GLUE_7 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00057     return -arg_1;
00058   }
00059   
00060   static ring<integer, MonomialTensor>::Polynomial
00061   GLUE_8 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00062     return arg_1 + arg_2;
00063   }
00064   
00065   static ring<integer, MonomialTensor>::Polynomial
00066   GLUE_9 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00067     return arg_1 - arg_2;
00068   }
00069   
00070   static ring<integer, MonomialTensor>::Polynomial
00071   GLUE_10 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00072     return arg_1 * arg_2;
00073   }
00074   
00075   static ring<integer, MonomialTensor>::Polynomial
00076   GLUE_11 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00077     return square (arg_1);
00078   }
00079   
00080   static ring<integer, MonomialTensor>::Polynomial
00081   GLUE_12 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const int &arg_2) {
00082     return pow (arg_1, arg_2);
00083   }
00084   
00085   static ring<integer, MonomialTensor>::Polynomial
00086   GLUE_13 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const int &arg_2) {
00087     return diff (arg_1, arg_2);
00088   }
00089   
00090   static ring<integer, MonomialTensor>::Polynomial
00091   GLUE_14 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const generic &arg_2) {
00092     return diff (arg_1, arg_2);
00093   }
00094   
00095   static ring<integer, MonomialTensor>::Polynomial
00096   GLUE_15 (const integer &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00097     return arg_1 + arg_2;
00098   }
00099   
00100   static ring<integer, MonomialTensor>::Polynomial
00101   GLUE_16 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const integer &arg_2) {
00102     return arg_1 + arg_2;
00103   }
00104   
00105   static ring<integer, MonomialTensor>::Polynomial
00106   GLUE_17 (const integer &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00107     return arg_1 - arg_2;
00108   }
00109   
00110   static ring<integer, MonomialTensor>::Polynomial
00111   GLUE_18 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const integer &arg_2) {
00112     return arg_1 - arg_2;
00113   }
00114   
00115   static ring<integer, MonomialTensor>::Polynomial
00116   GLUE_19 (const integer &arg_1, const ring<integer, MonomialTensor>::Polynomial &arg_2) {
00117     return arg_1 * arg_2;
00118   }
00119   
00120   static ring<integer, MonomialTensor>::Polynomial
00121   GLUE_20 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const integer &arg_2) {
00122     return arg_1 * arg_2;
00123   }
00124   
00125   static ring<integer, MonomialTensor>::Polynomial
00126   GLUE_21 (const ring<integer, MonomialTensor> &arg_1, const integer &arg_2) {
00127     return polynomial_tensor (arg_1, arg_2);
00128   }
00129   
00130   static ring<integer, MonomialTensor>::Polynomial
00131   GLUE_22 (const ring<integer, MonomialTensor> &arg_1, const integer &arg_2, const int &arg_3, const int &arg_4) {
00132     return polynomial_tensor (arg_1, arg_2, arg_3, arg_4);
00133   }
00134   
00135   static ring<integer, MonomialTensor>::Polynomial
00136   GLUE_23 (const ring<integer, MonomialTensor> &arg_1, const string &arg_2) {
00137     return polynomial_tensor (arg_1, arg_2);
00138   }
00139   
00140   static ring<integer, MonomialTensor>::Polynomial
00141   GLUE_24 (const ring<integer, MonomialTensor> &arg_1, const generic &arg_2) {
00142     return polynomial_tensor (arg_1, arg_2);
00143   }
00144   
00145   static ring<integer, MonomialTensor>::Polynomial
00146   GLUE_25 (const ring<integer, MonomialTensor> &arg_1, const string &arg_2) {
00147     return polynomial_tensor (arg_1, arg_2);
00148   }
00149   
00150   static ring<integer, MonomialTensor>::Polynomial
00151   GLUE_26 (const ring<integer, MonomialTensor> &arg_1, const generic &arg_2) {
00152     return polynomial_tensor (arg_1, arg_2);
00153   }
00154   
00155   static vector<generic>
00156   GLUE_27 (const ring<integer, MonomialTensor>::Polynomial &arg_1, const int &arg_2) {
00157     return polynomial_tensor_coefficients (arg_1, arg_2);
00158   }
00159   
00160   static vector<generic>
00161   GLUE_28 (const ring<integer, MonomialTensor>::Polynomial &arg_1) {
00162     return polynomial_tensor_coefficients (arg_1);
00163   }
00164   
00165   static ring<integer, MonomialTensor>::Polynomial
00166   GLUE_29 (const ring<integer, Sparse, DegRevLex>::Polynomial &arg_1) {
00167     return polynomial_tensor_of (arg_1);
00168   }
00169   
00170   static ring<integer, MonomialTensor>::Polynomial
00171   GLUE_30 (const ring<integer, MonomialTensor> &arg_1, const int &arg_2) {
00172     return arg_1[arg_2];
00173   }
00174   
00175   void
00176   glue_polynomial_tensor_integer () {
00177     static bool done = false;
00178     if (done) return;
00179     done = true;
00180     call_glue (string ("glue_int"));
00181     call_glue (string ("glue_vector_generic"));
00182     call_glue (string ("glue_string"));
00183     call_glue (string ("glue_kernel"));
00184     define_type<ring<integer, Sparse, DegRevLex> > (gen (lit ("MonomialSparseRing"), lit ("Integer")));
00185     define_type<MonomialTensor > (lit ("MonomialBasis"));
00186     define_constant<MonomialTensor > ("Monomials", MonomialTensor ());
00187     define_type<ring<integer, MonomialTensor> > (gen (lit ("MonomialTensorRing"), lit ("Integer")));
00188     define ("sample", GLUE_1);
00189     define ("tensor", GLUE_2);
00190     define (".[]", GLUE_3);
00191     define_type<ring<integer, MonomialTensor>::Polynomial > (gen (lit ("Polynomial"), gen (lit ("MonomialTensorRing"), lit ("Integer"))));
00192     define_type<ring<integer, Sparse, DegRevLex>::Polynomial > (gen (lit ("Polynomial"), gen (lit ("MonomialSparseRing"), lit ("Integer"))));
00193     define ("#", GLUE_4);
00194     define ("degree", GLUE_5);
00195     define ("nbvar", GLUE_6);
00196     define ("-", GLUE_7);
00197     define ("+", GLUE_8);
00198     define ("-", GLUE_9);
00199     define ("*", GLUE_10);
00200     define ("square", GLUE_11);
00201     define ("^", GLUE_12);
00202     define ("diff", GLUE_13);
00203     define ("diff", GLUE_14);
00204     define ("+", GLUE_15);
00205     define ("+", GLUE_16);
00206     define ("-", GLUE_17);
00207     define ("-", GLUE_18);
00208     define ("*", GLUE_19);
00209     define ("*", GLUE_20);
00210     define ("polynomial", GLUE_21);
00211     define ("polynomial", GLUE_22);
00212     define ("polynomial", GLUE_23);
00213     define ("polynomial", GLUE_24);
00214     define ("<<", GLUE_25);
00215     define ("<<", GLUE_26);
00216     define ("coefficients", GLUE_27);
00217     define ("coefficients", GLUE_28);
00218     define ("tensor", GLUE_29);
00219     define (".[]", GLUE_30);
00220   }
00221 }