algebramix_doc 0.3
|
00001 00002 #include <numerix/integer.hpp> 00003 #include <basix/int.hpp> 00004 #include <numerix/modular.hpp> 00005 #include <numerix/modular_integer.hpp> 00006 #include <basix/vector.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 <numerix/rational.hpp> 00017 #include <algebramix/series.hpp> 00018 #include <algebramix/series_elementary.hpp> 00019 #include <algebramix/series_integer.hpp> 00020 #include <algebramix/series_rational.hpp> 00021 #include <algebramix/series_modular_integer.hpp> 00022 #include <algebramix/series_sugar.hpp> 00023 #include <basix/tuple.hpp> 00024 #include <basix/routine.hpp> 00025 #include <basix/glue.hpp> 00026 00027 #define int_literal(x) as_int (as_string (x)) 00028 namespace mmx { 00029 template<typename C> polynomial<C> 00030 polynomial_reverse (const vector<C>& v) { 00031 return polynomial<C> (reverse (v)); } 00032 00033 template<typename C> polynomial<modular<modulus<C>, modular_local> > 00034 as_polynomial_modular (const polynomial<C>& f, const modulus<C>& p) { 00035 modular<modulus<C>, modular_local>::set_modulus (p); 00036 return as<polynomial<modular<modulus<C>, modular_local> > > (f); } 00037 00038 template<typename C> vector<generic> 00039 wrap_subresultants (const polynomial<C>& f, const polynomial<C>& g) { 00040 return as<vector<generic> > (subresultants (f, g)); } 00041 00042 } 00043 namespace mmx { POLYNOMIAL_GENERIC_USES_SCHONHAGE } 00044 #define series_shift_default(s,sh) shift (s, sh, mmx_bit_precision) 00045 00046 namespace mmx { 00047 static generic 00048 GLUE_1 (const integer &arg_1, const integer &arg_2) { 00049 return integer_pow (arg_1, arg_2); 00050 } 00051 00052 static series<generic> 00053 GLUE_2 (const series<generic> &arg_1, const integer &arg_2) { 00054 return binpow (arg_1, arg_2); 00055 } 00056 00057 static void 00058 GLUE_3 (const series<mmx_modular(integer) > &arg_1, const generic &arg_2) { 00059 set_variable_name (arg_1, arg_2); 00060 } 00061 00062 static void 00063 GLUE_4 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00064 set_output_order (arg_1, arg_2); 00065 } 00066 00067 static void 00068 GLUE_5 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00069 set_cancel_order (arg_1, arg_2); 00070 } 00071 00072 static void 00073 GLUE_6 (const series<mmx_modular(integer) > &arg_1, const bool &arg_2) { 00074 set_formula_output (arg_1, arg_2); 00075 } 00076 00077 static series<mmx_modular(integer) > 00078 GLUE_7 (const tuple<mmx_modular(integer) > &arg_1) { 00079 return series<mmx_modular(integer) > (as_vector (arg_1)); 00080 } 00081 00082 static series<mmx_modular(integer) > 00083 GLUE_8 (const mmx_modular(integer) &arg_1) { 00084 return series<mmx_modular(integer) > (arg_1); 00085 } 00086 00087 static series<mmx_modular(integer) > 00088 GLUE_9 (const polynomial<mmx_modular(integer) > &arg_1) { 00089 return series<mmx_modular(integer) > (arg_1); 00090 } 00091 00092 static iterator<generic> 00093 GLUE_10 (const series<mmx_modular(integer) > &arg_1) { 00094 return as<iterator<generic> > (iterate (arg_1)); 00095 } 00096 00097 static mmx_modular(integer) 00098 GLUE_11 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00099 return arg_1[arg_2]; 00100 } 00101 00102 static polynomial<mmx_modular(integer) > 00103 GLUE_12 (const series<mmx_modular(integer) > &arg_1, const int &arg_2, const int &arg_3) { 00104 return range (arg_1, arg_2, arg_3); 00105 } 00106 00107 static series<mmx_modular(integer) > 00108 GLUE_13 (const series<mmx_modular(integer) > &arg_1) { 00109 return -arg_1; 00110 } 00111 00112 static series<mmx_modular(integer) > 00113 GLUE_14 (const series<mmx_modular(integer) > &arg_1) { 00114 return square (arg_1); 00115 } 00116 00117 static series<mmx_modular(integer) > 00118 GLUE_15 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00119 return arg_1 + arg_2; 00120 } 00121 00122 static series<mmx_modular(integer) > 00123 GLUE_16 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00124 return arg_1 - arg_2; 00125 } 00126 00127 static series<mmx_modular(integer) > 00128 GLUE_17 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00129 return arg_1 * arg_2; 00130 } 00131 00132 static series<mmx_modular(integer) > 00133 GLUE_18 (const mmx_modular(integer) &arg_1, const series<mmx_modular(integer) > &arg_2) { 00134 return arg_1 + arg_2; 00135 } 00136 00137 static series<mmx_modular(integer) > 00138 GLUE_19 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00139 return arg_1 + arg_2; 00140 } 00141 00142 static series<mmx_modular(integer) > 00143 GLUE_20 (const mmx_modular(integer) &arg_1, const series<mmx_modular(integer) > &arg_2) { 00144 return arg_1 - arg_2; 00145 } 00146 00147 static series<mmx_modular(integer) > 00148 GLUE_21 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00149 return arg_1 - arg_2; 00150 } 00151 00152 static series<mmx_modular(integer) > 00153 GLUE_22 (const mmx_modular(integer) &arg_1, const series<mmx_modular(integer) > &arg_2) { 00154 return arg_1 * arg_2; 00155 } 00156 00157 static series<mmx_modular(integer) > 00158 GLUE_23 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00159 return arg_1 * arg_2; 00160 } 00161 00162 static series<mmx_modular(integer) > 00163 GLUE_24 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00164 return binpow (arg_1, arg_2); 00165 } 00166 00167 static series<mmx_modular(integer) > 00168 GLUE_25 (const series<mmx_modular(integer) > &arg_1, const integer &arg_2) { 00169 return binpow (arg_1, arg_2); 00170 } 00171 00172 static series<mmx_modular(integer) > 00173 GLUE_26 (const series<mmx_modular(integer) > &arg_1) { 00174 return derive (arg_1); 00175 } 00176 00177 static series<mmx_modular(integer) > 00178 GLUE_27 (const series<mmx_modular(integer) > &arg_1) { 00179 return xderive (arg_1); 00180 } 00181 00182 static series<mmx_modular(integer) > 00183 GLUE_28 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00184 return dilate (arg_1, arg_2); 00185 } 00186 00187 static series<mmx_modular(integer) > 00188 GLUE_29 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00189 return lshiftz (arg_1, arg_2); 00190 } 00191 00192 static series<mmx_modular(integer) > 00193 GLUE_30 (const series<mmx_modular(integer) > &arg_1, const int &arg_2) { 00194 return rshiftz (arg_1, arg_2); 00195 } 00196 00197 static series<mmx_modular(integer) > 00198 GLUE_31 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00199 return arg_1 / arg_2; 00200 } 00201 00202 static series<mmx_modular(integer) > 00203 GLUE_32 (const mmx_modular(integer) &arg_1, const series<mmx_modular(integer) > &arg_2) { 00204 return arg_1 / arg_2; 00205 } 00206 00207 static series<mmx_modular(integer) > 00208 GLUE_33 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00209 return arg_1 / arg_2; 00210 } 00211 00212 static series<mmx_modular(integer) > 00213 GLUE_34 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00214 return arg_1 / arg_2; 00215 } 00216 00217 static bool 00218 GLUE_35 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00219 return divides (arg_1, arg_2); 00220 } 00221 00222 static series<mmx_modular(integer) > 00223 GLUE_36 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00224 return gcd (arg_1, arg_2); 00225 } 00226 00227 static series<mmx_modular(integer) > 00228 GLUE_37 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00229 return lcm (arg_1, arg_2); 00230 } 00231 00232 static series<mmx_modular(integer) > 00233 GLUE_38 (const series<mmx_modular(integer) > &arg_1) { 00234 return integrate (arg_1); 00235 } 00236 00237 static series<mmx_modular(integer) > 00238 GLUE_39 (const series<mmx_modular(integer) > &arg_1, const series<mmx_modular(integer) > &arg_2) { 00239 return compose (arg_1, arg_2); 00240 } 00241 00242 static series<mmx_modular(integer) > 00243 GLUE_40 (const series<mmx_modular(integer) > &arg_1) { 00244 return reverse (arg_1); 00245 } 00246 00247 static series<mmx_modular(integer) > 00248 GLUE_41 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00249 return q_difference (arg_1, arg_2); 00250 } 00251 00252 static series<mmx_modular(integer) > 00253 GLUE_42 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00254 return series_shift_default (arg_1, arg_2); 00255 } 00256 00257 static series<mmx_modular(integer) > 00258 GLUE_43 (const series<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2, const int &arg_3) { 00259 return shift (arg_1, arg_2, arg_3); 00260 } 00261 00262 static series<generic> 00263 GLUE_44 (const series<mmx_modular(integer) > &arg_1) { 00264 return as<series<generic> > (arg_1); 00265 } 00266 00267 static series<mmx_modular(integer) > 00268 GLUE_45 (const routine &arg_1, const mmx_modular(integer) &arg_2) { 00269 return fixed_point_series (arg_1, arg_2); 00270 } 00271 00272 static vector<generic> 00273 GLUE_46 (const routine &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00274 return gen_fixed_point_vector_series (arg_1, arg_2); 00275 } 00276 00277 static series<mmx_modular(integer) > 00278 GLUE_47 (const routine &arg_1, const mmx_modular(integer) &arg_2) { 00279 return integrate_series (arg_1, arg_2); 00280 } 00281 00282 static vector<generic> 00283 GLUE_48 (const routine &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00284 return gen_integrate_vector_series (arg_1, arg_2); 00285 } 00286 00287 static series<mmx_modular(integer) > 00288 GLUE_49 (const routine &arg_1, const mmx_modular(integer) &arg_2) { 00289 return implicit_series (arg_1, arg_2); 00290 } 00291 00292 static vector<generic> 00293 GLUE_50 (const routine &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00294 return gen_implicit_vector_series (arg_1, arg_2); 00295 } 00296 00297 void 00298 glue_series_modular_integer () { 00299 static bool done = false; 00300 if (done) return; 00301 done = true; 00302 call_glue (string ("glue_integer")); 00303 call_glue (string ("glue_modular_integer")); 00304 call_glue (string ("glue_polynomial_modular_integer")); 00305 call_glue (string ("glue_series_generic")); 00306 define ("^", GLUE_1); 00307 define ("^", GLUE_2); 00308 define_type<series<mmx_modular(integer) > > (gen (lit ("Series"), gen (lit ("Modular"), lit ("Integer")))); 00309 define ("set_variable_name", GLUE_3); 00310 define ("set_output_order", GLUE_4); 00311 define ("set_cancel_order", GLUE_5); 00312 define ("set_formula_output", GLUE_6); 00313 define ("series", GLUE_7); 00314 define_converter ("upgrade", GLUE_8, PENALTY_INCLUSION); 00315 define_converter ("upgrade", GLUE_9, PENALTY_INCLUSION); 00316 define_converter (":>", GLUE_10, PENALTY_CAST); 00317 define (".[]", GLUE_11); 00318 define (".[]", GLUE_12); 00319 define ("-", GLUE_13); 00320 define ("square", GLUE_14); 00321 define ("+", GLUE_15); 00322 define ("-", GLUE_16); 00323 define ("*", GLUE_17); 00324 define ("+", GLUE_18); 00325 define ("+", GLUE_19); 00326 define ("-", GLUE_20); 00327 define ("-", GLUE_21); 00328 define ("*", GLUE_22); 00329 define ("*", GLUE_23); 00330 define ("^", GLUE_24); 00331 define ("^", GLUE_25); 00332 define ("derive", GLUE_26); 00333 define ("xderive", GLUE_27); 00334 define ("dilate", GLUE_28); 00335 define ("<<", GLUE_29); 00336 define (">>", GLUE_30); 00337 define ("/", GLUE_31); 00338 define ("/", GLUE_32); 00339 define ("/", GLUE_33); 00340 define ("div", GLUE_34); 00341 define ("divides?", GLUE_35); 00342 define ("gcd", GLUE_36); 00343 define ("lcm", GLUE_37); 00344 define ("integrate", GLUE_38); 00345 define ("@", GLUE_39); 00346 define ("reverse", GLUE_40); 00347 define ("q_difference", GLUE_41); 00348 define ("shift", GLUE_42); 00349 define ("shift", GLUE_43); 00350 define_converter (":>", GLUE_44, PENALTY_PROMOTE_GENERIC); 00351 define ("fixed_point_series", GLUE_45); 00352 define ("fixed_point_series", GLUE_46); 00353 define ("integrate_series", GLUE_47); 00354 define ("integrate_series", GLUE_48); 00355 define ("implicit_series", GLUE_49); 00356 define ("implicit_series", GLUE_50); 00357 } 00358 }