Hermite interpollation

References : Posted by various
Notes :
These are all different ways to do the same thing : hermite interpollation. Try'm all and benchmark.
Code :
// original
inline float hermite1(float x, float y0, float y1, float y2, float y3)
{
    // 4-point, 3rd-order Hermite (x-form)
    float c0 = y1;
    float c1 = 0.5f * (y2 - y0);
    float c2 = y0 - 2.5f * y1 + 2.f * y2 - 0.5f * y3;
    float c3 = 1.5f * (y1 - y2) + 0.5f * (y3 - y0);

    return ((c3 * x + c2) * x + c1) * x + c0;
}

// james mccartney
inline float hermite2(float x, float y0, float y1, float y2, float y3)
{
    // 4-point, 3rd-order Hermite (x-form)
    float c0 = y1;
    float c1 = 0.5f * (y2 - y0);
    float c3 = 1.5f * (y1 - y2) + 0.5f * (y3 - y0);
    float c2 = y0 - y1 + c1 - c3;

    return ((c3 * x + c2) * x + c1) * x + c0;
}

// james mccartney
inline float hermite3(float x, float y0, float y1, float y2, float y3)
{
        // 4-point, 3rd-order Hermite (x-form)
        float c0 = y1;
        float c1 = 0.5f * (y2 - y0);
        float y0my1 = y0 - y1;
        float c3 = (y1 - y2) + 0.5f * (y3 - y0my1 - y2);
        float c2 = y0my1 + c1 - c3;

        return ((c3 * x + c2) * x + c1) * x + c0;
}

// laurent de soras
inline float hermite4(float frac_pos, float xm1, float x0, float x1, float x2)
{
   const float    c     = (x1 - xm1) * 0.5f;
   const float    v     = x0 - x1;
   const float    w     = c + v;
   const float    a     = w + v + (x2 - x0) * 0.5f;
   const float    b_neg = w + a;

   return ((((a * frac_pos) - b_neg) * frac_pos + c) * frac_pos + x0);
}

Comments
from : theguylle
comment : great sources but what is Hermite ? if you don't describe what is your code made for, you will made a great sources but I don't know why? cheers Paul

from : bram[AT]musicdsp[DOT]org
comment : hermite is interpollation. have a look around the archive, you'll see that the word 'hermite' is in more than one item ;-) -bram

from : ronaldowf[AT]sanepar[DOT]com[DOT]br
comment : Please, would like to know of hermite code it exists in delphi. thankful Ronaldo Cascavel/Paraná/Brasil

from : m[DOT]magrini[AT]NOSPAMbad-sector[DOT]com
comment : Please, add, at least, the meaning of each parameter (I mean x, y0, y1,y2, y3).... m.

from : musicdsp[AT][remove this]dsparsons[DOT]co[DOT]uk
comment : Ronaldo, it doesn't take much to translate these to Delphi - for float, either use single or double to your preference! Looking at the codes, it seems quite clear that the parameters follow a pattern of: Sample Position between middle two samples, then the sample before current, current sample, curernt sample +1, current sample +2. HTH DSP

from : antiprosynthesis[AT]hotmail[DOT]com
comment : What are all these variables standing for? Not very clear :|

from : George
comment : parameters are allright. xm1 ---> x[n-1] x0 ---> x[n] x1 ---> x[n+1] x2 ---> x[n+2] fractional position stands for a fraction between 0 and 1 to interpolate

from : paranoias-poison-door[AT]gmail[DOT]youknowwhatandtakeoutthehyphens
comment : Couldn't #2 be sped up a hair by commenting out float c0 = y1; and then replacing c0 with y1 in the return line? Or do the compilers do that kind of thing automatically when they optimize?

from : asynth[AT]io[DOT]com
comment : "Couldn't #2 be sped up a hair" It gets optimized out.