algebramix_doc 0.3
/Users/mourrain/Devel/mmx/algebramix/include/algebramix/polynomial_polynomial.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : polynomial_polynomial.hpp
00004 * DESCRIPTION: Kronecker multiplication of bivariate polynomials
00005 * COPYRIGHT  : (C) 2004  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_POLYNOMIAL_POLYNOMIAL_HPP
00014 #define __MMX_POLYNOMIAL_POLYNOMIAL_HPP
00015 #include <algebramix/polynomial.hpp>
00016 #include <algebramix/polynomial_ring_dicho.hpp>
00017 #include <algebramix/kronecker_polynomial.hpp>
00018 #include <algebramix/polynomial_kronecker.hpp>
00019 
00020 namespace mmx {
00021 
00022 /******************************************************************************
00023 * Variant
00024 ******************************************************************************/
00025 
00026 template<typename V>
00027 struct polynomial_polynomial: public V {
00028   typedef typename V::Vec Vec;
00029   typedef typename V::Naive Naive;
00030   typedef polynomial_polynomial<typename V::Positive> Positive;
00031   typedef polynomial_polynomial<typename V::No_simd> No_simd;
00032   typedef polynomial_polynomial<typename V::No_thread> No_thread;
00033   typedef polynomial_polynomial<typename V::No_scaled> No_scaled;
00034 };
00035 
00036 template<typename F, typename V, typename W>
00037 struct implementation<F,V,polynomial_polynomial<W> >:
00038   public implementation<F,V,W> {};
00039 
00040 /******************************************************************************
00041 * Variable names, default is C[x][y][z]
00042 ******************************************************************************/
00043 
00044 template<typename V,typename W>
00045 struct implementation<polynomial_defaults,V,polynomial_polynomial<W> > {
00046 
00047   template<typename P>
00048   class global_variables {
00049     static inline generic& dyn_name () {
00050       static generic name = "x";
00051       return name; }
00052   public:
00053     static inline void set_variable_name (const generic& x) { dyn_name () = x; }
00054     static inline generic get_variable_name () { return dyn_name (); }
00055   };
00056 
00057   template<typename C, typename V1, typename V2>
00058   class global_variables<polynomial<polynomial<C,V1>, V2> > {
00059     static inline generic& dyn_name () {
00060       static generic name = "y";
00061       return name; }
00062   public:
00063     static inline void set_variable_name (const generic& x) {
00064       dyn_name () = x; }
00065     static inline generic get_variable_name () {
00066       return dyn_name (); }
00067   };
00068 
00069   template<typename C, typename V1, typename V2, typename V3>
00070   class global_variables<polynomial<polynomial<
00071                                            polynomial<C,V1>, V2>, V3 > > {
00072     static inline generic& dyn_name () {
00073       static generic name = "z";
00074       return name; }
00075   public:
00076     static inline void set_variable_name (const generic& x) {
00077       dyn_name () = x; }
00078     static inline generic get_variable_name () {
00079       return dyn_name (); }
00080   };
00081 
00082 };
00083 
00084 /******************************************************************************
00085 * Kronecker exact division
00086 ******************************************************************************/
00087 
00088 template<typename V,typename W>
00089 struct implementation<polynomial_exact_divide,V,
00090                       polynomial_polynomial<W> >:
00091   public implementation<polynomial_linear,V>
00092 {
00093   typedef polynomial_exact_divide_threshold <polynomial_polynomial<W> > Th;
00094   typedef implementation<polynomial_exact_divide,W> Fallback;
00095 
00096 template<typename C> static inline void
00097 div (C* dest, const C* s1, const C* s2, nat n1, nat n2) {
00098   if (min (n1, n2) < Threshold(C,Th))
00099     Fallback::div (dest, s1, s2, n1, n2);
00100   else div_kronecker (dest, s1, n1, s2, n2); }
00101 
00102 };
00103 
00104 /******************************************************************************
00105 * Kronecker multiplication
00106 ******************************************************************************/
00107 
00108 template<typename C, typename V>
00109 struct polynomial_variant_helper<polynomial<C,V> > {
00110   typedef polynomial_gcd_ring_dicho<
00111             polynomial_kronecker<
00112               polynomial_polynomial<
00113                 polynomial_dicho<
00114                   polynomial_naive> > > > PV;
00115 };
00116 
00117 template<typename C, typename V1, typename V2>
00118 struct polynomial_variant_helper<polynomial<polynomial<C,V1>,V2> > {
00119   typedef V2 PV;
00120 };
00121 
00122 } // namespace mmx
00123 #endif // __MMX_POLYNOMIAL_POLYNOMIAL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines