Skip to content

Instantly share code, notes, and snippets.

@eric-wieser
Created April 2, 2014 13:52
Show Gist options
  • Save eric-wieser/9934574 to your computer and use it in GitHub Desktop.
Save eric-wieser/9934574 to your computer and use it in GitHub Desktop.
template<int N>
std::array<float, N - 1> gradient(const std::array<float, N> &datain, float dx){
std::array<float, N - 1> result;
for (unsigned long i = 0; i < N-1; i++){
result[i] = (datain[i] + datain[i + 1]) / dx;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment