Developer documentation

loops_upoldse.hpp
Go to the documentation of this file.
1 /********************************************************************
2  * This file is part of the source code of the realroot library.
3  * Author(s): J.P. Pavone, GALAAD, INRIA
4  * $Id: upoldse.hpp,v 1.1 2005/07/11 10:03:56 jppavone Exp $
5  ********************************************************************/
6 #ifndef realroot_SOLVE_SBDSLV_LOOPS_UPOLDSE_HPP
7 #define realroot_SOLVE_SBDSLV_LOOPS_UPOLDSE_HPP
8 //--------------------------------------------------------------------
9 namespace mmx {
10 //--------------------------------------------------------------------
11 namespace upoldse_ /* univariate dense polynomial loops */
12 {
13 template<typename real_t> inline /* differentiation */
14 void diff( real_t * dst, real_t const * const src, unsigned sz, int st )
15 {
16  for ( unsigned i = 0; i < sz-1; dst[i*st] = (i+1)*src[(i+1)*st], i ++ ) ;
17 }
18 template<typename coeff_t,typename parm_t> inline /* évaluation */
19 void horner( parm_t& res, coeff_t const * const mnms, unsigned sz, const parm_t& t, int st = 1 )
20 {
21  res = 0.0;
22  for ( int p = (sz-1)*st; p != 0; res += mnms[p], res *= t, p -= st ) ;
23  res+=mnms[0];
24 }
25 template<typename real_t> inline /* évaluation */
26 real_t horner( real_t const * const mnms, unsigned sz, const real_t& t, int st = 1 )
27 {
28  real_t res;
29  horner(res,mnms,sz,t,st);
30  return res;
31 }
32 template<typename real_t> inline /* A FAIRE: utiliser st ! */
33 void dhorner( real_t& p, real_t& dp, real_t const * const mnms, unsigned sz, const real_t& t )/*, int st = 1 )*/
34 {
35  int n = sz-1;
36  p = mnms[n], dp = 0.0;
37  for ( int j = n-1; j>=0; dp=dp*t+p, p=p*t+mnms[j], j-- ) ;
38 }
39 
40 // template<typename real_t> inline /* x <- x+c */
41 // void shift( real_t * d, unsigned sz, int st, const real_t& c )
42 // {
43 // int j,k;
44 // for ( j = 0; j <= sz-2; j++ )
45 // for( k =n-2; k >= j; d[k*st] += c*d[(k+1)*st], k--);
46 // };
47 };
48 //--------------------------------------------------------------------
49 } //namespace mmx
50 /********************************************************************/
51 #endif //
Definition: array.hpp:12
void diff(real_t *dst, real_t const *const src, unsigned sz, int st)
Definition: loops_upoldse.hpp:14
void horner(parm_t &res, coeff_t const *const mnms, unsigned sz, const parm_t &t, int st=1)
Definition: loops_upoldse.hpp:19
void dhorner(real_t &p, real_t &dp, real_t const *const mnms, unsigned sz, const real_t &t)
Definition: loops_upoldse.hpp:33
Home