00001 #ifndef realroot_ring_dual_hpp
00002 #define realroot_ring_dual_hpp
00003
00015
00016 #include <realroot/polynomial.hpp>
00017 #include <realroot/sparse_dual.hpp>
00018
00019 #define TMPL template<class C, class O>
00020 #define RING ring<C,Dual,O>
00021 #define RING_POL ring<C,Sparse,O>
00022 #define POL polynomial<C,with<Sparse,O> >
00023 #define DUALPOL polynomial<C,with<Dual,O> >
00024
00025 namespace mmx {
00026
00027 struct Dual {};
00028
00029 template<class A, class B> struct use;
00030 template<class C, class V> struct polynomial;
00031 template<class C, class V> struct with;
00032
00033 template<class C, class O>
00034 struct use<polynomial_of,polynomial<C,with<Dual,O> > >{
00035
00036 typedef sparse::dual<C,O> rep_t;
00037
00038 typedef C Scalar;
00039 typedef typename rep_t::Monomial Monomial;
00040 typedef polynomial<C,with<Dual,O> > Polynomial;
00041 typedef ring<C,Dual,O> Ring;
00042
00043 };
00044
00048 template<class C, class O>
00049 struct ring<C, Dual, O > {
00050
00051 typedef RING self_t;
00052 typedef sparse::dual<C,O> rep_t;
00053
00054 typedef C Scalar;
00055 typedef typename rep_t::Monomial Monomial;
00056 typedef polynomial<C,with<Dual,O> > Polynomial;
00057
00058 typedef RING Ring;
00059
00060 static variables& vars () { return RING_POL::vars();}
00061
00062 Polynomial operator[](int i) const {
00063 return Polynomial((C)1,1,i);
00064 }
00065
00066 int nbvar() const { return RING_POL::var.nbvar(); }
00067 };
00068
00069
00070 template<class C, class O> C sample(const RING&rg) { return (C)0;}
00071
00072
00073 TMPL define_operator_rrr(DUALPOL, POL, DUALPOL, operator*, sparse::mul)
00074 TMPL define_operator_rrr(POL, DUALPOL, POL, operator*, sparse::mul)
00075
00076
00077 template<class P, class Q> struct mul_helper;
00078 template<class C, class O> struct mul_helper<
00079 polynomial< C, with<Sparse,O> >,
00080 polynomial< C, with<Dual, O> > > {
00081 typedef polynomial< C, with<Dual, O> > TYPE;
00082 };
00083
00084 template<class C, class O> struct mul_helper<
00085 polynomial< C, with<Dual, O> >,
00086 polynomial< C, with<Sparse,O> > > {
00087 typedef polynomial< C, with<Sparse,O> > TYPE;
00088 };
00089 }
00090
00091 #undef TMPL
00092 #undef RING
00093 #undef RING_POL
00094 #undef POL
00095 #undef DUALPOL
00096 #undef Polynomial
00097
00098 #endif //realroot_ring_dual.hpp