algebramix_doc 0.3
/Users/mourrain/Devel/mmx/algebramix/glue/glue_polynomial_modular_integer.cpp
Go to the documentation of this file.
00001 
00002 #include <basix/vector.hpp>
00003 #include <basix/int.hpp>
00004 #include <numerix/integer.hpp>
00005 #include <numerix/modular.hpp>
00006 #include <numerix/modular_integer.hpp>
00007 #include <algebramix/vector_unrolled.hpp>
00008 #include <algebramix/vector_simd.hpp>
00009 #include <algebramix/vector_modular.hpp>
00010 #include <algebramix/polynomial.hpp>
00011 #include <algebramix/polynomial_polynomial.hpp>
00012 #include <algebramix/polynomial_integer.hpp>
00013 #include <algebramix/polynomial_modular.hpp>
00014 #include <algebramix/polynomial_modular_integer.hpp>
00015 #include <algebramix/polynomial_schonhage.hpp>
00016 #include <basix/tuple.hpp>
00017 #include <basix/glue.hpp>
00018 
00019 #define int_literal(x) as_int (as_string (x))
00020 namespace mmx {
00021     template<typename C> polynomial<C>
00022     polynomial_reverse (const vector<C>& v) {
00023       return polynomial<C> (reverse (v)); }
00024 
00025     template<typename C> polynomial<modular<modulus<C>, modular_local> >
00026     as_polynomial_modular (const polynomial<C>& f, const modulus<C>& p) {
00027       modular<modulus<C>, modular_local>::set_modulus (p);
00028       return as<polynomial<modular<modulus<C>, modular_local> > > (f); }
00029 
00030     template<typename C> vector<generic>
00031     wrap_subresultants (const polynomial<C>& f, const polynomial<C>& g) {
00032       return as<vector<generic> > (subresultants (f, g)); }
00033 
00034   }
00035 namespace mmx { POLYNOMIAL_GENERIC_USES_SCHONHAGE }
00036 
00037 namespace mmx {
00038   static polynomial<mmx_modular(integer) >
00039   GLUE_1 (const tuple<mmx_modular(integer) > &arg_1) {
00040     return polynomial_reverse (as_vector (arg_1));
00041   }
00042   
00043   static polynomial<mmx_modular(integer) >
00044   GLUE_2 (const tuple<mmx_modular(integer) > &arg_1) {
00045     return polynomial<mmx_modular(integer) > (as_vector (arg_1));
00046   }
00047   
00048   static void
00049   GLUE_3 (const polynomial<mmx_modular(integer) > &arg_1, const generic &arg_2) {
00050     set_variable_name (arg_1, arg_2);
00051   }
00052   
00053   static polynomial<mmx_modular(integer) >
00054   GLUE_4 (const mmx_modular(integer) &arg_1) {
00055     return polynomial<mmx_modular(integer) > (arg_1);
00056   }
00057   
00058   static iterator<generic>
00059   GLUE_5 (const polynomial<mmx_modular(integer) > &arg_1) {
00060     return as<iterator<generic> > (iterate (arg_1));
00061   }
00062   
00063   static int
00064   GLUE_6 (const polynomial<mmx_modular(integer) > &arg_1) {
00065     return N (arg_1);
00066   }
00067   
00068   static int
00069   GLUE_7 (const polynomial<mmx_modular(integer) > &arg_1) {
00070     return deg (arg_1);
00071   }
00072   
00073   static mmx_modular(integer)
00074   GLUE_8 (const polynomial<mmx_modular(integer) > &arg_1, const int &arg_2) {
00075     return arg_1[arg_2];
00076   }
00077   
00078   static polynomial<mmx_modular(integer) >
00079   GLUE_9 (const polynomial<mmx_modular(integer) > &arg_1) {
00080     return -arg_1;
00081   }
00082   
00083   static polynomial<mmx_modular(integer) >
00084   GLUE_10 (const polynomial<mmx_modular(integer) > &arg_1) {
00085     return square (arg_1);
00086   }
00087   
00088   static polynomial<mmx_modular(integer) >
00089   GLUE_11 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00090     return arg_1 + arg_2;
00091   }
00092   
00093   static polynomial<mmx_modular(integer) >
00094   GLUE_12 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00095     return arg_1 - arg_2;
00096   }
00097   
00098   static polynomial<mmx_modular(integer) >
00099   GLUE_13 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00100     return arg_1 * arg_2;
00101   }
00102   
00103   static polynomial<mmx_modular(integer) >
00104   GLUE_14 (const mmx_modular(integer) &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00105     return arg_1 + arg_2;
00106   }
00107   
00108   static polynomial<mmx_modular(integer) >
00109   GLUE_15 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00110     return arg_1 + arg_2;
00111   }
00112   
00113   static polynomial<mmx_modular(integer) >
00114   GLUE_16 (const mmx_modular(integer) &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00115     return arg_1 - arg_2;
00116   }
00117   
00118   static polynomial<mmx_modular(integer) >
00119   GLUE_17 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00120     return arg_1 - arg_2;
00121   }
00122   
00123   static polynomial<mmx_modular(integer) >
00124   GLUE_18 (const mmx_modular(integer) &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00125     return arg_1 * arg_2;
00126   }
00127   
00128   static polynomial<mmx_modular(integer) >
00129   GLUE_19 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00130     return arg_1 * arg_2;
00131   }
00132   
00133   static polynomial<mmx_modular(integer) >
00134   GLUE_20 (const polynomial<mmx_modular(integer) > &arg_1, const int &arg_2) {
00135     return binpow (arg_1, arg_2);
00136   }
00137   
00138   static polynomial<mmx_modular(integer) >
00139   GLUE_21 (const polynomial<mmx_modular(integer) > &arg_1, const int &arg_2) {
00140     return lshiftz (arg_1, arg_2);
00141   }
00142   
00143   static polynomial<mmx_modular(integer) >
00144   GLUE_22 (const polynomial<mmx_modular(integer) > &arg_1, const int &arg_2) {
00145     return rshiftz (arg_1, arg_2);
00146   }
00147   
00148   static polynomial<mmx_modular(integer) >
00149   GLUE_23 (const polynomial<mmx_modular(integer) > &arg_1) {
00150     return derive (arg_1);
00151   }
00152   
00153   static polynomial<mmx_modular(integer) >
00154   GLUE_24 (const polynomial<mmx_modular(integer) > &arg_1) {
00155     return xderive (arg_1);
00156   }
00157   
00158   static mmx_modular(integer)
00159   GLUE_25 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00160     return evaluate (arg_1, arg_2);
00161   }
00162   
00163   static vector<mmx_modular(integer) >
00164   GLUE_26 (const polynomial<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) {
00165     return evaluate (arg_1, arg_2);
00166   }
00167   
00168   static mmx_modular(integer)
00169   GLUE_27 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00170     return evaluate (arg_1, arg_2);
00171   }
00172   
00173   static vector<mmx_modular(integer) >
00174   GLUE_28 (const polynomial<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) {
00175     return evaluate (arg_1, arg_2);
00176   }
00177   
00178   static polynomial<mmx_modular(integer) >
00179   GLUE_29 (const polynomial<integer> &arg_1, const modulus<integer> &arg_2) {
00180     return as_polynomial_modular (arg_1, arg_2);
00181   }
00182   
00183   static polynomial<mmx_modular(integer) >
00184   GLUE_30 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00185     return arg_1 / arg_2;
00186   }
00187   
00188   static polynomial<mmx_modular(integer) >
00189   GLUE_31 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00190     return arg_1 / arg_2;
00191   }
00192   
00193   static polynomial<mmx_modular(integer) >
00194   GLUE_32 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00195     return quo (arg_1, arg_2);
00196   }
00197   
00198   static polynomial<mmx_modular(integer) >
00199   GLUE_33 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00200     return rem (arg_1, arg_2);
00201   }
00202   
00203   static bool
00204   GLUE_34 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00205     return divides (arg_1, arg_2);
00206   }
00207   
00208   static polynomial<mmx_modular(integer) >
00209   GLUE_35 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2, const int &arg_3) {
00210     return subresultant (arg_1, arg_2, arg_3);
00211   }
00212   
00213   static vector<generic>
00214   GLUE_36 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00215     return wrap_subresultants (arg_1, arg_2);
00216   }
00217   
00218   static mmx_modular(integer)
00219   GLUE_37 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00220     return resultant (arg_1, arg_2);
00221   }
00222   
00223   static mmx_modular(integer)
00224   GLUE_38 (const polynomial<mmx_modular(integer) > &arg_1) {
00225     return discriminant (arg_1);
00226   }
00227   
00228   static polynomial<mmx_modular(integer) >
00229   GLUE_39 (const polynomial<mmx_modular(integer) > &arg_1) {
00230     return integrate (arg_1);
00231   }
00232   
00233   static polynomial<mmx_modular(integer) >
00234   GLUE_40 (const polynomial<mmx_modular(integer) > &arg_1, const polynomial<mmx_modular(integer) > &arg_2) {
00235     return compose (arg_1, arg_2);
00236   }
00237   
00238   static polynomial<mmx_modular(integer) >
00239   GLUE_41 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00240     return q_difference (arg_1, arg_2);
00241   }
00242   
00243   static polynomial<mmx_modular(integer) >
00244   GLUE_42 (const polynomial<mmx_modular(integer) > &arg_1, const int &arg_2) {
00245     return dilate (arg_1, arg_2);
00246   }
00247   
00248   static polynomial<mmx_modular(integer) >
00249   GLUE_43 (const vector<mmx_modular(integer) > &arg_1) {
00250     return annulator (arg_1);
00251   }
00252   
00253   static polynomial<mmx_modular(integer) >
00254   GLUE_44 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) {
00255     return interpolate (arg_1, arg_2);
00256   }
00257   
00258   static polynomial<mmx_modular(integer) >
00259   GLUE_45 (const polynomial<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) {
00260     return shift (arg_1, arg_2);
00261   }
00262   
00263   static polynomial<mmx_modular(integer) >
00264   GLUE_46 (const polynomial<mmx_modular(integer) > &arg_1) {
00265     return graeffe (arg_1);
00266   }
00267   
00268   static polynomial<generic>
00269   GLUE_47 (const polynomial<mmx_modular(integer) > &arg_1) {
00270     return as<polynomial<generic> > (arg_1);
00271   }
00272   
00273   void
00274   glue_polynomial_modular_integer () {
00275     static bool done = false;
00276     if (done) return;
00277     done = true;
00278     call_glue (string ("glue_vector_generic"));
00279     call_glue (string ("glue_vector_modular_integer"));
00280     call_glue (string ("glue_polynomial_integer"));
00281     define_type<polynomial<mmx_modular(integer) > > (gen (lit ("Polynomial"), gen (lit ("Modular"), lit ("Integer"))));
00282     define ("poly", GLUE_1);
00283     define ("polynomial", GLUE_2);
00284     define ("set_variable_name", GLUE_3);
00285     define_converter ("upgrade", GLUE_4, PENALTY_INCLUSION);
00286     define_converter (":>", GLUE_5, PENALTY_CAST);
00287     define ("#", GLUE_6);
00288     define ("deg", GLUE_7);
00289     define (".[]", GLUE_8);
00290     define ("-", GLUE_9);
00291     define ("square", GLUE_10);
00292     define ("+", GLUE_11);
00293     define ("-", GLUE_12);
00294     define ("*", GLUE_13);
00295     define ("+", GLUE_14);
00296     define ("+", GLUE_15);
00297     define ("-", GLUE_16);
00298     define ("-", GLUE_17);
00299     define ("*", GLUE_18);
00300     define ("*", GLUE_19);
00301     define ("^", GLUE_20);
00302     define ("<<", GLUE_21);
00303     define (">>", GLUE_22);
00304     define ("derive", GLUE_23);
00305     define ("xderive", GLUE_24);
00306     define ("eval", GLUE_25);
00307     define ("eval", GLUE_26);
00308     define ("evaluate", GLUE_27);
00309     define ("evaluate", GLUE_28);
00310     define ("mod", GLUE_29);
00311     define ("/", GLUE_30);
00312     define ("div", GLUE_31);
00313     define ("quo", GLUE_32);
00314     define ("rem", GLUE_33);
00315     define ("divides?", GLUE_34);
00316     define ("subresultant", GLUE_35);
00317     define ("subresultants", GLUE_36);
00318     define ("resultant", GLUE_37);
00319     define ("discriminant", GLUE_38);
00320     define ("integrate", GLUE_39);
00321     define ("@", GLUE_40);
00322     define ("q_difference", GLUE_41);
00323     define ("dilate", GLUE_42);
00324     define ("annulator", GLUE_43);
00325     define ("interpolate", GLUE_44);
00326     define ("shift", GLUE_45);
00327     define ("graeffe", GLUE_46);
00328     define_converter (":>", GLUE_47, PENALTY_PROMOTE_GENERIC);
00329   }
00330 }
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines