You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* zeros and num stability
* frollprod adaptive fast redirect to exact
* more tests
* codecov
* correct expected ans
* Revert "zeros and num stability"
This reverts commit 4074e12.
* handle zeros in frollprod fast
test(6000.933, frollprod(c(1,2,NA), 2), c(NA, 2, NA), output="non-finite values are present in input, re-running with extra care for NFs")
1204
1204
test(6000.934, frollprod(c(NA,2,3), 2), c(NA, NA, 6), output="non-finite values are present in input, skip non-finite inaware attempt and run with extra care for NFs straighaway")
test(6000.936, frollprod(c(NA,2,3), c(2,2,2), adaptive=TRUE), c(NA, NA, 6), output="non-finite values are present in input, re-running with extra care for NFs")
1205
+
test(6000.935, frollprod(1:3, c(2,2,2), adaptive=TRUE), c(NA, 2, 6), output="algo 0 not implemented, fall back to 1")
1206
+
test(6000.936, frollprod(c(NA,2,3), c(2,2,2), adaptive=TRUE), c(NA, NA, 6), output="non-finite values are present in input, na.rm=FALSE and algo='exact' propagates NFs properply, no need to re-run")
//void frolladaptiveminFast(const double *x, uint64_t nx, ans_t *ans, const int *k, double fill, bool narm, int hasnf, bool verbose); // does not exists as of now
//void frolladaptiveprodFast(const double *x, uint64_t nx, ans_t *ans, const int *k, double fill, bool narm, int hasnf, bool verbose); // does not exists as of now
//void frolladaptivemedianFast(const double *x, uint64_t nx, ans_t *ans, const int *k, double fill, bool narm, int hasnf, bool verbose); // does not exists as of now
for (i=0; i<k-1; i++) { // #loop_counter_not_local_scope_ok
958
-
w *= x[i];
983
+
if (x[i] ==0.0) {
984
+
zerc++;
985
+
} else {
986
+
w *= x[i];
987
+
}
959
988
ans->dbl_v[i] =fill;
960
989
}
961
-
w *= x[i];
962
-
ans->dbl_v[i] = (double) w;
990
+
if (x[i] ==0.0) {
991
+
zerc++;
992
+
} else {
993
+
w *= x[i];
994
+
}
995
+
if (zerc) {
996
+
ans->dbl_v[i] =0.0;
997
+
} else {
998
+
ans->dbl_v[i] = (double) w;
999
+
}
963
1000
if (R_FINITE((double) w)) {
964
1001
for (uint64_ti=k; i<nx; i++) {
965
-
w /= x[i-k];
966
-
w *= x[i];
967
-
ans->dbl_v[i] = (double) w;
1002
+
if (x[i-k] ==0.0) {
1003
+
zerc--;
1004
+
} else {
1005
+
w /= x[i-k];
1006
+
}
1007
+
if (x[i] ==0.0) {
1008
+
zerc++;
1009
+
} else {
1010
+
w *= x[i];
1011
+
}
1012
+
if (zerc) {
1013
+
ans->dbl_v[i] =0.0;
1014
+
} else {
1015
+
ans->dbl_v[i] = (double) w;
1016
+
}
968
1017
}
969
1018
if (!R_FINITE((double) w)) {
970
1019
if (hasnf==-1)
971
1020
ansSetMsg(ans, 2, "%s: has.nf=FALSE used but non-finite values are present in input, use default has.nf=NA to avoid this warning", __func__);
972
1021
if (verbose)
973
1022
ansSetMsg(ans, 0, "%s: non-finite values are present in input, re-running with extra care for NFs\n", __func__);
974
-
w=1.0; truehasnf= true;
1023
+
w=1.0; zerc=0; truehasnf= true;
975
1024
}
976
1025
} else {
977
1026
if (hasnf==-1)
978
1027
ansSetMsg(ans, 2, "%s: has.nf=FALSE used but non-finite values are present in input, use default has.nf=NA to avoid this warning", __func__);
979
1028
if (verbose)
980
1029
ansSetMsg(ans, 0, "%s: non-finite values are present in input, skip non-finite inaware attempt and run with extra care for NFs straighaway\n", __func__);
0 commit comments