OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This program is free software; you can redistribute it and/or modify |
| 3 * it under the terms of the GNU General Public License version 2 as |
| 4 * published by the Free Software Foundation; |
| 5 * |
| 6 * This program is distributed in the hope that it will be useful, |
| 7 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 * GNU General Public License for more details. |
| 10 * |
| 11 * You should have received a copy of the GNU General Public License |
| 12 * along with this program; if not, write to the Free Software |
| 13 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 14 */ |
| 15 // Adapted for ns3 from GNU Scientific library version 1.9 file:cheb_eval.c by J
ohn Abraham<jabraham3@mail.gatech.edu> |
| 16 |
| 17 #include "chebyshev.h" |
| 18 #include <math.h> |
| 19 #include "gsl_sf_result.h" |
| 20 #include "gsl_errno.h" |
| 21 #include "gsl_machine.h" |
| 22 |
| 23 static inline int |
| 24 cheb_eval_e(const cheb_series * cs, |
| 25 const double x, |
| 26 gsl_sf_result * result) |
| 27 { |
| 28 int j; |
| 29 double d = 0.0; |
| 30 double dd = 0.0; |
| 31 |
| 32 double y = (2.0*x - cs->a - cs->b) / (cs->b - cs->a); |
| 33 double y2 = 2.0 * y; |
| 34 |
| 35 double e = 0.0; |
| 36 |
| 37 for(j = cs->order; j>=1; j--) { |
| 38 double temp = d; |
| 39 d = y2*d - dd + cs->c[j]; |
| 40 e += fabs(y2*temp) + fabs(dd) + fabs(cs->c[j]); |
| 41 dd = temp; |
| 42 } |
| 43 |
| 44 {· |
| 45 double temp = d; |
| 46 d = y*d - dd + 0.5 * cs->c[0]; |
| 47 e += fabs(y*temp) + fabs(dd) + 0.5 * fabs(cs->c[0]); |
| 48 } |
| 49 |
| 50 result->val = d; |
| 51 result->err = GSL_DBL_EPSILON * e + fabs(cs->c[cs->order]); |
| 52 |
| 53 return GSL_SUCCESS; |
| 54 } |
| 55 |
OLD | NEW |