00001 00002 #include <basix/int.hpp> 00003 #include <basix/vector.hpp> 00004 #include <algebramix/vector_unrolled.hpp> 00005 #include <algebramix/vector_simd.hpp> 00006 #include <algebramix/permutation.hpp> 00007 #include <basix/tuple.hpp> 00008 #include <basix/glue.hpp> 00009 00010 #define int_literal(x) as_int (as_string (x)) 00011 00012 namespace mmx { 00013 static permutation 00014 GLUE_1 (const tuple<int> &arg_1) { 00015 return permutation (as_vector (arg_1)); 00016 } 00017 00018 static permutation 00019 GLUE_2 (const int &arg_1) { 00020 return permutation (arg_1); 00021 } 00022 00023 static permutation 00024 GLUE_3 (const int &arg_1, const int &arg_2, const int &arg_3) { 00025 return transposition (arg_1, arg_2, arg_3); 00026 } 00027 00028 static permutation 00029 GLUE_4 (const int &arg_1, const int &arg_2) { 00030 return cycle (arg_1, arg_2); 00031 } 00032 00033 static vector<int> 00034 GLUE_5 (const permutation &arg_1) { 00035 return as_vector_int (arg_1); 00036 } 00037 00038 static iterator<generic> 00039 GLUE_6 (const permutation &arg_1) { 00040 return as<iterator<generic> > (iterate_int (arg_1)); 00041 } 00042 00043 static int 00044 GLUE_7 (const permutation &arg_1) { 00045 return N (arg_1); 00046 } 00047 00048 static int 00049 GLUE_8 (const permutation &arg_1, const int &arg_2) { 00050 return arg_1 (arg_2); 00051 } 00052 00053 static int 00054 GLUE_9 (const permutation &arg_1) { 00055 return nr_transpositions (arg_1); 00056 } 00057 00058 static permutation 00059 GLUE_10 (const permutation &arg_1, const permutation &arg_2) { 00060 return arg_1 * arg_2; 00061 } 00062 00063 static permutation 00064 GLUE_11 (const permutation &arg_1) { 00065 return invert (arg_1); 00066 } 00067 00068 void 00069 glue_permutation () { 00070 static bool done = false; 00071 if (done) return; 00072 done = true; 00073 call_glue (string ("glue_int")); 00074 call_glue (string ("glue_vector_int")); 00075 define_type<permutation > (lit ("Permutation")); 00076 define ("permutation", GLUE_1); 00077 define ("permutation", GLUE_2); 00078 define ("transposition", GLUE_3); 00079 define ("cycle", GLUE_4); 00080 define ("as_vector", GLUE_5); 00081 define_converter (":>", GLUE_6, PENALTY_CAST); 00082 define ("#", GLUE_7); 00083 define (".()", GLUE_8); 00084 define ("nr_transpositions", GLUE_9); 00085 define ("*", GLUE_10); 00086 define ("invert", GLUE_11); 00087 } 00088 }