algebramix_doc 0.3
/Users/mourrain/Devel/mmx/algebramix/include/algebramix/matrix_integer.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : matrix_integer.hpp
00004 * DESCRIPTION: Multi-modular multiplication of integer matrices
00005 * COPYRIGHT  : (C) 2009  Joris van der Hoeven and Gregoire Lecerf
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 
00023 namespace mmx {
00024 
00025 /******************************************************************************
00026 * Use multi-modular multiplication by default for integer matrices
00027 ******************************************************************************/
00028 
00029 DEFINE_VARIANT (matrix_integer,
00030                 matrix_balanced<matrix_crt<matrix_ring_naive<matrix_naive> > >)
00031 
00032 STMPL
00033 struct matrix_variant_helper<integer> {
00034   typedef matrix_integer MV;
00035 };
00036 
00037 /******************************************************************************
00038 * Size helper and default moduli
00039 ******************************************************************************/
00040 
00041 xnat
00042 matrix_product_bit_size (const integer* s1, nat s1_rs, nat s1_cs,
00043                          const integer* s2, nat s2_rs, nat s2_cs,
00044                          nat r, nat l, nat c);
00045 
00046 STMPL
00047 struct matrix_crt_multiply_helper<integer> {
00048 private:
00049   struct mat_crt_naive {
00050     typedef integer base;
00051     typedef int modulus_base;
00052     typedef modulus_int_preinverse<20> modulus_base_variant;
00053     typedef Modulus_variant(integer) modulus_variant;
00054   };
00055   struct mat_crt_dicho {
00056     typedef integer base;
00057     typedef integer modulus_base;
00058     typedef modulus_integer_naive modulus_base_variant;
00059     typedef Modulus_variant(integer) modulus_variant;
00060   };
00061   typedef modulus<mat_crt_naive::modulus_base,
00062                   mat_crt_naive::modulus_base_variant> M;
00063 public:
00064   static const nat dimension_threshold= 7;
00065   static const nat ratio_threshold= 100; // this is a percentage
00066 
00067   typedef crt_naive_transformer<integer,mat_crt_naive> crt_naive;
00068   typedef crt_dicho_transformer<integer,mat_crt_dicho> crt_dicho;
00069   typedef crt_blocks_transformer<crt_naive,crt_dicho,160> crt_transformer;
00070 
00071   typedef moduli_helper<integer,M,fft_prime_sequence_int<20> > moduli_sequence;
00072 
00073   static inline xnat size (const integer* s1, nat s1_rs, nat s1_cs,
00074                            const integer* s2, nat s2_rs, nat s2_cs,
00075                            nat r, nat l, nat c) {
00076     return matrix_product_bit_size (s1, s1_rs, s1_cs,
00077                                     s2, s2_rs, s2_cs,
00078                                     r, l, c); }
00079 };
00080 
00081 template<typename W>
00082 struct threshold_helper<integer,matrix_multiply_threshold<W> > {
00083   typedef fixed_value<nat,2> impl;
00084 };
00085 
00086 } // namespace mmx
00087 #endif // __MMX_MATRIX_INTEGER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines