00001
00002
00003
00004
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_
00012 {
00013 template<typename real_t> inline
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
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
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
00023 void dhorner( real_t& p, real_t& dp, real_t const * const mnms, unsigned sz, const real_t& t )
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
00027
00028
00029
00030
00031
00032
00033 };
00034
00035 }
00036
00037 #endif //