we can create our own high-precision polynomial approximations.legacy
| @@ -60,5 +60,6 @@ test/benchsuite | |||||
| test/quad | test/quad | ||||
| test/sandbox | test/sandbox | ||||
| test/math/pi | test/math/pi | ||||
| test/math/remez | |||||
| tools/make-font | tools/make-font | ||||
| # Our data | # Our data | ||||
| @@ -3,15 +3,21 @@ AM_CPPFLAGS = -I$(top_srcdir)/src | |||||
| all-local: $(noinst_PROGRAMS) | all-local: $(noinst_PROGRAMS) | ||||
| test x$(MAKE_FSELF) = xno || make_fself pi$(EXEEXT) pi.self | test x$(MAKE_FSELF) = xno || make_fself pi$(EXEEXT) pi.self | ||||
| test x$(MAKE_FSELF) = xno || make_fself remez$(EXEEXT) remez.self | |||||
| CLEANFILES = $(noinst_PROGRAMS:%$(EXEEXT)=%.self) \ | CLEANFILES = $(noinst_PROGRAMS:%$(EXEEXT)=%.self) \ | ||||
| $(noinst_PROGRAMS:%$(EXEEXT)=%.elf) \ | $(noinst_PROGRAMS:%$(EXEEXT)=%.elf) \ | ||||
| $(noinst_PROGRAMS:%$(EXEEXT)=%.exe) | $(noinst_PROGRAMS:%$(EXEEXT)=%.exe) | ||||
| noinst_PROGRAMS = pi | |||||
| noinst_PROGRAMS = pi remez | |||||
| pi_SOURCES = pi.cpp | pi_SOURCES = pi.cpp | ||||
| pi_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | pi_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | ||||
| pi_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | pi_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | ||||
| pi_DEPENDENCIES = $(top_builddir)/src/liblol.a | pi_DEPENDENCIES = $(top_builddir)/src/liblol.a | ||||
| remez_SOURCES = remez.cpp | |||||
| remez_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | |||||
| remez_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | |||||
| remez_DEPENDENCIES = $(top_builddir)/src/liblol.a | |||||
| @@ -0,0 +1,53 @@ | |||||
| // | |||||
| // Lol Engine - Sample math program: Chebyshev polynomials | |||||
| // | |||||
| // Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
| // | |||||
| #if defined HAVE_CONFIG_H | |||||
| # include "config.h" | |||||
| #endif | |||||
| #include <cstring> | |||||
| #include "core.h" | |||||
| using namespace lol; | |||||
| static int const ORDER = 12; | |||||
| static int cheby[ORDER][ORDER]; | |||||
| static void make_table() | |||||
| { | |||||
| memset(cheby[0], 0, ORDER * sizeof(int)); | |||||
| cheby[0][0] = 1; | |||||
| memset(cheby[1], 0, ORDER * sizeof(int)); | |||||
| cheby[1][1] = 1; | |||||
| for (int i = 2; i < ORDER; i++) | |||||
| { | |||||
| cheby[i][0] = -cheby[i - 2][0]; | |||||
| for (int j = 1; j < ORDER; j++) | |||||
| cheby[i][j] = 2 * cheby[i - 1][j - 1] - cheby[i - 2][j]; | |||||
| } | |||||
| } | |||||
| int main(int argc, char **argv) | |||||
| { | |||||
| make_table(); | |||||
| for (int i = 0; i < ORDER; i++) | |||||
| { | |||||
| for (int j = 0; j < ORDER; j++) | |||||
| printf("% 5i ", cheby[i][j]); | |||||
| printf("\n"); | |||||
| } | |||||
| return EXIT_SUCCESS; | |||||
| } | |||||