Skip to content

Instantly share code, notes, and snippets.

@rygorous
Created December 1, 2010 07:38
Show Gist options
  • Save rygorous/723121 to your computer and use it in GitHub Desktop.
Save rygorous/723121 to your computer and use it in GitHub Desktop.
Chebyshev
__forceinline double chebyshev_ryg(int n, double x)
{
if (n == 0) return 1.0;
if (n == 1) return x;
double t = x, t1 = 1, t2;
// if you don't use a for here, the vc++ loop optimizer doesn't get it!
for (int i=1; i<n; i++) {
t2 = t1;
t1 = t;
t = 2.0 * x * t1 - t2;
}
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment