00001 00002 #include <basix/int.hpp> 00003 #include <basix/vector.hpp> 00004 #include <basix/port.hpp> 00005 #include <basix/literal.hpp> 00006 #include <numerix/integer.hpp> 00007 #include <numerix/modular.hpp> 00008 #include <numerix/modular_integer.hpp> 00009 #include <algebramix/vector_unrolled.hpp> 00010 #include <algebramix/vector_simd.hpp> 00011 #include <algebramix/vector_modular.hpp> 00012 #include <basix/tuple.hpp> 00013 #include <basix/alias.hpp> 00014 #include <basix/glue.hpp> 00015 00016 #define int_literal(x) as_int (as_string (x)) 00017 #define is_generic_literal is<literal> 00018 #define gen_literal_apply(f,v) gen (as<generic> (f), v) 00019 #define gen_literal_access(f,v) access (as<generic> (f), v) 00020 00021 namespace mmx { 00022 static vector<mmx_modular(integer) > 00023 GLUE_1 (const tuple<mmx_modular(integer) > &arg_1) { 00024 return vector<mmx_modular(integer) > (as_vector (arg_1)); 00025 } 00026 00027 static vector<mmx_modular(integer) > 00028 GLUE_2 (const tuple<mmx_modular(integer) > &arg_1) { 00029 return vector<mmx_modular(integer) > (as_vector (arg_1)); 00030 } 00031 00032 static iterator<generic> 00033 GLUE_3 (const vector<mmx_modular(integer) > &arg_1) { 00034 return as<iterator<generic> > (iterate (arg_1)); 00035 } 00036 00037 static int 00038 GLUE_4 (const vector<mmx_modular(integer) > &arg_1) { 00039 return N (arg_1); 00040 } 00041 00042 static mmx_modular(integer) 00043 GLUE_5 (const vector<mmx_modular(integer) > &arg_1, const int &arg_2) { 00044 return arg_1[arg_2]; 00045 } 00046 00047 static alias<mmx_modular(integer) > 00048 GLUE_6 (const alias<vector<mmx_modular(integer) > > &arg_1, const int &arg_2) { 00049 return alias_access<mmx_modular(integer) > (arg_1, arg_2); 00050 } 00051 00052 static vector<mmx_modular(integer) > 00053 GLUE_7 (const vector<mmx_modular(integer) > &arg_1, const int &arg_2, const int &arg_3) { 00054 return range (arg_1, arg_2, arg_3); 00055 } 00056 00057 static vector<mmx_modular(integer) > 00058 GLUE_8 (const vector<mmx_modular(integer) > &arg_1) { 00059 return reverse (arg_1); 00060 } 00061 00062 static vector<mmx_modular(integer) > 00063 GLUE_9 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00064 return append (arg_1, arg_2); 00065 } 00066 00067 static alias<vector<mmx_modular(integer) > > 00068 GLUE_10 (const alias<vector<mmx_modular(integer) > > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00069 return alias_write (arg_1, arg_2); 00070 } 00071 00072 static vector<mmx_modular(integer) > 00073 GLUE_11 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00074 return cons (arg_1, arg_2); 00075 } 00076 00077 static mmx_modular(integer) 00078 GLUE_12 (const vector<mmx_modular(integer) > &arg_1) { 00079 return car (arg_1); 00080 } 00081 00082 static vector<mmx_modular(integer) > 00083 GLUE_13 (const vector<mmx_modular(integer) > &arg_1) { 00084 return cdr (arg_1); 00085 } 00086 00087 static bool 00088 GLUE_14 (const vector<mmx_modular(integer) > &arg_1) { 00089 return is_nil (arg_1); 00090 } 00091 00092 static bool 00093 GLUE_15 (const vector<mmx_modular(integer) > &arg_1) { 00094 return is_atom (arg_1); 00095 } 00096 00097 static vector<mmx_modular(integer) > 00098 GLUE_16 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00099 return insert (arg_1, arg_2); 00100 } 00101 00102 static int 00103 GLUE_17 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00104 return find (arg_1, arg_2); 00105 } 00106 00107 static bool 00108 GLUE_18 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00109 return contains (arg_1, arg_2); 00110 } 00111 00112 static vector<generic> 00113 GLUE_19 (const vector<mmx_modular(integer) > &arg_1) { 00114 return as<vector<generic> > (arg_1); 00115 } 00116 00117 static vector<mmx_modular(integer) > 00118 GLUE_20 (const vector<mmx_modular(integer) > &arg_1) { 00119 return -arg_1; 00120 } 00121 00122 static vector<mmx_modular(integer) > 00123 GLUE_21 (const vector<mmx_modular(integer) > &arg_1) { 00124 return square (arg_1); 00125 } 00126 00127 static vector<mmx_modular(integer) > 00128 GLUE_22 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00129 return arg_1 + arg_2; 00130 } 00131 00132 static vector<mmx_modular(integer) > 00133 GLUE_23 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00134 return arg_1 - arg_2; 00135 } 00136 00137 static vector<mmx_modular(integer) > 00138 GLUE_24 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00139 return arg_1 * arg_2; 00140 } 00141 00142 static vector<mmx_modular(integer) > 00143 GLUE_25 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00144 return arg_1 + arg_2; 00145 } 00146 00147 static vector<mmx_modular(integer) > 00148 GLUE_26 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00149 return arg_1 + arg_2; 00150 } 00151 00152 static vector<mmx_modular(integer) > 00153 GLUE_27 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00154 return arg_1 - arg_2; 00155 } 00156 00157 static vector<mmx_modular(integer) > 00158 GLUE_28 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00159 return arg_1 - arg_2; 00160 } 00161 00162 static vector<mmx_modular(integer) > 00163 GLUE_29 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00164 return arg_1 * arg_2; 00165 } 00166 00167 static vector<mmx_modular(integer) > 00168 GLUE_30 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00169 return arg_1 * arg_2; 00170 } 00171 00172 static mmx_modular(integer) 00173 GLUE_31 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00174 return dot (arg_1, arg_2); 00175 } 00176 00177 static mmx_modular(integer) 00178 GLUE_32 (const vector<mmx_modular(integer) > &arg_1) { 00179 return big_mul (arg_1); 00180 } 00181 00182 static mmx_modular(integer) 00183 GLUE_33 (const vector<mmx_modular(integer) > &arg_1) { 00184 return big_add (arg_1); 00185 } 00186 00187 static bool 00188 GLUE_34 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00189 return arg_1 == arg_2; 00190 } 00191 00192 static bool 00193 GLUE_35 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00194 return arg_1 != arg_2; 00195 } 00196 00197 static bool 00198 GLUE_36 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00199 return arg_1 == arg_2; 00200 } 00201 00202 static bool 00203 GLUE_37 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00204 return arg_1 != arg_2; 00205 } 00206 00207 static bool 00208 GLUE_38 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00209 return arg_1 == arg_2; 00210 } 00211 00212 static bool 00213 GLUE_39 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00214 return arg_1 != arg_2; 00215 } 00216 00217 static vector<mmx_modular(integer) > 00218 GLUE_40 (const vector<mmx_modular(integer) > &arg_1) { 00219 return invert (arg_1); 00220 } 00221 00222 static vector<mmx_modular(integer) > 00223 GLUE_41 (const vector<mmx_modular(integer) > &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00224 return arg_1 / arg_2; 00225 } 00226 00227 static vector<mmx_modular(integer) > 00228 GLUE_42 (const mmx_modular(integer) &arg_1, const vector<mmx_modular(integer) > &arg_2) { 00229 return arg_1 / arg_2; 00230 } 00231 00232 static vector<mmx_modular(integer) > 00233 GLUE_43 (const vector<mmx_modular(integer) > &arg_1, const mmx_modular(integer) &arg_2) { 00234 return arg_1 / arg_2; 00235 } 00236 00237 void 00238 glue_vector_modular_integer () { 00239 static bool done = false; 00240 if (done) return; 00241 done = true; 00242 call_glue (string ("glue_modular_integer")); 00243 call_glue (string ("glue_vector_integer")); 00244 define_type<vector<mmx_modular(integer) > > (gen (lit ("Vector"), gen (lit ("Modular"), lit ("Integer")))); 00245 define ("vector", GLUE_1); 00246 define ("[]", GLUE_2); 00247 define_converter (":>", GLUE_3, PENALTY_CAST); 00248 define ("#", GLUE_4); 00249 define (".[]", GLUE_5); 00250 define (".[]", GLUE_6); 00251 define (".[]", GLUE_7); 00252 define ("reverse", GLUE_8); 00253 define ("><", GLUE_9); 00254 define ("<<", GLUE_10); 00255 define ("cons", GLUE_11); 00256 define ("car", GLUE_12); 00257 define ("cdr", GLUE_13); 00258 define ("nil?", GLUE_14); 00259 define ("atom?", GLUE_15); 00260 define ("insert", GLUE_16); 00261 define ("find", GLUE_17); 00262 define ("contains?", GLUE_18); 00263 define_converter (":>", GLUE_19, PENALTY_PROMOTE_GENERIC); 00264 define ("-", GLUE_20); 00265 define ("square", GLUE_21); 00266 define ("+", GLUE_22); 00267 define ("-", GLUE_23); 00268 define ("*", GLUE_24); 00269 define ("+", GLUE_25); 00270 define ("+", GLUE_26); 00271 define ("-", GLUE_27); 00272 define ("-", GLUE_28); 00273 define ("*", GLUE_29); 00274 define ("*", GLUE_30); 00275 define ("dot", GLUE_31); 00276 define ("big_mul", GLUE_32); 00277 define ("big_add", GLUE_33); 00278 define ("=", GLUE_34); 00279 define ("!=", GLUE_35); 00280 define ("=", GLUE_36); 00281 define ("!=", GLUE_37); 00282 define ("=", GLUE_38); 00283 define ("!=", GLUE_39); 00284 define ("invert", GLUE_40); 00285 define ("/", GLUE_41); 00286 define ("/", GLUE_42); 00287 define ("/", GLUE_43); 00288 } 00289 }