Skip to content

Instantly share code, notes, and snippets.

@Diggsey
Created May 23, 2015 23:02
Show Gist options
  • Save Diggsey/43428b29c03681c0c021 to your computer and use it in GitHub Desktop.
Save Diggsey/43428b29c03681c0c021 to your computer and use it in GitHub Desktop.
float acc[N];
acc[0] = S::identity();
for (int i = 0; i < (N-1); ++i) {
acc[i + 1] = S::op(acc[i], x[i]);
}
float dacc0[N];
dacc0[N - 1] = 1.0f;
for (int i = (N - 1); i > 0; --i) {
dacc0[i - 1] = S::dop0(acc[i], x[i]);
}
float y[N];
for (int i = 0; i < N; ++i) {
float dacc1 = S::dop1(acc[i], x[i]);
y[i] = dacc1*dacc0[i];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment