algebramix_doc 0.3
/Users/mourrain/Devel/mmx/algebramix/glue/glue_series_integer.cpp
Go to the documentation of this file.
00001 
00002 #include <numerix/integer.hpp>
00003 #include <basix/vector.hpp>
00004 #include <algebramix/polynomial.hpp>
00005 #include <algebramix/polynomial_polynomial.hpp>
00006 #include <algebramix/polynomial_integer.hpp>
00007 #include <algebramix/polynomial_schonhage.hpp>
00008 #include <numerix/rational.hpp>
00009 #include <algebramix/series.hpp>
00010 #include <algebramix/series_elementary.hpp>
00011 #include <algebramix/series_integer.hpp>
00012 #include <algebramix/series_rational.hpp>
00013 #include <algebramix/series_sugar.hpp>
00014 #include <basix/tuple.hpp>
00015 #include <basix/glue.hpp>
00016 
00017 namespace mmx {
00018     template<typename C> polynomial<C>
00019     polynomial_reverse (const vector<C>& v) {
00020       return polynomial<C> (reverse (v)); }
00021 
00022     template<typename C> polynomial<modular<modulus<C>, modular_local> >
00023     as_polynomial_modular (const polynomial<C>& f, const modulus<C>& p) {
00024       modular<modulus<C>, modular_local>::set_modulus (p);
00025       return as<polynomial<modular<modulus<C>, modular_local> > > (f); }
00026 
00027     template<typename C> vector<generic>
00028     wrap_subresultants (const polynomial<C>& f, const polynomial<C>& g) {
00029       return as<vector<generic> > (subresultants (f, g)); }
00030 
00031   }
00032 namespace mmx { POLYNOMIAL_GENERIC_USES_SCHONHAGE }
00033 #define series_shift_default(s,sh) shift (s, sh, mmx_bit_precision)
00034 
00035 namespace mmx {
00036   static generic
00037   GLUE_1 (const integer &arg_1, const integer &arg_2) {
00038     return integer_pow (arg_1, arg_2);
00039   }
00040   
00041   static void
00042   GLUE_2 (const series<integer> &arg_1, const generic &arg_2) {
00043     set_variable_name (arg_1, arg_2);
00044   }
00045   
00046   static void
00047   GLUE_3 (const series<integer> &arg_1, const int &arg_2) {
00048     set_output_order (arg_1, arg_2);
00049   }
00050   
00051   static void
00052   GLUE_4 (const series<integer> &arg_1, const int &arg_2) {
00053     set_cancel_order (arg_1, arg_2);
00054   }
00055   
00056   static void
00057   GLUE_5 (const series<integer> &arg_1, const bool &arg_2) {
00058     set_formula_output (arg_1, arg_2);
00059   }
00060   
00061   static series<integer>
00062   GLUE_6 (const tuple<integer> &arg_1) {
00063     return series<integer > (as_vector (arg_1));
00064   }
00065   
00066   static series<integer>
00067   GLUE_7 (const integer &arg_1) {
00068     return series<integer > (arg_1);
00069   }
00070   
00071   static series<integer>
00072   GLUE_8 (const polynomial<integer> &arg_1) {
00073     return series<integer > (arg_1);
00074   }
00075   
00076   static iterator<generic>
00077   GLUE_9 (const series<integer> &arg_1) {
00078     return as<iterator<generic> > (iterate (arg_1));
00079   }
00080   
00081   static integer
00082   GLUE_10 (const series<integer> &arg_1, const int &arg_2) {
00083     return arg_1[arg_2];
00084   }
00085   
00086   static polynomial<integer>
00087   GLUE_11 (const series<integer> &arg_1, const int &arg_2, const int &arg_3) {
00088     return range (arg_1, arg_2, arg_3);
00089   }
00090   
00091   static series<integer>
00092   GLUE_12 (const series<integer> &arg_1) {
00093     return -arg_1;
00094   }
00095   
00096   static series<integer>
00097   GLUE_13 (const series<integer> &arg_1) {
00098     return square (arg_1);
00099   }
00100   
00101   static series<integer>
00102   GLUE_14 (const series<integer> &arg_1, const series<integer> &arg_2) {
00103     return arg_1 + arg_2;
00104   }
00105   
00106   static series<integer>
00107   GLUE_15 (const series<integer> &arg_1, const series<integer> &arg_2) {
00108     return arg_1 - arg_2;
00109   }
00110   
00111   static series<integer>
00112   GLUE_16 (const series<integer> &arg_1, const series<integer> &arg_2) {
00113     return arg_1 * arg_2;
00114   }
00115   
00116   static series<integer>
00117   GLUE_17 (const integer &arg_1, const series<integer> &arg_2) {
00118     return arg_1 + arg_2;
00119   }
00120   
00121   static series<integer>
00122   GLUE_18 (const series<integer> &arg_1, const integer &arg_2) {
00123     return arg_1 + arg_2;
00124   }
00125   
00126   static series<integer>
00127   GLUE_19 (const integer &arg_1, const series<integer> &arg_2) {
00128     return arg_1 - arg_2;
00129   }
00130   
00131   static series<integer>
00132   GLUE_20 (const series<integer> &arg_1, const integer &arg_2) {
00133     return arg_1 - arg_2;
00134   }
00135   
00136   static series<integer>
00137   GLUE_21 (const integer &arg_1, const series<integer> &arg_2) {
00138     return arg_1 * arg_2;
00139   }
00140   
00141   static series<integer>
00142   GLUE_22 (const series<integer> &arg_1, const integer &arg_2) {
00143     return arg_1 * arg_2;
00144   }
00145   
00146   static series<integer>
00147   GLUE_23 (const series<integer> &arg_1, const int &arg_2) {
00148     return binpow (arg_1, arg_2);
00149   }
00150   
00151   static series<integer>
00152   GLUE_24 (const series<integer> &arg_1, const integer &arg_2) {
00153     return binpow (arg_1, arg_2);
00154   }
00155   
00156   static series<integer>
00157   GLUE_25 (const series<integer> &arg_1) {
00158     return derive (arg_1);
00159   }
00160   
00161   static series<integer>
00162   GLUE_26 (const series<integer> &arg_1) {
00163     return xderive (arg_1);
00164   }
00165   
00166   static series<integer>
00167   GLUE_27 (const series<integer> &arg_1, const int &arg_2) {
00168     return dilate (arg_1, arg_2);
00169   }
00170   
00171   static series<integer>
00172   GLUE_28 (const series<integer> &arg_1, const int &arg_2) {
00173     return lshiftz (arg_1, arg_2);
00174   }
00175   
00176   static series<integer>
00177   GLUE_29 (const series<integer> &arg_1, const int &arg_2) {
00178     return rshiftz (arg_1, arg_2);
00179   }
00180   
00181   static series<generic>
00182   GLUE_30 (const series<generic> &arg_1, const integer &arg_2) {
00183     return binpow (arg_1, arg_2);
00184   }
00185   
00186   static bool
00187   GLUE_31 (const series<integer> &arg_1, const series<integer> &arg_2) {
00188     return arg_1 <= arg_2;
00189   }
00190   
00191   static bool
00192   GLUE_32 (const series<integer> &arg_1, const series<integer> &arg_2) {
00193     return arg_1 >= arg_2;
00194   }
00195   
00196   static bool
00197   GLUE_33 (const series<integer> &arg_1, const series<integer> &arg_2) {
00198     return arg_1 < arg_2;
00199   }
00200   
00201   static bool
00202   GLUE_34 (const series<integer> &arg_1, const series<integer> &arg_2) {
00203     return arg_1 > arg_2;
00204   }
00205   
00206   static series<generic>
00207   GLUE_35 (const series<integer> &arg_1) {
00208     return as<series<generic> > (arg_1);
00209   }
00210   
00211   void
00212   glue_series_integer () {
00213     static bool done = false;
00214     if (done) return;
00215     done = true;
00216     call_glue (string ("glue_polynomial_integer"));
00217     call_glue (string ("glue_series_generic"));
00218     define ("^", GLUE_1);
00219     define_type<series<integer> > (gen (lit ("Series"), lit ("Integer")));
00220     define ("set_variable_name", GLUE_2);
00221     define ("set_output_order", GLUE_3);
00222     define ("set_cancel_order", GLUE_4);
00223     define ("set_formula_output", GLUE_5);
00224     define ("series", GLUE_6);
00225     define_converter ("upgrade", GLUE_7, PENALTY_INCLUSION);
00226     define_converter ("upgrade", GLUE_8, PENALTY_INCLUSION);
00227     define_converter (":>", GLUE_9, PENALTY_CAST);
00228     define (".[]", GLUE_10);
00229     define (".[]", GLUE_11);
00230     define ("-", GLUE_12);
00231     define ("square", GLUE_13);
00232     define ("+", GLUE_14);
00233     define ("-", GLUE_15);
00234     define ("*", GLUE_16);
00235     define ("+", GLUE_17);
00236     define ("+", GLUE_18);
00237     define ("-", GLUE_19);
00238     define ("-", GLUE_20);
00239     define ("*", GLUE_21);
00240     define ("*", GLUE_22);
00241     define ("^", GLUE_23);
00242     define ("^", GLUE_24);
00243     define ("derive", GLUE_25);
00244     define ("xderive", GLUE_26);
00245     define ("dilate", GLUE_27);
00246     define ("<<", GLUE_28);
00247     define (">>", GLUE_29);
00248     define ("^", GLUE_30);
00249     define ("<=", GLUE_31);
00250     define (">=", GLUE_32);
00251     define ("<", GLUE_33);
00252     define (">", GLUE_34);
00253     define_converter (":>", GLUE_35, PENALTY_PROMOTE_GENERIC);
00254   }
00255 }
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines