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 <algebramix/p_expansion.hpp> 00013 #include <algebramix/p_expansion_modular_integer.hpp> 00014 #include <basix/tuple.hpp> 00015 #include <basix/glue.hpp> 00016 00017 #define int_literal(x) as_int (as_string (x)) 00018 #define is_generic_literal is<literal> 00019 #define gen_literal_apply(f,v) gen (as<generic> (f), v) 00020 #define gen_literal_access(f,v) access (as<generic> (f), v) 00021 00022 #define simple_p_expansion(C) polynomial<C, polynomial_carry_variant_helper<C>::PV> 00023 #define simple_as_p_expansion(C) as_p_expansion<C,Modulus_variant(C),modular_local> 00024 00025 00026 namespace mmx { 00027 static inline simple_p_expansion(mmx_modular(integer)) 00028 integer_as_p_expansion(const integer& c, const modulus<integer>& p) { 00029 return simple_as_p_expansion(integer)(c, p); } 00030 } 00031 00032 00033 namespace mmx { 00034 static simple_p_expansion(mmx_modular(integer) ) 00035 GLUE_1 (const tuple<mmx_modular(integer) > &arg_1) { 00036 return (simple_p_expansion(mmx_modular(integer) ) (as_vector (arg_1))); 00037 } 00038 00039 static void 00040 GLUE_2 (const simple_p_expansion(mmx_modular(integer) ) &arg_1, const generic &arg_2) { 00041 set_variable_name (arg_1, arg_2); 00042 } 00043 00044 static iterator<generic> 00045 GLUE_3 (const simple_p_expansion(mmx_modular(integer) ) &arg_1) { 00046 return as<iterator<generic> > (iterate (arg_1)); 00047 } 00048 00049 static int 00050 GLUE_4 (const simple_p_expansion(mmx_modular(integer) ) &arg_1) { 00051 return N (arg_1); 00052 } 00053 00054 static int 00055 GLUE_5 (const simple_p_expansion(mmx_modular(integer) ) &arg_1) { 00056 return deg (arg_1); 00057 } 00058 00059 static mmx_modular(integer) 00060 GLUE_6 (const simple_p_expansion(mmx_modular(integer) ) &arg_1, const int &arg_2) { 00061 return arg_1[arg_2]; 00062 } 00063 00064 static integer 00065 GLUE_7 (const simple_p_expansion(mmx_modular(integer) ) &arg_1) { 00066 return as<integer > (arg_1); 00067 } 00068 00069 static simple_p_expansion(mmx_modular(integer) ) 00070 GLUE_8 (const integer &arg_1, const modulus<integer> &arg_2) { 00071 return integer_as_p_expansion (arg_1, arg_2); 00072 } 00073 00074 void 00075 glue_p_expansion_modular_integer () { 00076 static bool done = false; 00077 if (done) return; 00078 done = true; 00079 call_glue (string ("glue_basix_vector_generic")); 00080 call_glue (string ("glue_modular_integer")); 00081 call_glue (string ("glue_vector_modular_integer")); 00082 define_type<simple_p_expansion(mmx_modular(integer) ) > (gen (lit ("P_expansion"), gen (lit ("Modular"), lit ("Integer")))); 00083 define ("p_expansion", GLUE_1); 00084 define ("set_variable_name", GLUE_2); 00085 define_converter (":>", GLUE_3, PENALTY_CAST); 00086 define ("#", GLUE_4); 00087 define ("deg", GLUE_5); 00088 define (".[]", GLUE_6); 00089 define ("integer", GLUE_7); 00090 define ("p_expansion", GLUE_8); 00091 } 00092 }