Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is p_a_inv needed ? #111

Open
kagiannis opened this issue Jun 9, 2015 · 0 comments
Open

Is p_a_inv needed ? #111

kagiannis opened this issue Jun 9, 2015 · 0 comments

Comments

@kagiannis
Copy link
Contributor

Is p_a_inv needed ? It has many branches and maybe not so good precision.
p_inv is already fast.

Some platforms have hardware division that is faster than software division.
I think we can either make an inline function like this

inline PAL_DIV(float a,float b){
#ifdef HAVE_DIV
    return a/b;
#else
    /* compute inverse */
    union {
        float f;
        uint32_t x;
    } u = {b};
    /* First approximation */
    u.x = 0x7EEEEBB3 - u.x;
    /* Refine */
    u.f = u.f * (2 - u.f * cur);
    u.f = u.f * (2 - u.f * cur);
    u.f = u.f * (2 - u.f * cur);
    return a*u.f
#endif
}

and use it when division is needed
or use division in every case and let the compiler to do the division

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant