소스 검색

test: start working on a Remez exchange algorithm implementation so that

we can create our own high-precision polynomial approximations.
legacy
Sam Hocevar sam 13 년 전
부모
커밋
b7a1270b9a
3개의 변경된 파일61개의 추가작업 그리고 1개의 파일을 삭제
  1. +1
    -0
      .gitignore
  2. +7
    -1
      test/math/Makefile.am
  3. +53
    -0
      test/math/remez.cpp

+ 1
- 0
.gitignore 파일 보기

@@ -60,5 +60,6 @@ test/benchsuite
test/quad
test/sandbox
test/math/pi
test/math/remez
tools/make-font
# Our data

+ 7
- 1
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


+ 53
- 0
test/math/remez.cpp 파일 보기

@@ -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;
}


불러오는 중...
취소
저장