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

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

test: various improvements to the Remez exchange solver.

  • Property svn:keywords set to Id
File size: 974 bytes
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    real y = sqrt(x);
30    return (sin(y) - y) / (x * y);
31}
32
33static real myerr(real const &x)
34{
35    real y = sqrt(x);
36    return re(x * y);
37}
38
39int main(void)
40{
41    RemezSolver<4> solver;
42    solver.Run(real::R_1 >> 400, real::R_PI_2 * real::R_PI_2, myfun, myerr, 15);
43
44    return EXIT_SUCCESS;
45}
46
Note: See TracBrowser for help on using the repository browser.