source: trunk/test/math/remez.cpp @ 1012

Last change on this file since 1012 was 1012, checked in by sam, 9 years ago

test: more Remez exchange experimentations.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Lol Engine - Sample math program: Chebyshev polynomials
3//
4// Copyright: (c) 2005-2011 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
20using namespace lol;
21using namespace std;
22
23#include "remez-matrix.h"
24#include "remez-solver.h"
25
26/* The function we want to approximate */
27static real myfun(real const &x)
28{
29    static real const a0 = real::R_1;
30    static real const a1 = real(-11184811) >> 26;
31    static real const b1 = real(-1) / real(6);
32    static real const b2 = real(1) / real(120);
33    real y = sqrt(x);
34    return sin(y) / y;
35}
36
37static real myerr(real const &x)
38{
39    return real::R_1;
40}
41
42int main(int argc, char **argv)
43{
44    RemezSolver<6> solver;
45    //solver.Run(0, 1, myfun, myfun, 15);
46    solver.Run(exp((real)-100), real::R_PI * real::R_PI >> 2, myfun, myfun, 15);
47    //solver.Run(-1, 1, myfun, myfun, 15);
48    //solver.Run(0, real::R_PI * real::R_PI >> 4, myfun, myfun, 15);
49
50    return EXIT_SUCCESS;
51}
52
Note: See TracBrowser for help on using the repository browser.