shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/curve_rational_glue.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 * MODULE     : implicit_curve_glue.hpp
00003 * DESCRIPTION: Glue for rational curve
00004 * COPYRIGHT  : (C) 2007 Bernard Mourrain
00005 *******************************************************************************
00006 * This software falls under the GNU general public license and comes WITHOUT
00007 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00008 * If you don't have this file, write to the Free Software Foundation, Inc.,
00009 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00010 ******************************************************************************/
00011 #ifndef __MMX_SHAPE_RATIONAL_CURVE_GLUE_HPP
00012 #define __MMX_SHAPE_RATIONAL_CURVE_GLUE_HPP
00013 #include <basix/glue.hpp>
00014 #include <basix/tuple.hpp>
00015 #include <realroot/polynomial_sparse_glue.hpp>
00016 #include <shape/MGXK.hpp>
00017 #include <shape/axel_glue.hpp>
00018 #include <shape/bounding_box.hpp>
00019 namespace mmx {
00020   namespace shape {
00021     struct curve_rational_def;
00022 
00023     template<> struct use<curve_rational_def,MGXK> {
00024       typedef polynomial< rational, with<Sparse,DegRevLex> > Polynomial;
00025     };
00026   }
00027 }
00028 #include <shape/curve_rational.hpp>
00029 
00030 #define shape_curve_rational shape::curve_rational<rational,shape::MGXK> 
00031 #define Polynomial  polynomial< rational, with<Sparse,DegRevLex> >
00032 #define CURVE shape_curve_rational
00033 //====================================================================
00034 namespace mmx {
00035   namespace shape {
00036 
00037     inline bool operator ==(const CURVE& v1, const CURVE& v2) {return true;}
00038     inline bool operator !=(const CURVE& v1, const CURVE& v2) {return !(v1==v2);}
00039     inline bool exact_eq(const CURVE& v1, const CURVE& v2) {return v1==v2;}
00040     inline bool exact_neq(const CURVE& v1, const CURVE& v2) {return v1!=v2;}
00041     
00042     inline unsigned hash (const CURVE& v) 
00043     {
00044       register unsigned i, h= 214365, n=1;
00045       for (i=0; i<n; i++) h= (h<<1) ^ (h<<5) ^ (h>>27) ;//^ hash(v[i]);
00046       return h;
00047     }
00048     inline unsigned exact_hash (const CURVE& m) {return hash(m);}
00049     inline unsigned soft_hash (const CURVE& m) {return hash(m);}
00050 
00051     inline syntactic flatten (const CURVE& s) 
00052     {
00053       using namespace shape;
00054       
00055       syntactic res = "RationalCurve";
00056       return res;
00057 
00058       if(s.dimension()>1)
00059         return apply(res, mmx::flatten(s.numerator(0)), mmx::flatten(s.numerator(1)), mmx::flatten(s.denominator()));
00060       else
00061         return apply(res, mmx::flatten(s.numerator(0)), mmx::flatten(s.denominator()));
00062     }
00063 
00064   } //namespace shape
00065   
00066  //  inline CURVE shape_curve_rational_string (const string& e1,const string& e2, const string& e3)
00067 //   {
00068 //     return CURVE (Polynomial(as_charp(e1)), Polynomial(as_charp(e2)), Polynomial(as_charp(e3)));
00069 //   }
00070 
00071 //   inline CURVE shape_curve_rational_string (const string& e1,const string& e2, const string& e3, const string& e4)
00072 //   {
00073 //     return CURVE (Polynomial(as_charp(e1)), Polynomial(as_charp(e2)), Polynomial(as_charp(e3)), Polynomial(as_charp(e4)));
00074 //   }
00075 
00076   inline CURVE create_curve_rational(const Polynomial& e1,const Polynomial& e2, const Polynomial& e3)
00077   {
00078     return CURVE(e1,e2,e3);
00079   }
00080 
00081   inline CURVE create_curve_rational(const interval<double>& I, const Polynomial& e1,const Polynomial& e2, const Polynomial& e3)
00082   {
00083     return CURVE(lower(I), upper(I), e1,e2,e3);
00084   }
00085 
00086   inline CURVE create_curve_rational(const Polynomial& e1,const Polynomial& e2, const Polynomial& e3,const Polynomial& e4)
00087   {
00088     return CURVE(e1,e2,e3,e4);
00089   }
00090 
00091   inline CURVE create_curve_rational(const interval<double>& I, const Polynomial& e1,const Polynomial& e2, const Polynomial& e3, const Polynomial& e4)
00092   {
00093     return CURVE(lower(I), upper(I), e1,e2,e3,e4);
00094   }
00095 
00096 //====================================================================
00097 #undef CURVE
00098 #undef Polynomial
00099 //====================================================================
00100 } // namespace mmx
00101 #endif // __MMX_ALGEBRAIC_CURVE_GLUE_HPP