shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/algebraic_set.hpp
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * M a t h e m a g i x
00003  *****************************************************************************
00004  * Algebraic set
00005  * 2008-03-28
00006  * Julien Wintz & Bernard Mourrain
00007  *****************************************************************************
00008  *               Copyright (C) 2006 INRIA Sophia-Antipolis
00009  *****************************************************************************
00010  * Comments :
00011  ****************************************************************************/
00012 # ifndef shape_algebraic_set_hpp
00013 # define shape_algebraic_set_hpp
00014 
00015 # include <realroot/GMP.hpp>
00016 # include <realroot/polynomial_sparse.hpp>
00017 # define TMPL  template<class C, class V>
00018 # define TMPL1 template<class V>
00019 # define SELF  algebraic_set<C,V>
00020 //====================================================================
00021 namespace mmx {
00022 namespace shape {
00023 //====================================================================
00024 struct numeric_def {};
00025 
00026 template<> struct use<numeric_def> 
00027 {  
00028   typedef ::mmx::GMP::integer  Integer;
00029   typedef ::mmx::GMP::rational Rational;
00030   typedef ::mmx::GMP::floating Floating;
00031 };
00032 
00033 struct algebraic_set_def {};
00034 
00035 template<> struct use<algebraic_set_def> 
00036 {  
00037   typedef use<numeric_def>::Rational         Scalar;
00038   //  typedef double Scalar;
00039   typedef polynomial<Scalar, with<Sparse, DegRevLex> > Polynomial;
00040 };
00041 
00042 TMPL struct use<algebraic_set_def,join2<C,V> > 
00043 {  
00044   typedef typename use<numeric_def,V>::Rational         Scalar;
00045   //  typedef C Scalar;
00046   typedef polynomial<Scalar, with<Sparse, DegRevLex> > Polynomial;
00047 };
00048 //--------------------------------------------------------------------
00049 TMPL
00050 class algebraic_set 
00051 {
00052 public:
00053   //  typedef polynomial<Rational, with<Sparse, DegRevLex> > Polynomial;
00054   typedef typename use<algebraic_set_def,join2<C,V> >::Polynomial   Polynomial;
00055 
00056   algebraic_set(void) {};
00057   algebraic_set(const char* s1) ;
00058   algebraic_set(const char* s1, const char* s2) ;
00059   algebraic_set(const Polynomial& eq) ;
00060   algebraic_set(const Polynomial& eq1, const Polynomial& eq2) ;
00061   ~algebraic_set(void) {};
00062   
00063   const Seq<Polynomial>& equations()  const { return this->m_polynomials ; }
00064   const Polynomial&      equation(int i=0) const { return this->m_polynomials[i] ; }
00065   Polynomial&            equation(int i=0)       { return this->m_polynomials[i] ; }
00066   void         set_equation(const Polynomial& p) { this->m_polynomials[0]=p ; }
00067   void insert(const Polynomial& p)   { this->m_polynomials<<p; }
00068   int  nbequation()            const { return m_polynomials.size(); }
00069 
00070 private:
00071   Seq<Polynomial> m_polynomials ;
00072 } ;
00073 
00074 TMPL
00075 SELF::algebraic_set(const char* s1) {
00076   m_polynomials<<Polynomial(s1);
00077 }
00078 
00079 TMPL
00080 SELF::algebraic_set(const char* s1,const char* s2) {
00081   m_polynomials<<Polynomial(s1);
00082   m_polynomials<<Polynomial(s2);
00083 }
00084 
00085 TMPL
00086 SELF::algebraic_set(const Polynomial& p1) {
00087   m_polynomials<<p1;
00088 }
00089 
00090 TMPL
00091 SELF::algebraic_set(const Polynomial& p1,const Polynomial& p2) {
00092   m_polynomials<<p1;
00093   m_polynomials<<p2;
00094 }
00095 
00096 //====================================================================
00097 } ; // namespace shape
00098 } ; // namespace mmx
00099 //====================================================================
00100 # undef TMPL
00101 # undef TMPL1
00102 # undef SELF
00103 # endif // IMPLICITCURVE_H