Changeset 1005 for trunk/test/math
 Timestamp:
 Oct 4, 2011, 3:35:45 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/math/remez.cpp
r997 r1005 14 14 15 15 #include <cstring> 16 #include <cstdio> 16 17 17 18 #include "core.h" … … 20 21 21 22 /* The order of the approximation we're looking for */ 22 static int const ORDER = 8;23 static int const ORDER = 4; 23 24 24 25 /* The function we want to approximate */ 25 26 static real myfun(real const &x) 26 27 { 27 static real const one = 1.0; 28 if (!x) 29 return real::R_PI_2; 30 return sin(x * real::R_PI_2) / x; 31 //return cos(x)  one; 32 //return exp(x); 28 return exp(x); 29 //if (!x) 30 // return real::R_PI_2; 31 //return sin(x * real::R_PI_2) / x; 32 } 33 34 static real myerror(real const &x) 35 { 36 return myfun(x); 37 //return real::R_1; 33 38 } 34 39 … … 206 211 static void remez_findzeroes(real *coeff, real *zeroes, real *control) 207 212 { 208 /* FIXME: this is fake for now */209 213 for (int i = 0; i < ORDER + 1; i++) 210 214 { … … 278 282 final = maxerror; 279 283 control[i] = (a + b) * (real)0.5; 280 printf("%g ( in%g)\n", (double)maxerror, (double)control[i]);284 printf("%g (at %g)\n", (double)maxerror, (double)control[i]); 281 285 break; 282 286 } … … 314 318 mat.m[i][n] = sum; 315 319 } 316 mat.m[i][ORDER + 1] = (real)(1 + (i & 1) * 2); 320 if (i & 1) 321 mat.m[i][ORDER + 1] = fabs(myerror(control[i])); 322 else 323 mat.m[i][ORDER + 1] = fabs(myerror(control[i])); 317 324 } 318 325
Note: See TracChangeset
for help on using the changeset viewer.