Git Product home page Git Product logo

fmath's Introduction

fast approximate function of exponential function exp and log

How to use

include fmath.hpp and use fmath::log, fmath::exp, fmath::expd.

fmath::PowGenerator is a class to generate a function to compute pow(x, y) of x >= 0 for a given fixed y > 0.

eg. fmath::PowGenerator f(1.234); f.get(x) returns pow(x, 1.234);

Prototpye of function

  • float fmath::exp(float);
  • float fmath::log(float);
  • double fmath::logd(double);
  • __m128 fmath::exp_ps(__m128);
  • __m128 fmath::log_ps(__m128);
  • void fmath::expv_d(double *p, size_t n); // for double p[n];

Experimental

If you install xbyak and define FMATH_USE_XBYAK before including fmath.hpp, then fmath::exp() and fmath::exp_ps() will be about 10~20 % faster. Xbyak version uses SSE4.1 if available.

AVX version of fmath::exp is experimental

Remark

gcc puts warnings such as "dereferencing type-punned pointer will break strict-aliasing rules." It is no problem. Please change #if 1 in fmath.hpp:423 if you worry about it. But it causes a little slower.

-ffast-math option of gcc may generate bad code for fmath::expd.

License

modified new BSD License http://opensource.org/licenses/BSD-3-Clause

History

  • 2012/Oct/30 fix fmath::expd for small value
  • 2011/Aug/26 add fmath::expd_v
  • 2011/Mar/25 exp supports AVX
  • 2011/Mar/25 exp, exp_ps support avx
  • 2010/Feb/16 add fmath::exp_ps, log_ps and optimize functions
  • 2010/Jan/10 add fmath::PowGenerator
  • 2009/Dec/28 add fmath::log()
  • 2009/Dec/09 support cygwin
  • 2009/Dec/08 first version

Author

MITSUNARI Shigeo([email protected]) http://herumi.in.coocan.jp/

Benchmark

compiler

  • Visual Studio 2010RC
  • icc 11.1
  • gcc 4.3.2 on cygwin
  • gcc 4.4.1 on 64bit Linux

option

  • cl(icl):

/Ox /Ob2 /GS- /Zi /D_SECURE_SCL=0 /MD /Oy /arch:SSE2 /fp:fast /DNOMINMAX

  • gcc:

-O3 -fomit-frame-pointer -DNDEBUG -fno-operator-names -msse2 -mfpmath=sse -march=native

see fastexp.cpp

fmath's People

Contributors

herumi avatar 80c535 avatar t-suzuki avatar

Watchers

weimingtom avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.