Last change
on this file since 985 was
985,
checked in by sam, 11 years ago
|
test: start working on a Remez exchange algorithm implementation so that
we can create our own high-precision polynomial approximations.
|
-
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) 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 | |
---|
17 | #include "core.h" |
---|
18 | |
---|
19 | using namespace lol; |
---|
20 | |
---|
21 | static int const ORDER = 12; |
---|
22 | |
---|
23 | static int cheby[ORDER][ORDER]; |
---|
24 | |
---|
25 | static void make_table() |
---|
26 | { |
---|
27 | memset(cheby[0], 0, ORDER * sizeof(int)); |
---|
28 | cheby[0][0] = 1; |
---|
29 | memset(cheby[1], 0, ORDER * sizeof(int)); |
---|
30 | cheby[1][1] = 1; |
---|
31 | |
---|
32 | for (int i = 2; i < ORDER; i++) |
---|
33 | { |
---|
34 | cheby[i][0] = -cheby[i - 2][0]; |
---|
35 | for (int j = 1; j < ORDER; j++) |
---|
36 | cheby[i][j] = 2 * cheby[i - 1][j - 1] - cheby[i - 2][j]; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | int main(int argc, char **argv) |
---|
41 | { |
---|
42 | make_table(); |
---|
43 | |
---|
44 | for (int i = 0; i < ORDER; i++) |
---|
45 | { |
---|
46 | for (int j = 0; j < ORDER; j++) |
---|
47 | printf("% 5i ", cheby[i][j]); |
---|
48 | printf("\n"); |
---|
49 | } |
---|
50 | |
---|
51 | return EXIT_SUCCESS; |
---|
52 | } |
---|
53 | |
---|
Note: See
TracBrowser
for help on using the repository browser.