Changeset 1119


Ignore:
Timestamp:
Dec 29, 2011, 7:36:54 PM (8 years ago)
Author:
sam
Message:

math: make everything clean for a LolRemez release.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.am

    r1094 r1119  
    1212
    1313dist: lolunit-$(LOLUNIT_VERSION).tar.gz
     14dist: lolremez-$(LOLREMEZ_VERSION).tar.gz
    1415
     16.PHONY: lolunit-$(LOLUNIT_VERSION).tar.gz
    1517lolunit-$(LOLUNIT_VERSION).tar.gz:
    1618        rm -rf lolunit-$(LOLUNIT_VERSION)
     
    2123        rm -rf lolunit-$(LOLUNIT_VERSION)
    2224
     25.PHONY: lolremez-$(LOLREMEZ_VERSION).tar.gz
     26lolremez-$(LOLREMEZ_VERSION).tar.gz:
     27        rm -rf lolremez-$(LOLREMEZ_VERSION)
     28        mkdir lolremez-$(LOLREMEZ_VERSION)
     29        mkdir lolremez-$(LOLREMEZ_VERSION)/lol
     30        mkdir lolremez-$(LOLREMEZ_VERSION)/lol/math
     31        cp $(top_srcdir)/src/real.cpp $(top_srcdir)/test/math/remez.cpp \
     32          lolremez-$(LOLREMEZ_VERSION)
     33        cat $(top_srcdir)/src/real.cpp | sed 's@core.h@lol/math/real.h@' > \
     34          lolremez-$(LOLREMEZ_VERSION)/real.cpp
     35        cp $(top_srcdir)/src/lol/math/real.h \
     36           $(top_srcdir)/src/lol/math/matrix.h \
     37           $(top_srcdir)/src/lol/math/remez.h \
     38          lolremez-$(LOLREMEZ_VERSION)/lol/math
     39        printf 'remez: real.cpp remez.cpp\n' > lolremez-$(LOLREMEZ_VERSION)/Makefile
     40        printf '\t$$(CXX) -I. -O2 -g -ggdb $$^ -o $$@\n' >> lolremez-$(LOLREMEZ_VERSION)/Makefile
     41        printf 'clean:\n' >> lolremez-$(LOLREMEZ_VERSION)/Makefile
     42        printf '\trm -f remez\n' >> lolremez-$(LOLREMEZ_VERSION)/Makefile
     43        tar cvzf lolremez-$(LOLREMEZ_VERSION).tar.gz lolremez-$(LOLREMEZ_VERSION)
     44        rm -rf lolremez-$(LOLREMEZ_VERSION)
     45
  • trunk/configure.ac

    r1112 r1119  
    1111LOLUNIT_VERSION=0.1
    1212AC_SUBST(LOLUNIT_VERSION)
     13LOLREMEZ_VERSION=0.1
     14AC_SUBST(LOLREMEZ_VERSION)
    1315
    1416AM_CONFIG_HEADER(config.h)
  • trunk/src/lol/math/matrix.h

    r1117 r1119  
    1717#define __LOL_MATH_MATRIX_H__
    1818
     19#include <stdint.h>
    1920#include <cmath>
    2021#if !defined __ANDROID__
  • trunk/src/lol/math/remez.h

    r1117 r1119  
    1010
    1111//
    12 // The Remez class
    13 // ---------------
     12// The RemezSolver class
     13// ---------------------
    1414//
    1515
    1616#if !defined __LOL_MATH_REMEZ_H__
    1717#define __LOL_MATH_REMEZ_H__
     18
     19#include <cstdio>
     20
     21#include "lol/math/matrix.h"
    1822
    1923namespace lol
     
    5660
    5761        PrintPoly();
     62    }
     63
     64    inline void Run(T a, T b, RealFunc *func, int steps)
     65    {
     66        Run(a, b, func, NULL, steps);
    5867    }
    5968
     
    320329    T Weight(T const &x)
    321330    {
    322         return m_weight(x * m_k2 + m_k1);
     331        if (m_weight)
     332            return m_weight(x * m_k2 + m_k1);
     333        return 1;
    323334    }
    324335
  • trunk/test/math/remez.cpp

    r1117 r1119  
    1313#endif
    1414
    15 #include <cstdio>
    16 #include <cstdlib>
    17 
    1815#if USE_SDL && defined __APPLE__
    1916#   include <SDL_main.h>
     
    2118
    2219#include "lol/math/real.h"
    23 #include "lol/math/matrix.h"
    2420#include "lol/math/remez.h"
    2521
     
    2723using lol::RemezSolver;
    2824
    29 /* The function we want to approximate */
    30 real myfun(real const &y)
    31 {
    32     real x = sqrt(y);
    33     return (sin(x) - x) / (x * y);
    34 }
    35 
    36 real myerr(real const &y)
    37 {
    38     real x = sqrt(y);
    39     return sin(x) / (x * y);
    40 }
     25/* See the tutorial at http://lol.zoy.org/wiki/doc/maths/remez */
     26real f(real const &x) { return exp(x); }
    4127
    4228int main(int argc, char **argv)
    4329{
    44     RemezSolver<2, real> solver;
    45     solver.Run(real::R_1 >> 400, real::R_PI_2 * real::R_PI_2, myfun, myerr, 40);
    46 
    47     return EXIT_SUCCESS;
     30    RemezSolver<4, real> solver;
     31    solver.Run(-1, 1, f, 30);
     32    return 0;
    4833}
    4934
Note: See TracChangeset for help on using the changeset viewer.