Changeset 1011 for trunk/test/math


Ignore:
Timestamp:
Oct 6, 2011, 9:18:17 AM (10 years ago)
Author:
sam
Message:

test: more Remez exchange experimentations.

Location:
trunk/test/math
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/math/Makefile.am

    r1009 r1011  
    44all-local: $(noinst_PROGRAMS)
    55        test x$(MAKE_FSELF) = xno || make_fself pi$(EXEEXT) pi.self
     6        test x$(MAKE_FSELF) = xno || make_fself poly$(EXEEXT) pi.self
    67        test x$(MAKE_FSELF) = xno || make_fself remez$(EXEEXT) remez.self
    78
     
    1011             $(noinst_PROGRAMS:%$(EXEEXT)=%.exe)
    1112
    12 noinst_PROGRAMS = pi remez
     13noinst_PROGRAMS = pi poly remez
    1314
    1415pi_SOURCES = pi.cpp
     
    1718pi_DEPENDENCIES = $(top_builddir)/src/liblol.a
    1819
     20poly_SOURCES = poly.cpp
     21poly_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
     22poly_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@
     23poly_DEPENDENCIES = $(top_builddir)/src/liblol.a
     24
    1925remez_SOURCES = remez.cpp remez-matrix.h remez-solver.h
    2026remez_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@
  • trunk/test/math/remez.cpp

    r1010 r1011  
    2727static real myfun(real const &x)
    2828{
     29    static real const a0 = real::R_1;
     30    static real const a1 = real(-11184811) >> 26;
     31    static real const b1 = real(-1) / real(6);
     32    static real const b2 = real(1) / real(120);
    2933    real y = sqrt(x);
    3034    if (!y)
    31         return real::R_PI_2;
    32     return sin(real::R_PI_2 * y) / y;
     35        return b2;
     36    return ((sin(y) / y - a0) / x - a1) / x;
    3337}
    3438
     
    4044int main(int argc, char **argv)
    4145{
    42     RemezSolver<4> solver;
    43     solver.Run(0, 1, myfun, myfun, 15);
     46    RemezSolver<3> solver;
     47    //solver.Run(0, 1, myfun, myfun, 15);
     48    solver.Run(0, real::R_PI * real::R_PI >> 2, myfun, myfun, 15);
    4449    //solver.Run(-1, 1, myfun, myfun, 15);
    4550    //solver.Run(0, real::R_PI * real::R_PI >> 4, myfun, myfun, 15);
Note: See TracChangeset for help on using the changeset viewer.