Skip to content

Commit 5365d22

Browse files
committed
Merge branch 'issue-#762'
2 parents 4ff04e6 + b0df88e commit 5365d22

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

R/decostand.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
warning("input data contains negative entries: result may be non-sense")
1515
}
1616
}
17-
else k <- .Machine$double.eps
17+
else k <- 0 # all pmax.int(k,...) should be dropped but test first
1818
attr <- NULL
1919
switch(method, total = {
2020
if (missing(MARGIN))

src/vegdist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static double veg_chord(double *x, int nr, int nc, int i1, int i2)
187187
i2 += nr;
188188
}
189189

190-
if (count == 0) return NA_REAL;
190+
if (count == 0 || ss1 * ss2 <= 0.0) return NA_REAL;
191191
dist = 2.0 * (1.0 - cp/sqrt(ss1 * ss2));
192192
return sqrt(fmax(dist, 0.0));
193193
}
@@ -216,7 +216,7 @@ static double veg_hellinger(double *x, int nr, int nc, int i1, int i2)
216216
i2 += nr;
217217
}
218218

219-
if (count == 0) return NA_REAL;
219+
if (count == 0 || ss1 * ss2 <= 0.0) return NA_REAL;
220220
dist = 2.0 * (1.0 - cp/sqrt(ss1 * ss2));
221221
return sqrt(fmax(dist, 0.0));
222222
}

0 commit comments

Comments
 (0)