00001 00002 #include <basix/int.hpp> 00003 #include <basix/vector.hpp> 00004 #include <multimix/multivariate_coordinates.hpp> 00005 #include <basix/port.hpp> 00006 #include <basix/literal.hpp> 00007 #include <numerix/integer.hpp> 00008 #include <multimix/multivariate_monomial.hpp> 00009 #include <basix/alias.hpp> 00010 #include <basix/tuple.hpp> 00011 #include <basix/glue.hpp> 00012 00013 #define int_literal(x) as_int (as_string (x)) 00014 #define mmx_coordinate multivariate_coordinate<> 00015 #define mmx_coordinates multivariate_coordinates<> 00016 #define is_generic_literal is<literal> 00017 #define gen_literal_apply(f,v) gen (as<generic> (f), v) 00018 #define gen_literal_access(f,v) access (as<generic> (f), v) 00019 #define lmv_monomial multivariate<monomial<vector<integer> > > 00020 00021 namespace mmx { 00022 static bool 00023 GLUE_1 (const generic &arg_1) { 00024 return generic_is_string (arg_1); 00025 } 00026 00027 static int 00028 GLUE_2 (const string &arg_1) { 00029 return N (arg_1); 00030 } 00031 00032 static string 00033 GLUE_3 (const string &arg_1, const int &arg_2, const int &arg_3) { 00034 return arg_1 (arg_2, arg_3); 00035 } 00036 00037 static string 00038 GLUE_4 (const string &arg_1, const string &arg_2) { 00039 return arg_1 * arg_2; 00040 } 00041 00042 static string 00043 GLUE_5 (const string &arg_1, const string &arg_2) { 00044 return arg_1 * arg_2; 00045 } 00046 00047 static alias<string> 00048 GLUE_6 (const alias<string> &arg_1, const string &arg_2) { 00049 return alias_write (arg_1, arg_2); 00050 } 00051 00052 static bool 00053 GLUE_7 (const string &arg_1, const string &arg_2) { 00054 return arg_1 < arg_2; 00055 } 00056 00057 static bool 00058 GLUE_8 (const string &arg_1, const string &arg_2) { 00059 return arg_1 <= arg_2; 00060 } 00061 00062 static bool 00063 GLUE_9 (const string &arg_1, const string &arg_2) { 00064 return arg_1 > arg_2; 00065 } 00066 00067 static bool 00068 GLUE_10 (const string &arg_1, const string &arg_2) { 00069 return arg_1 >= arg_2; 00070 } 00071 00072 static bool 00073 GLUE_11 (const string &arg_1, const string &arg_2) { 00074 return starts (arg_1, arg_2); 00075 } 00076 00077 static bool 00078 GLUE_12 (const string &arg_1, const string &arg_2) { 00079 return ends (arg_1, arg_2); 00080 } 00081 00082 static string 00083 GLUE_13 (const string &arg_1, const string &arg_2, const string &arg_3) { 00084 return replace (arg_1, arg_2, arg_3); 00085 } 00086 00087 static int 00088 GLUE_14 (const string &arg_1, const string &arg_2, const int &arg_3) { 00089 return search_forwards (arg_1, arg_2, arg_3); 00090 } 00091 00092 static int 00093 GLUE_15 (const string &arg_1, const string &arg_2, const int &arg_3) { 00094 return search_backwards (arg_1, arg_2, arg_3); 00095 } 00096 00097 static string 00098 GLUE_16 (const string &arg_1) { 00099 return upcase (arg_1); 00100 } 00101 00102 static string 00103 GLUE_17 (const string &arg_1) { 00104 return locase (arg_1); 00105 } 00106 00107 static string 00108 GLUE_18 (const string &arg_1) { 00109 return upcase_first (arg_1); 00110 } 00111 00112 static string 00113 GLUE_19 (const string &arg_1) { 00114 return locase_first (arg_1); 00115 } 00116 00117 static string 00118 GLUE_20 (const string &arg_1) { 00119 return quote (arg_1); 00120 } 00121 00122 static string 00123 GLUE_21 (const string &arg_1) { 00124 return unquote (arg_1); 00125 } 00126 00127 static string 00128 GLUE_22 (const int &arg_1) { 00129 return charcode_as_string (arg_1); 00130 } 00131 00132 static int 00133 GLUE_23 (const string &arg_1) { 00134 return string_as_charcode (arg_1); 00135 } 00136 00137 static bool 00138 GLUE_24 (const string &arg_1) { 00139 return is_integer_string (arg_1); 00140 } 00141 00142 static bool 00143 GLUE_25 (const string &arg_1) { 00144 return is_floating_string (arg_1); 00145 } 00146 00147 static bool 00148 GLUE_26 (const string &arg_1) { 00149 return is_alpha (arg_1); 00150 } 00151 00152 static bool 00153 GLUE_27 (const string &arg_1) { 00154 return is_numeric (arg_1); 00155 } 00156 00157 static bool 00158 GLUE_28 (const string &arg_1) { 00159 return is_alpha_numeric (arg_1); 00160 } 00161 00162 static bool 00163 GLUE_29 (const string &arg_1) { 00164 return is_mmx_identifier (arg_1); 00165 } 00166 00167 static bool 00168 GLUE_30 (const generic &arg_1) { 00169 return is_generic_literal (arg_1); 00170 } 00171 00172 static generic 00173 GLUE_31 (const literal &arg_1, const tuple<generic> &arg_2) { 00174 return gen_literal_apply (arg_1, as_vector (arg_2)); 00175 } 00176 00177 static generic 00178 GLUE_32 (const literal &arg_1, const tuple<generic> &arg_2) { 00179 return gen_literal_access (arg_1, as_vector (arg_2)); 00180 } 00181 00182 static literal 00183 GLUE_33 (const string &arg_1) { 00184 return literal (arg_1); 00185 } 00186 00187 static string 00188 GLUE_34 (const literal &arg_1) { 00189 return *arg_1; 00190 } 00191 00192 static generic 00193 GLUE_35 (const int &arg_1) { 00194 return integer_construct (arg_1); 00195 } 00196 00197 static lmv_monomial 00198 GLUE_36 () { 00199 return lmv_monomial (); 00200 } 00201 00202 static lmv_monomial 00203 GLUE_37 (const mmx_coordinate &arg_1) { 00204 return lmv_monomial (arg_1); 00205 } 00206 00207 static lmv_monomial 00208 GLUE_38 (const mmx_coordinate &arg_1) { 00209 return lmv_monomial (arg_1); 00210 } 00211 00212 static mmx_coordinates 00213 GLUE_39 (const lmv_monomial &arg_1) { 00214 return arg_1.coords; 00215 } 00216 00217 static int 00218 GLUE_40 (const lmv_monomial &arg_1) { 00219 return dim (arg_1); 00220 } 00221 00222 static lmv_monomial 00223 GLUE_41 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00224 return arg_1 * arg_2; 00225 } 00226 00227 static lmv_monomial 00228 GLUE_42 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00229 return arg_1 / arg_2; 00230 } 00231 00232 static bool 00233 GLUE_43 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00234 return arg_1 >>= arg_2; 00235 } 00236 00237 static lmv_monomial 00238 GLUE_44 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00239 return gcd (arg_1, arg_2); 00240 } 00241 00242 static lmv_monomial 00243 GLUE_45 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00244 return lcm (arg_1, arg_2); 00245 } 00246 00247 static bool 00248 GLUE_46 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00249 return arg_1 << arg_2; 00250 } 00251 00252 static bool 00253 GLUE_47 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00254 return arg_1 <<= arg_2; 00255 } 00256 00257 static bool 00258 GLUE_48 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00259 return arg_1 >> arg_2; 00260 } 00261 00262 static bool 00263 GLUE_49 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00264 return arg_1 >>= arg_2; 00265 } 00266 00267 static int 00268 GLUE_50 (const lmv_monomial &arg_1) { 00269 return pr_hash (arg_1); 00270 } 00271 00272 static bool 00273 GLUE_51 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00274 return pr_eq (arg_1, arg_2); 00275 } 00276 00277 static bool 00278 GLUE_52 (const lmv_monomial &arg_1, const lmv_monomial &arg_2) { 00279 return pr_neq (arg_1, arg_2); 00280 } 00281 00282 static vector<mmx_coordinate> 00283 GLUE_53 (const tuple<mmx_coordinate> &arg_1) { 00284 return vector<mmx_coordinate > (as_vector (arg_1)); 00285 } 00286 00287 static vector<mmx_coordinate> 00288 GLUE_54 (const tuple<mmx_coordinate> &arg_1) { 00289 return vector<mmx_coordinate > (as_vector (arg_1)); 00290 } 00291 00292 static iterator<generic> 00293 GLUE_55 (const vector<mmx_coordinate> &arg_1) { 00294 return as<iterator<generic> > (iterate (arg_1)); 00295 } 00296 00297 static int 00298 GLUE_56 (const vector<mmx_coordinate> &arg_1) { 00299 return N (arg_1); 00300 } 00301 00302 static mmx_coordinate 00303 GLUE_57 (const vector<mmx_coordinate> &arg_1, const int &arg_2) { 00304 return arg_1[arg_2]; 00305 } 00306 00307 static alias<mmx_coordinate> 00308 GLUE_58 (const alias<vector<mmx_coordinate> > &arg_1, const int &arg_2) { 00309 return alias_access<mmx_coordinate > (arg_1, arg_2); 00310 } 00311 00312 static vector<mmx_coordinate> 00313 GLUE_59 (const vector<mmx_coordinate> &arg_1, const int &arg_2, const int &arg_3) { 00314 return range (arg_1, arg_2, arg_3); 00315 } 00316 00317 static vector<mmx_coordinate> 00318 GLUE_60 (const vector<mmx_coordinate> &arg_1) { 00319 return reverse (arg_1); 00320 } 00321 00322 static vector<mmx_coordinate> 00323 GLUE_61 (const vector<mmx_coordinate> &arg_1, const vector<mmx_coordinate> &arg_2) { 00324 return append (arg_1, arg_2); 00325 } 00326 00327 static alias<vector<mmx_coordinate> > 00328 GLUE_62 (const alias<vector<mmx_coordinate> > &arg_1, const vector<mmx_coordinate> &arg_2) { 00329 return alias_write (arg_1, arg_2); 00330 } 00331 00332 static void 00333 GLUE_63 (const vector<mmx_coordinate> &arg_1, const vector<mmx_coordinate> &arg_2) { 00334 inside_append (arg_1, arg_2); 00335 } 00336 00337 static vector<mmx_coordinate> 00338 GLUE_64 (const mmx_coordinate &arg_1, const vector<mmx_coordinate> &arg_2) { 00339 return cons (arg_1, arg_2); 00340 } 00341 00342 static mmx_coordinate 00343 GLUE_65 (const vector<mmx_coordinate> &arg_1) { 00344 return car (arg_1); 00345 } 00346 00347 static vector<mmx_coordinate> 00348 GLUE_66 (const vector<mmx_coordinate> &arg_1) { 00349 return cdr (arg_1); 00350 } 00351 00352 static bool 00353 GLUE_67 (const vector<mmx_coordinate> &arg_1) { 00354 return is_nil (arg_1); 00355 } 00356 00357 static bool 00358 GLUE_68 (const vector<mmx_coordinate> &arg_1) { 00359 return is_atom (arg_1); 00360 } 00361 00362 static vector<mmx_coordinate> 00363 GLUE_69 (const vector<mmx_coordinate> &arg_1, const mmx_coordinate &arg_2) { 00364 return insert (arg_1, arg_2); 00365 } 00366 00367 static int 00368 GLUE_70 (const vector<mmx_coordinate> &arg_1, const mmx_coordinate &arg_2) { 00369 return find (arg_1, arg_2); 00370 } 00371 00372 static bool 00373 GLUE_71 (const vector<mmx_coordinate> &arg_1, const mmx_coordinate &arg_2) { 00374 return contains (arg_1, arg_2); 00375 } 00376 00377 static vector<lmv_monomial> 00378 GLUE_72 (const tuple<lmv_monomial> &arg_1) { 00379 return vector<lmv_monomial > (as_vector (arg_1)); 00380 } 00381 00382 static vector<lmv_monomial> 00383 GLUE_73 (const tuple<lmv_monomial> &arg_1) { 00384 return vector<lmv_monomial > (as_vector (arg_1)); 00385 } 00386 00387 static iterator<generic> 00388 GLUE_74 (const vector<lmv_monomial> &arg_1) { 00389 return as<iterator<generic> > (iterate (arg_1)); 00390 } 00391 00392 static int 00393 GLUE_75 (const vector<lmv_monomial> &arg_1) { 00394 return N (arg_1); 00395 } 00396 00397 static lmv_monomial 00398 GLUE_76 (const vector<lmv_monomial> &arg_1, const int &arg_2) { 00399 return arg_1[arg_2]; 00400 } 00401 00402 static alias<lmv_monomial> 00403 GLUE_77 (const alias<vector<lmv_monomial> > &arg_1, const int &arg_2) { 00404 return alias_access<lmv_monomial > (arg_1, arg_2); 00405 } 00406 00407 static vector<lmv_monomial> 00408 GLUE_78 (const vector<lmv_monomial> &arg_1, const int &arg_2, const int &arg_3) { 00409 return range (arg_1, arg_2, arg_3); 00410 } 00411 00412 static vector<lmv_monomial> 00413 GLUE_79 (const vector<lmv_monomial> &arg_1) { 00414 return reverse (arg_1); 00415 } 00416 00417 static vector<lmv_monomial> 00418 GLUE_80 (const vector<lmv_monomial> &arg_1, const vector<lmv_monomial> &arg_2) { 00419 return append (arg_1, arg_2); 00420 } 00421 00422 static alias<vector<lmv_monomial> > 00423 GLUE_81 (const alias<vector<lmv_monomial> > &arg_1, const vector<lmv_monomial> &arg_2) { 00424 return alias_write (arg_1, arg_2); 00425 } 00426 00427 static void 00428 GLUE_82 (const vector<lmv_monomial> &arg_1, const vector<lmv_monomial> &arg_2) { 00429 inside_append (arg_1, arg_2); 00430 } 00431 00432 static vector<lmv_monomial> 00433 GLUE_83 (const lmv_monomial &arg_1, const vector<lmv_monomial> &arg_2) { 00434 return cons (arg_1, arg_2); 00435 } 00436 00437 static lmv_monomial 00438 GLUE_84 (const vector<lmv_monomial> &arg_1) { 00439 return car (arg_1); 00440 } 00441 00442 static vector<lmv_monomial> 00443 GLUE_85 (const vector<lmv_monomial> &arg_1) { 00444 return cdr (arg_1); 00445 } 00446 00447 static bool 00448 GLUE_86 (const vector<lmv_monomial> &arg_1) { 00449 return is_nil (arg_1); 00450 } 00451 00452 static bool 00453 GLUE_87 (const vector<lmv_monomial> &arg_1) { 00454 return is_atom (arg_1); 00455 } 00456 00457 static vector<lmv_monomial> 00458 GLUE_88 (const vector<lmv_monomial> &arg_1, const lmv_monomial &arg_2) { 00459 return insert (arg_1, arg_2); 00460 } 00461 00462 static int 00463 GLUE_89 (const vector<lmv_monomial> &arg_1, const lmv_monomial &arg_2) { 00464 return find (arg_1, arg_2); 00465 } 00466 00467 static bool 00468 GLUE_90 (const vector<lmv_monomial> &arg_1, const lmv_monomial &arg_2) { 00469 return contains (arg_1, arg_2); 00470 } 00471 00472 static vector<generic> 00473 GLUE_91 (const vector<mmx_coordinate> &arg_1) { 00474 return as<vector<generic> > (arg_1); 00475 } 00476 00477 static vector<generic> 00478 GLUE_92 (const vector<lmv_monomial> &arg_1) { 00479 return as<vector<generic> > (arg_1); 00480 } 00481 00482 static vector<mmx_coordinate> 00483 GLUE_93 (const mmx_coordinates &arg_1) { 00484 return as_vector (arg_1); 00485 } 00486 00487 static vector<lmv_monomial> 00488 GLUE_94 (const vector<lmv_monomial> &arg_1) { 00489 return stairs (arg_1); 00490 } 00491 00492 static bool 00493 GLUE_95 (const lmv_monomial &arg_1, const vector<lmv_monomial> &arg_2) { 00494 return arg_1 <<= arg_2; 00495 } 00496 00497 static int 00498 GLUE_96 (const vector<mmx_coordinate> &arg_1) { 00499 return pr_hash (arg_1); 00500 } 00501 00502 static bool 00503 GLUE_97 (const vector<mmx_coordinate> &arg_1, const vector<mmx_coordinate> &arg_2) { 00504 return pr_eq (arg_1, arg_2); 00505 } 00506 00507 static bool 00508 GLUE_98 (const vector<mmx_coordinate> &arg_1, const vector<mmx_coordinate> &arg_2) { 00509 return pr_neq (arg_1, arg_2); 00510 } 00511 00512 static int 00513 GLUE_99 (const vector<lmv_monomial> &arg_1) { 00514 return pr_hash (arg_1); 00515 } 00516 00517 static bool 00518 GLUE_100 (const vector<lmv_monomial> &arg_1, const vector<lmv_monomial> &arg_2) { 00519 return pr_eq (arg_1, arg_2); 00520 } 00521 00522 static bool 00523 GLUE_101 (const vector<lmv_monomial> &arg_1, const vector<lmv_monomial> &arg_2) { 00524 return pr_neq (arg_1, arg_2); 00525 } 00526 00527 void 00528 glue_lmonomial () { 00529 static bool done = false; 00530 if (done) return; 00531 done = true; 00532 call_glue (string ("glue_basix_vector_generic")); 00533 call_glue (string ("glue_coordinates")); 00534 define ("string?", GLUE_1); 00535 define ("#", GLUE_2); 00536 define (".[]", GLUE_3); 00537 define ("*", GLUE_4); 00538 define ("><", GLUE_5); 00539 define ("<<", GLUE_6); 00540 define ("<", GLUE_7); 00541 define ("<=", GLUE_8); 00542 define (">", GLUE_9); 00543 define (">=", GLUE_10); 00544 define ("starts?", GLUE_11); 00545 define ("ends?", GLUE_12); 00546 define ("replace", GLUE_13); 00547 define ("search_forwards", GLUE_14); 00548 define ("search_backwards", GLUE_15); 00549 define ("upcase", GLUE_16); 00550 define ("locase", GLUE_17); 00551 define ("upcase_first", GLUE_18); 00552 define ("locase_first", GLUE_19); 00553 define ("quote", GLUE_20); 00554 define ("unquote", GLUE_21); 00555 define ("ascii", GLUE_22); 00556 define ("ascii_code", GLUE_23); 00557 define ("integer?", GLUE_24); 00558 define ("floating?", GLUE_25); 00559 define ("alpha?", GLUE_26); 00560 define ("numeric?", GLUE_27); 00561 define ("alpha_numeric?", GLUE_28); 00562 define ("mmx_identifier?", GLUE_29); 00563 define ("literal?", GLUE_30); 00564 define (".()", GLUE_31); 00565 define (".[]", GLUE_32); 00566 define ("as_literal", GLUE_33); 00567 define ("as_string", GLUE_34); 00568 define_constructor<int > (GLUE_35); 00569 define_type<lmv_monomial > (lit ("LMonomial")); 00570 define ("lmonomial", GLUE_36); 00571 define ("lmonomial", GLUE_37); 00572 define_converter ("upgrade", GLUE_38, PENALTY_INCLUSION); 00573 define (".coordinates", GLUE_39); 00574 define ("dim", GLUE_40); 00575 define ("*", GLUE_41); 00576 define ("/", GLUE_42); 00577 define ("divides?", GLUE_43); 00578 define ("gcd", GLUE_44); 00579 define ("lcm", GLUE_45); 00580 define ("<<", GLUE_46); 00581 define ("<<=", GLUE_47); 00582 define (">>", GLUE_48); 00583 define (">>=", GLUE_49); 00584 define ("hash%", GLUE_50); 00585 define ("=%", GLUE_51); 00586 define ("!=%", GLUE_52); 00587 define_type<vector<mmx_coordinate> > (gen (lit ("Vector"), lit ("Coordinate"))); 00588 define_type<vector<lmv_monomial> > (gen (lit ("Vector"), lit ("LMonomial"))); 00589 define ("vector", GLUE_53); 00590 define ("[]", GLUE_54); 00591 define_converter (":>", GLUE_55, PENALTY_CAST); 00592 define ("#", GLUE_56); 00593 define (".[]", GLUE_57); 00594 define (".[]", GLUE_58); 00595 define (".[]", GLUE_59); 00596 define ("reverse", GLUE_60); 00597 define ("><", GLUE_61); 00598 define ("<<", GLUE_62); 00599 define ("append", GLUE_63); 00600 define ("cons", GLUE_64); 00601 define ("car", GLUE_65); 00602 define ("cdr", GLUE_66); 00603 define ("nil?", GLUE_67); 00604 define ("atom?", GLUE_68); 00605 define ("insert", GLUE_69); 00606 define ("find", GLUE_70); 00607 define ("contains?", GLUE_71); 00608 define ("vector", GLUE_72); 00609 define ("[]", GLUE_73); 00610 define_converter (":>", GLUE_74, PENALTY_CAST); 00611 define ("#", GLUE_75); 00612 define (".[]", GLUE_76); 00613 define (".[]", GLUE_77); 00614 define (".[]", GLUE_78); 00615 define ("reverse", GLUE_79); 00616 define ("><", GLUE_80); 00617 define ("<<", GLUE_81); 00618 define ("append", GLUE_82); 00619 define ("cons", GLUE_83); 00620 define ("car", GLUE_84); 00621 define ("cdr", GLUE_85); 00622 define ("nil?", GLUE_86); 00623 define ("atom?", GLUE_87); 00624 define ("insert", GLUE_88); 00625 define ("find", GLUE_89); 00626 define ("contains?", GLUE_90); 00627 define_converter (":>", GLUE_91, PENALTY_PROMOTE_GENERIC); 00628 define_converter (":>", GLUE_92, PENALTY_PROMOTE_GENERIC); 00629 define ("as_vector", GLUE_93); 00630 define ("stairs", GLUE_94); 00631 define ("<<=", GLUE_95); 00632 define ("hash%", GLUE_96); 00633 define ("=%", GLUE_97); 00634 define ("!=%", GLUE_98); 00635 define ("hash%", GLUE_99); 00636 define ("=%", GLUE_100); 00637 define ("!=%", GLUE_101); 00638 } 00639 }