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
for (i=0; i<k-1; i++) { // #loop_counter_not_local_scope_ok
951
-
w *= x[i];
996
+
if (x[i] ==0.0) {
997
+
zerc++;
998
+
} else {
999
+
w+=log(fabsl(x[i]));
1000
+
if (x[i] <0.0)
1001
+
negc++;
1002
+
}
952
1003
ans->dbl_v[i] =fill;
953
1004
}
954
-
w *= x[i];
955
-
ans->dbl_v[i] = (double) w;
1005
+
if (x[i] ==0.0) {
1006
+
zerc++;
1007
+
} else {
1008
+
w+=log(fabsl(x[i]));
1009
+
if (x[i] <0.0)
1010
+
negc++;
1011
+
}
1012
+
if (zerc) {
1013
+
ans->dbl_v[i] =0.0;
1014
+
} else {
1015
+
long doubleres=expl(w);
1016
+
if (negc % 2)
1017
+
res=-res;
1018
+
ans->dbl_v[i] = (double) res;
1019
+
}
956
1020
if (R_FINITE((double) w)) {
957
1021
for (uint64_ti=k; i<nx; i++) {
958
-
w /= x[i-k];
959
-
w *= x[i];
960
-
ans->dbl_v[i] = (double) w;
1022
+
if (x[i-k] ==0.0) {
1023
+
zerc--;
1024
+
} else {
1025
+
w-=log(fabsl(x[i-k]));
1026
+
if (x[i-k] <0.0)
1027
+
negc--;
1028
+
}
1029
+
if (x[i] ==0.0) {
1030
+
zerc++;
1031
+
} else {
1032
+
w+=log(fabsl(x[i]));
1033
+
if (x[i] <0.0)
1034
+
negc++;
1035
+
}
1036
+
if (zerc) {
1037
+
ans->dbl_v[i] =0.0;
1038
+
} else {
1039
+
long doubleres=expl(w);
1040
+
if (negc % 2)
1041
+
res=-res;
1042
+
ans->dbl_v[i] = (double) res;
1043
+
}
961
1044
}
962
1045
if (!R_FINITE((double) w)) {
963
1046
if (hasnf==-1)
964
1047
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__);
965
1048
if (verbose)
966
1049
ansSetMsg(ans, 0, "%s: non-finite values are present in input, re-running with extra care for NFs\n", __func__);
967
-
w=1.0; truehasnf= true;
1050
+
w=0.0; zerc=0; negc=0; truehasnf= true;
968
1051
}
969
1052
} else {
970
1053
if (hasnf==-1)
971
1054
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
1055
if (verbose)
973
1056
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