Skip to content

Commit

Permalink
Merge pull request #13 from eddelbuettel/master
Browse files Browse the repository at this point in the history
define STRICT_R_HEADERS, include float.h, adjust dbl eps constant
  • Loading branch information
jmgirard authored Apr 28, 2021
2 parents 283f5b8 + 75c49a0 commit 6b11f60
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/circular.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define STRICT_R_HEADERS
#include <float.h>
#include <Rcpp.h>

using namespace Rcpp;
Expand All @@ -15,7 +17,7 @@ double angle_mean(NumericVector x) {
}
double R = (sqrt(pow(S, 2) + pow(C, 2)) / n);
// A vector length of zero has no angular mean
if (R > DOUBLE_EPS) {
if (R > DBL_EPSILON) {
out = std::atan2(S, C);
} else {
out = NA_REAL;
Expand Down Expand Up @@ -45,7 +47,7 @@ double angle_median(NumericVector x) {
// Find candidates for the median (with the minimum average deviation)
for(int i(0); i < n; i++) {
dev_val = angle_dev(x, x[i]);
if(((dev_val - minimum) / n) < -DOUBLE_EPS) {
if(((dev_val - minimum) / n) < -DBL_EPSILON) {
minimum = dev_val;
candidates[0] = x[i];
} else if (fabs(dev_val - minimum) <= 1e-8) {
Expand Down

0 comments on commit 6b11f60

Please sign in to comment.