synaps/topology/sbd2dbdg.h

00001 /********************************************************************
00002  *   This file is part of the source code of the SYNAPS kernel.
00003  *   Author(s): B. Mourrain, GALAAD, INRIA
00004  *   $Id: topology2d.h,v 1.2 2005/09/28 06:40:47 mourrain Exp $
00005  ********************************************************************/
00006 #ifndef synaps_subdivision_sbd2dbdg_H
00007 #define synaps_subdivision_sbd2dbdg_H
00008 //--------------------------------------------------------------------
00009 #include <synaps/topology/sbd2d.h>
00010 #include <synaps/arithm/Interval.h>
00011 //#include <synaps/arithm/interval/interval.h>
00012 //--------------------------------------------------------------------
00013 __BEGIN_NAMESPACE_SYNAPS
00014 //--------------------------------------------------------------------
00015 template<class X, int N>
00016 void print_mx(const MatrDse<Interval<X,N> >& M)
00017 {
00018 
00019   double dmx=0, imx=0,imn=1;
00020   for(unsigned i=0; i< M.nbrow();i++)
00021     for(unsigned j=0; j< M.nbcol();j++)
00022       {
00023         imx= std::max(imx,M(i,j).sup()-M(i,j).inf());
00024         imn= std::min(imn,M(i,j).sup()-M(i,j).inf());
00025         if( M(i,j).sup()<0)
00026           dmx = std::max(dmx,-M(i,j).sup());
00027         else
00028               dmx = std::max(dmx,M(i,j).sup());
00029           }
00030       std::cout<<"DMax "<<dmx<<std::endl;
00031       std::cout<<"IMax "<<imx<<std::endl;
00032       std::cout<<"IMin "<<imn<<std::endl;
00033 }
00034 
00035 template<class X, int N>
00036 void print_sign(const MatrDse<Interval<X,N> >& M)
00037 {
00038   for(unsigned i=0;i<M.nbrow();i++)
00039     {
00040       std::cout<<"[";
00041       for(unsigned j=0; j<M.nbcol();j++)
00042       {
00043         if(M(i,j).sup()<0)
00044           std::cout<<"-";
00045         else if(M(i,j).inf()>=0)
00046           std::cout<<"+";
00047         else if(M(i,j).inf()<0 && M(i,j).sup()>0)
00048           std::cout<<"?";
00049         else
00050           std::cout<<" ";
00051         //std::cout<<M(i,j).sup()-M(i,j).inf()<<std::endl;
00052       }
00053       std::cout<<"]"<<std::endl;
00054     }
00055 }
00056 template<class Int>
00057 bool IsSmall (const Int& I)
00058 {
00059   return (I.inf()<= 0 && I.sup() >= 0 && (I.inf()!=I.sup()));
00060 }
00061 
00062 template<class X, int N>
00063 int sign(const Interval<X,N>& I)
00064 {
00065   if(I.sup()< (0))
00066     return -1;
00067   else if(I.inf()>(0))
00068     return 1;
00069   else if(I.sup()==0 && I.inf()==0)
00070     return 0;
00071   else
00072     return 2;
00073 }
00074 // template<class X, int N>
00075 // int sign(const std2::interval<double>& I)
00076 // {
00077 //   if(I.sup()< (0))
00078 //     return -1;
00079 //   else if(I.inf()>(0))
00080 //     return 1;
00081 //   else if(I.sup()==0 && I.inf()==0)
00082 //     return 0;
00083 //   else
00084 //     return 2;
00085 // }
00086 
00087 namespace bezier 
00088 {
00089   template<class X>
00090   struct bzislv: public Isole<X> 
00091   {
00092     X eps;
00093     bzislv():eps(1e-4){}
00094 
00095     template<class UPOL>
00096     Seq<X> solve(const UPOL& p, X x0, X x1)
00097     {
00098       typedef typename UPOL::value_type coeff_t;
00099       bezier::rep1d<X> ubp(p.size()), dbp(p.size());
00100       for(unsigned i=0;i<p.size();i++)
00101         {
00102           ubp[i]=p[i].sup();
00103           dbp[i]=p[i].inf();
00104           assert(dbp[i]<= ubp[i]);
00105         }
00106       this->Run(dbp,ubp,eps,false);
00107       Seq<X> sol; sol.resize(0);
00108       this->GetMidPoints(sol);
00109       for (unsigned i = 0; i < sol.size(); i ++ )
00110         {
00111           if ( this->m_res[i].t )
00112             std::cout<<" xxx"<<std::endl;
00113         }
00114       RConvert(sol,x0,x1);             
00115       return sol;
00116     }
00117   };
00118   
00119  
00120 }//namespace bezier
00121 //--------------------------------------------------------------------
00122 __END_NAMESPACE_SYNAPS
00123 //====================================================================
00124 #endif //synaps_subdivision_topology_H

SYNAPS DOCUMENTATION
logo