-
Notifications
You must be signed in to change notification settings - Fork 6
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
SymbolixAU
committed
Sep 5, 2018
1 parent
5f69431
commit fe3a9dd
Showing
11 changed files
with
144 additions
and
11 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
Binary file not shown.
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,11 @@ | ||
#ifndef RCPP_VIRIDIS_BASE_H | ||
#define RCPP_VIRIDIS_BASE_H | ||
|
||
// extensions to base:: | ||
Rcpp::NumericVector m_diff( Rcpp::NumericVector x ); | ||
|
||
Rcpp::NumericVector m_range( Rcpp::NumericVector x ); | ||
|
||
Rcpp::NumericVector m_rescale( Rcpp::NumericVector x); | ||
|
||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <Rcpp.h> | ||
#include <algorithm> | ||
using namespace Rcpp; | ||
|
||
Rcpp::NumericVector m_diff(Rcpp::NumericVector x) { | ||
int n = x.size() - 1; | ||
Rcpp::NumericVector difference(n); | ||
int i = 0; | ||
for (i = 0; i < n; i++) { | ||
difference[i] = x[i+1] - x[i]; | ||
} | ||
return difference; | ||
} | ||
|
||
Rcpp::NumericVector m_range(Rcpp::NumericVector x) { | ||
Rcpp::NumericVector rng(2); | ||
rng[0] = min(na_omit(x)); | ||
rng[1] = max(na_omit(x)); | ||
return rng; | ||
} | ||
|
||
|
||
// Always rescales to (0, 1) | ||
Rcpp::NumericVector m_rescale( Rcpp::NumericVector x ) { | ||
int n = x.size(); | ||
Rcpp::NumericVector rescaled(n); | ||
Rcpp::NumericVector rng = m_range(x); | ||
Rcpp::NumericVector diff_from = m_diff(rng); // should only be one value! | ||
|
||
double this_diff = std::max(1.0, diff_from[0]); | ||
|
||
int i = 0; | ||
|
||
for (i = 0; i < n; i++) { | ||
rescaled[i] = (x[i] - rng[0]) / this_diff; | ||
} | ||
return rescaled; | ||
} | ||
|
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