diff --git a/.gitignore b/.gitignore index 31e56df1..fca8d554 100644 --- a/.gitignore +++ b/.gitignore @@ -60,5 +60,6 @@ test/benchsuite test/quad test/sandbox test/math/pi +test/math/remez tools/make-font # Our data diff --git a/test/math/Makefile.am b/test/math/Makefile.am index 0f630200..465f66be 100644 --- a/test/math/Makefile.am +++ b/test/math/Makefile.am @@ -3,15 +3,21 @@ AM_CPPFLAGS = -I$(top_srcdir)/src all-local: $(noinst_PROGRAMS) 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) \ $(noinst_PROGRAMS:%$(EXEEXT)=%.elf) \ $(noinst_PROGRAMS:%$(EXEEXT)=%.exe) -noinst_PROGRAMS = pi +noinst_PROGRAMS = pi remez pi_SOURCES = pi.cpp pi_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ pi_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ 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 + diff --git a/test/math/remez.cpp b/test/math/remez.cpp new file mode 100644 index 00000000..44d8a1cc --- /dev/null +++ b/test/math/remez.cpp @@ -0,0 +1,53 @@ +// +// Lol Engine - Sample math program: Chebyshev polynomials +// +// Copyright: (c) 2005-2011 Sam Hocevar +// 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 + +#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; +} +