Last change
on this file since 1010 was
1010,
checked in by sam, 11 years ago

test: allow to perform Remez solving on an arbitrary range.


Property svn:keywords set to
Id

File size:
1.1 KB

Line  

1  // 

2  // Lol Engine  Sample math program: Chebyshev polynomials 

3  // 

4  // Copyright: (c) 20052011 Sam Hocevar <sam@hocevar.net> 

5  // This program is free software; you can redistribute it and/or 

6  // modify it under the terms of the Do What The Fuck You Want To 

7  // Public License, Version 2, as published by Sam Hocevar. See 

8  // http://sam.zoy.org/projects/COPYING.WTFPL for more details. 

9  // 

10  

11  #if defined HAVE_CONFIG_H 

12  # include "config.h" 

13  #endif 

14  

15  #include <cstring> 

16  #include <cstdio> 

17  

18  #include "core.h" 

19  

20  using namespace lol; 

21  using namespace std; 

22  

23  #include "remezmatrix.h" 

24  #include "remezsolver.h" 

25  

26  /* The function we want to approximate */ 

27  static real myfun(real const &x) 

28  { 

29  real y = sqrt(x); 

30  if (!y) 

31  return real::R_PI_2; 

32  return sin(real::R_PI_2 * y) / y; 

33  } 

34  

35  static real myerr(real const &x) 

36  { 

37  return real::R_1; 

38  } 

39  

40  int main(int argc, char **argv) 

41  { 

42  RemezSolver<4> solver; 

43  solver.Run(0, 1, myfun, myfun, 15); 

44  //solver.Run(1, 1, myfun, myfun, 15); 

45  //solver.Run(0, real::R_PI * real::R_PI >> 4, myfun, myfun, 15); 

46  

47  return EXIT_SUCCESS; 

48  } 

49  

Note: See
TracBrowser
for help on using the repository browser.