realroot_doc 0.1.1
/Users/mourrain/Devel/mmx/realroot/include/realroot/loops_upoldse.hpp
Go to the documentation of this file.
00001 /********************************************************************
00002  *   This file is part of the source code of the realroot library.
00003  *   Author(s): J.P. Pavone, GALAAD, INRIA
00004  *   $Id: upoldse.hpp,v 1.1 2005/07/11 10:03:56 jppavone Exp $
00005  ********************************************************************/
00006 #ifndef realroot_SOLVE_SBDSLV_LOOPS_UPOLDSE_HPP
00007 #define realroot_SOLVE_SBDSLV_LOOPS_UPOLDSE_HPP
00008 //--------------------------------------------------------------------
00009 namespace mmx {
00010 //--------------------------------------------------------------------
00011 namespace upoldse_ /* univariate dense polynomial loops */
00012   {
00013     template<typename real_t> inline /* differentiation */
00014     void diff( real_t * dst, real_t const * const src, unsigned sz, int st )
00015     { for ( unsigned i = 0; i < sz-1; dst[i*st] = (i+1)*src[(i+1)*st],  i ++ ) ; };
00016     template<typename coeff_t,typename parm_t> inline /* évaluation */
00017     void horner( parm_t& res, coeff_t const * const mnms, unsigned sz, const parm_t& t, int st = 1  )
00018     { res = 0.0; for ( int p = (sz-1)*st; p != 0; res +=  mnms[p], res *= t, p -= st ) ; res+=mnms[0]; };
00019     template<typename real_t> inline  /* évaluation */
00020     real_t horner( real_t const * const mnms, unsigned sz, const real_t& t, int st = 1  )
00021     { real_t res; horner(res,mnms,sz,t,st); return res; };
00022     template<typename real_t> inline  /* A FAIRE: utiliser st ! */
00023     void dhorner( real_t& p, real_t& dp, real_t const * const mnms, unsigned sz, const real_t& t )/*, int st = 1 )*/
00024     { int n = sz-1; p = mnms[n], dp  = 0.0; for ( int j = n-1; j>=0; dp=dp*t+p, p=p*t+mnms[j], j-- ) ; };
00025 
00026 //     template<typename real_t> inline  /* x <- x+c */
00027 //     void shift( real_t * d, unsigned sz, int st, const real_t& c  )
00028 //     { 
00029 //       int j,k; 
00030 //       for ( j = 0; j <= sz-2; j++ )
00031 //      for( k =n-2; k >= j; d[k*st] += c*d[(k+1)*st], k--); 
00032 //     };
00033   };
00034 //--------------------------------------------------------------------
00035 } //namespace mmx
00036 /********************************************************************/
00037 #endif //