forked from dankelley/oce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <Rcpp.h> | ||
using namespace Rcpp; | ||
|
||
// This is a utility function called by matrixSmooth, | ||
// so it does not get a wrapper inserted into the R namespace; | ||
// that's why there is no roxygen @export here, and no roxygen | ||
// documentation, either. However, we need to tell Rcpp to export | ||
// it, so matrixSmooth() can .Call() it. | ||
// | ||
// [[Rcpp::export]] | ||
|
||
NumericMatrix matrix_smooth(NumericMatrix mat) | ||
{ | ||
int ni = mat.nrow(), nj=mat.ncol(); | ||
NumericMatrix res(ni, nj); | ||
// copy edges (FIXME: could use 1D smoother here) | ||
for (int j = 0; j < nj; j++) { | ||
res(0, j) = mat(0, j); | ||
res(ni-1, j) = mat(ni-1, j); | ||
} | ||
for (int i = 0; i < ni; i++) { | ||
res(i, 0) = mat(i, 0); | ||
res(i, nj-1) = mat(i, nj-1); | ||
} | ||
// smooth middle | ||
for (int i = 1; i < ni - 1; i++) | ||
for (int j = 1; j < nj - 1; j++) | ||
res(i, j) = (2.0*mat(i, j) + | ||
mat(i-1, j) + mat(i+1, j) + mat(i, j-1) + mat(i, j+1)) / 6.0; | ||
return(res); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters