00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #ifndef __MMX_MATRIX_INTEGER_HPP
00014 #define __MMX_MATRIX_INTEGER_HPP
00015 #include <numerix/integer.hpp>
00016 #include <algebramix/crt_integer.hpp>
00017 #include <algebramix/matrix.hpp>
00018 #include <algebramix/matrix_modular_int.hpp>
00019 #include <algebramix/matrix_ring_naive.hpp>
00020 #include <algebramix/matrix_crt.hpp>
00021 #include <algebramix/matrix_balanced.hpp>
00022 #include <algebramix/matrix_bareiss.hpp>
00023 
00024 namespace mmx {
00025 
00026 
00027 
00028 
00029 
00030 DEFINE_VARIANT (matrix_integer,
00031                 matrix_balanced<
00032                   matrix_bareiss<
00033                     matrix_crt<
00034                       matrix_ring_naive<matrix_naive> > > >)
00035 
00036 STMPL
00037 struct matrix_variant_helper<integer> {
00038   typedef matrix_integer MV;
00039 };
00040 
00041 
00042 
00043 
00044 
00045 xnat
00046 matrix_product_bit_size (const integer* s1, nat s1_rs, nat s1_cs,
00047                          const integer* s2, nat s2_rs, nat s2_cs,
00048                          nat r, nat l, nat c);
00049 
00050 STMPL
00051 struct matrix_crt_multiply_helper<integer> {
00052 private:
00053   struct mat_crt_naive {
00054     typedef integer base;
00055     typedef int modulus_base;
00056     typedef modulus_int_preinverse<20> modulus_base_variant;
00057     typedef Modulus_variant(integer) modulus_variant;
00058   };
00059   struct mat_crt_dicho {
00060     typedef integer base;
00061     typedef integer modulus_base;
00062     typedef modulus_integer_naive modulus_base_variant;
00063     typedef Modulus_variant(integer) modulus_variant;
00064   };
00065   typedef modulus<mat_crt_naive::modulus_base,
00066                   mat_crt_naive::modulus_base_variant> M;
00067 public:
00068   static const nat dimension_threshold= 7;
00069   static const nat ratio_threshold= 100; 
00070 
00071   typedef crt_naive_transformer<integer,mat_crt_naive> crt_naive;
00072   typedef crt_dicho_transformer<integer,mat_crt_dicho> crt_dicho;
00073   typedef crt_blocks_transformer<crt_naive,crt_dicho,160> crt_transformer;
00074 
00075   typedef moduli_helper<integer,M,fft_prime_sequence_int<20> > moduli_sequence;
00076 
00077   static inline xnat size (const integer* s1, nat s1_rs, nat s1_cs,
00078                            const integer* s2, nat s2_rs, nat s2_cs,
00079                            nat r, nat l, nat c) {
00080     return matrix_product_bit_size (s1, s1_rs, s1_cs,
00081                                     s2, s2_rs, s2_cs,
00082                                     r, l, c); }
00083 };
00084 
00085 template<typename W>
00086 struct threshold_helper<integer,matrix_multiply_threshold<W> > {
00087   typedef fixed_value<nat,2> impl;
00088 };
00089 
00090 } 
00091 #endif // __MMX_MATRIX_INTEGER_HPP