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