realroot_doc 0.1.1
/Users/mourrain/Devel/mmx/realroot/include/realroot/polynomial_glue.hpp
Go to the documentation of this file.
00001 #ifndef realroot_polynomial_glue_hpp
00002 #define realroot_polynomial_glue_hpp
00003 #include <basix/mmx_syntax.hpp>
00004 #include <realroot/polynomial.hpp>
00005 #include <realroot/polynomial_tensor.hpp>
00006 #include <realroot/subresultant.hpp>
00007 #define TMPL template <class C, class V, class W>
00008 #define WVW  with<V,W>
00009 #define Polynomial polynomial<C, WVW >
00010 //======================================================================
00011 namespace mmx {
00012   TMPL unsigned hash(const Polynomial& p){ return 1;}
00013   TMPL unsigned exact_hash(const Polynomial& p){ return 1;}
00014   TMPL unsigned soft_hash(const Polynomial& p){ return 1;}
00015   TMPL bool exact_eq(const Polynomial& p, const Polynomial& q){ return p==q;}
00016   TMPL bool exact_neq(const Polynomial& p, const Polynomial& q){ return p!=q;}
00017   
00018   TMPL syntactic flatten(const Polynomial& p) {
00019     return flatten(p.rep());
00020   }
00021 
00022   TMPL Polynomial diff(const Polynomial& p, const generic& v) {
00023     char *x= as_charp(as_mmx(v));
00024     int i= Polynomial::Ring::vars()[x];
00025     free_charp (x);
00026     return diff(p, i);
00027   }
00028   
00029   TMPL vector<generic>
00030   polynomial_sturm_sequence(const Polynomial& p, const Polynomial& q, int v)
00031   {
00032     vector<generic> res;
00033 
00034     Seq<Polynomial> lp = coefficients(p,v);
00035     vector<generic> vp;
00036     for (unsigned j=0;j<lp.size();j++)
00037       vp << as<generic>(lp[j]);
00038     res << as<generic>(vp);
00039 
00040     Seq<Polynomial> lq = coefficients(q,v);
00041     vector<generic> vq;
00042     for (unsigned j=0;j<lq.size();j++)
00043       vq << as<generic>(lq[j]);
00044     res << as<generic>(vq);
00045     
00046     Seq< Seq<Polynomial> >  s = subresultant<euclidean>::sequence(p,q,v);
00047     for(unsigned i=0;i<s.size();i++) {    
00048       Seq<Polynomial> ri = s[s.size()-i-1];
00049       vector<generic> vi;
00050       for (unsigned j=0;j<ri.size();j++)
00051         vi << as<generic>(ri[j]);
00052       res << as<generic>(vi);
00053     }
00054     return res;
00055   } 
00056 
00057   TMPL Polynomial
00058   polynomial_resultant(const Polynomial& p, const Polynomial& q, int v)
00059   {
00060     Seq< Seq<Polynomial> >  s = subresultant<euclidean>::sequence(p,q,v);
00061 
00062     Polynomial r;
00063     return (s[0])[0];
00064   }
00065 
00066 
00067  TMPL Polynomial
00068  polynomial_gcd(const Polynomial& p, const Polynomial& q, int v)
00069 {
00070 
00071 
00072     return p;
00073 }
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 } //namespace mmx
00082 //======================================================================
00083 #undef TMPL
00084 #undef Polynomial
00085 #endif //realroot_polynomial_glue_hpp