Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Created December 1, 2010 08:46
Show Gist options
  • Save pervognsen/723175 to your computer and use it in GitHub Desktop.
Save pervognsen/723175 to your computer and use it in GitHub Desktop.
double chebyshev_per2(int n, double x)
{
double a = 1.0, b = x;
#define DO(i) case i: { const double t = b; b = 2.0 * x * b - a; a = t; }
switch (n) { DO(9) DO(8) DO(7) DO(6) DO(5) DO(4) DO(3) DO(2) DO(1) }
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment