Giter VIP home page Giter VIP logo

fine's Introduction

FINE

Fast INverse Exponentiation

Compute x^(1/n) and x^n faster than standard methods

How to install and execute?

Make sure you are using at least C++20 standard for this library

Just clone, compile and run using

g++ -std=c++2a -O2 -Wall -pedantic test.cpp && ./test.out

The following program illustrates a basic example

#include "FINE.h"
#include "FINEd.h"
#include <cmath>
#include <cstdio>

int main(int argc, char *argv[]) {

    float a = 19.2f;
    int n = 2;

    printf("FINE Value: %f\n", Q_exp(a, n));
    printf("FINEd Value: %f\n", Q_exp_double(a, n));
    printf("C value: %f\n", pow(a, n));
    printf("\n");
    printf("FINE Value: %f\n", Q_nroot(a, n));
    printf("FINEd Value: %f\n", Q_nroot_double(a, n));
    printf("Quake 3 Value: %f\n", Quake(a));
    printf("C value: %f\n", pow(a, -1./n));
    
    return 0;
}

Results

For a trial run with the above program,

Exponent
FINE Value: 369.421783
FINEd Value: 369.421772
C value: 368.640029


Inverse-Root
FINE Value: 0.226177
FINEd Value: 0.226177
Quake 3 Value: 0.228213
C value: 0.228218

When the computations were repeated with different values for N=50,000 times (in microseconds)

Exponent
Times (float, double, C): 390, 387, 2306

Inverse-Root
Times (float, double, Quake, C): 1291, 1629, 658, 2069

The Quake method supports only inverse square roots

How does this work?

This work takes inspiration from the Fast Inverse Square Root from the Quake 3 Engine (although sources mention it is older) and generalizes it to both 32-bit and 64-bit floating-point values.

Note that fast computation of inverse n-th root requires fast exponentiation (x^n) as well and is included.

Whom to contact?

Please direct your queries to gpavanb1 for any questions.

fine's People

Contributors

gpavanb1 avatar

Stargazers

 avatar  avatar

Watchers

 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.