Skip to content

Instantly share code, notes, and snippets.

@peddamat
Created May 22, 2013 15:49
Show Gist options
  • Save peddamat/5628641 to your computer and use it in GitHub Desktop.
Save peddamat/5628641 to your computer and use it in GitHub Desktop.
Matrix dx(Matrix A) {
int M = A.getRowDimension();
int N = A.getColumnDimension();
Matrix R = new Matrix(M, N);
for (int y = 0; y < M; y++)
for (int x = 1; x < N-1; x++) {
double d1 = A.get(y,x-1);
double d2 = A.get(y,x+1);
double r = (d2 - d1)/2.0;
R.set(y,x,r);
}
return R;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment