@@ -48,37 +48,37 @@ inline bool check_na(Rcomplex x) {
48
48
}
49
49
50
50
51
- inline void incr (double & lhs, double rhs) {
52
- lhs += rhs;
51
+ inline void incr (double * lhs, double rhs) {
52
+ * lhs += rhs;
53
53
}
54
54
55
- inline void incr (int & lhs, int rhs) {
56
- lhs += rhs;
55
+ inline void incr (int * lhs, int rhs) {
56
+ * lhs += rhs;
57
57
}
58
58
59
- inline void incr (Rcomplex& lhs, const Rcomplex& rhs) {
60
- lhs. r += rhs.r ;
61
- lhs. i += rhs.i ;
59
+ inline void incr (Rcomplex* lhs, const Rcomplex& rhs) {
60
+ lhs-> r += rhs.r ;
61
+ lhs-> i += rhs.i ;
62
62
}
63
63
64
64
65
- inline void div (double & lhs, R_xlen_t rhs) {
66
- lhs /= rhs;
65
+ inline void div (double * lhs, R_xlen_t rhs) {
66
+ * lhs /= rhs;
67
67
}
68
68
69
- inline void div (Rcomplex& lhs, R_xlen_t rhs) {
70
- lhs. r /= rhs;
71
- lhs. i /= rhs;
69
+ inline void div (Rcomplex* lhs, R_xlen_t rhs) {
70
+ lhs-> r /= rhs;
71
+ lhs-> i /= rhs;
72
72
}
73
73
74
74
75
- inline void set_nan (double & x) {
76
- x = R_NaN;
75
+ inline void set_nan (double * x) {
76
+ * x = R_NaN;
77
77
}
78
78
79
- inline void set_nan (Rcomplex& x) {
80
- x. r = R_NaN;
81
- x. i = R_NaN;
79
+ inline void set_nan (Rcomplex* x) {
80
+ x-> r = R_NaN;
81
+ x-> i = R_NaN;
82
82
}
83
83
84
84
@@ -145,7 +145,7 @@ class RowSumsImpl :
145
145
146
146
for (j = 0 ; j < nc; j++) {
147
147
for (i = 0 ; i < nr; i++) {
148
- detail::incr (res[i], ref (i, j));
148
+ detail::incr (& res[i], ref (i, j));
149
149
}
150
150
}
151
151
@@ -198,7 +198,7 @@ public:
198
198
if (detail::check_na (ref (i, j))) { \
199
199
na_flags[i].x |= 0x1 ; \
200
200
} \
201
- detail::incr (res[i], ref (i, j)); \
201
+ detail::incr (& res[i], ref (i, j)); \
202
202
} \
203
203
} \
204
204
\
@@ -215,6 +215,7 @@ public:
215
215
ROW_SUMS_IMPL_KEEPNA (LGLSXP)
216
216
ROW_SUMS_IMPL_KEEPNA (INTSXP)
217
217
218
+ #undef ROW_SUMS_IMPL_KEEPNA
218
219
219
220
// RowSums
220
221
// na.rm = TRUE
@@ -246,7 +247,7 @@ class RowSumsImpl<RTYPE, NA, T, true> :
246
247
for (i = 0 ; i < nr; i++) {
247
248
current = ref (i, j);
248
249
if (!detail::check_na (current)) {
249
- detail::incr (res[i], current);
250
+ detail::incr (& res[i], current);
250
251
}
251
252
}
252
253
}
@@ -287,7 +288,7 @@ public:
287
288
for (i = 0 ; i < nr; i++) { \
288
289
current = ref (i, j); \
289
290
if (!detail::check_na (current)) { \
290
- detail::incr (res[i], current); \
291
+ detail::incr (& res[i], current); \
291
292
} \
292
293
} \
293
294
} \
@@ -299,6 +300,7 @@ public:
299
300
ROW_SUMS_IMPL_RMNA (LGLSXP)
300
301
ROW_SUMS_IMPL_RMNA (INTSXP)
301
302
303
+ #undef ROW_SUMS_IMPL_RMNA
302
304
303
305
// RowSums
304
306
// Input with template parameter NA = false
@@ -335,7 +337,7 @@ class ColSumsImpl :
335
337
336
338
for (j = 0 ; j < nc; j++) {
337
339
for (i = 0 ; i < nr; i++) {
338
- detail::incr (res[j], ref (i, j));
340
+ detail::incr (& res[j], ref (i, j));
339
341
}
340
342
}
341
343
@@ -380,7 +382,7 @@ public:
380
382
if (detail::check_na (ref (i, j))) { \
381
383
na_flags[j].x |= 0x1 ; \
382
384
} \
383
- detail::incr (res[j], ref (i, j)); \
385
+ detail::incr (& res[j], ref (i, j)); \
384
386
} \
385
387
} \
386
388
\
@@ -397,7 +399,8 @@ public:
397
399
COL_SUMS_IMPL_KEEPNA (LGLSXP)
398
400
COL_SUMS_IMPL_KEEPNA (INTSXP)
399
401
400
-
402
+ #undef COL_SUMS_IMPL_KEEPNA
403
+
401
404
// ColSums
402
405
// na.rm = TRUE
403
406
// default input
@@ -428,7 +431,7 @@ class ColSumsImpl<RTYPE, NA, T, true> :
428
431
for (i = 0 ; i < nr; i++) {
429
432
current = ref (i, j);
430
433
if (!detail::check_na (current)) {
431
- detail::incr (res[j], current);
434
+ detail::incr (& res[j], current);
432
435
}
433
436
}
434
437
}
@@ -469,7 +472,7 @@ public:
469
472
for (i = 0 ; i < nr; i++) { \
470
473
current = ref (i, j); \
471
474
if (!detail::check_na (current)) { \
472
- detail::incr (res[j], current); \
475
+ detail::incr (& res[j], current); \
473
476
} \
474
477
} \
475
478
} \
@@ -481,6 +484,7 @@ public:
481
484
COL_SUMS_IMPL_RMNA (LGLSXP)
482
485
COL_SUMS_IMPL_RMNA (INTSXP)
483
486
487
+ #undef COL_SUMS_IMPL_RMNA
484
488
485
489
// ColSums
486
490
// Input with template parameter NA = false
@@ -520,12 +524,12 @@ class RowMeansImpl :
520
524
521
525
for (j = 0 ; j < nc; j++) {
522
526
for (i = 0 ; i < nr; i++) {
523
- detail::incr (res[i], ref (i, j));
527
+ detail::incr (& res[i], ref (i, j));
524
528
}
525
529
}
526
530
527
531
for (i = 0 ; i < nr; i++) {
528
- detail::div (res[i], nc);
532
+ detail::div (& res[i], nc);
529
533
}
530
534
531
535
return res;
@@ -569,13 +573,13 @@ public:
569
573
if (detail::check_na (ref (i, j))) { \
570
574
na_flags[i].x |= 0x1 ; \
571
575
} \
572
- detail::incr (res[i], ref (i, j)); \
576
+ detail::incr (& res[i], ref (i, j)); \
573
577
} \
574
578
} \
575
579
\
576
580
for (i = 0 ; i < nr; i++) { \
577
581
if (!na_flags[i].x ) { \
578
- detail::div (res[i], nc); \
582
+ detail::div (& res[i], nc); \
579
583
} else { \
580
584
res[i] = NA_REAL; \
581
585
} \
@@ -588,7 +592,8 @@ public:
588
592
ROW_MEANS_IMPL_KEEPNA (LGLSXP)
589
593
ROW_MEANS_IMPL_KEEPNA (INTSXP)
590
594
591
-
595
+ #undef ROW_MEANS_IMPL_KEEPNA
596
+
592
597
// RowMeans
593
598
// na.rm = TRUE
594
599
// default input
@@ -621,17 +626,17 @@ class RowMeansImpl<RTYPE, NA, T, true> :
621
626
for (i = 0 ; i < nr; i++) {
622
627
current = ref (i, j);
623
628
if (!detail::check_na (current)) {
624
- detail::incr (res[i], ref (i, j));
629
+ detail::incr (& res[i], ref (i, j));
625
630
++n_ok[i];
626
631
}
627
632
}
628
633
}
629
634
630
635
for (i = 0 ; i < nr; i++) {
631
636
if (n_ok[i]) {
632
- detail::div (res[i], n_ok[i]);
637
+ detail::div (& res[i], n_ok[i]);
633
638
} else {
634
- detail::set_nan (res[i]);
639
+ detail::set_nan (& res[i]);
635
640
}
636
641
}
637
642
@@ -670,17 +675,17 @@ public:
670
675
for (j = 0 ; j < nc; j++) { \
671
676
for (i = 0 ; i < nr; i++) { \
672
677
if (!detail::check_na (ref (i, j))) { \
673
- detail::incr (res[i], ref (i, j)); \
678
+ detail::incr (& res[i], ref (i, j)); \
674
679
++n_ok[i]; \
675
680
} \
676
681
} \
677
682
} \
678
683
\
679
684
for (i = 0 ; i < nr; i++) { \
680
685
if (n_ok[i]) { \
681
- detail::div (res[i], n_ok[i]); \
686
+ detail::div (& res[i], n_ok[i]); \
682
687
} else { \
683
- detail::set_nan (res[i]); \
688
+ detail::set_nan (& res[i]); \
684
689
} \
685
690
} \
686
691
\
@@ -691,6 +696,7 @@ public:
691
696
ROW_MEANS_IMPL_RMNA (LGLSXP)
692
697
ROW_MEANS_IMPL_RMNA (INTSXP)
693
698
699
+ #undef ROW_MEANS_IMPL_RMNA
694
700
695
701
// RowMeans
696
702
// Input with template parameter NA = false
@@ -727,12 +733,12 @@ class ColMeansImpl :
727
733
728
734
for (j = 0 ; j < nc; j++) {
729
735
for (i = 0 ; i < nr; i++) {
730
- detail::incr (res[j], ref (i, j));
736
+ detail::incr (& res[j], ref (i, j));
731
737
}
732
738
}
733
739
734
740
for (j = 0 ; j < nc; j++) {
735
- detail::div (res[j], nr);
741
+ detail::div (& res[j], nr);
736
742
}
737
743
738
744
return res;
@@ -776,13 +782,13 @@ public:
776
782
if (detail::check_na (ref (i, j))) { \
777
783
na_flags[j].x |= 0x1 ; \
778
784
} \
779
- detail::incr (res[j], ref (i, j)); \
785
+ detail::incr (& res[j], ref (i, j)); \
780
786
} \
781
787
} \
782
788
\
783
789
for (j = 0 ; j < nc; j++) { \
784
790
if (!na_flags[j].x ) { \
785
- detail::div (res[j], nr); \
791
+ detail::div (& res[j], nr); \
786
792
} else { \
787
793
res[j] = NA_REAL; \
788
794
} \
@@ -795,6 +801,7 @@ public:
795
801
COL_MEANS_IMPL_KEEPNA (LGLSXP)
796
802
COL_MEANS_IMPL_KEEPNA (INTSXP)
797
803
804
+ #undef COL_MEANS_IMPL_KEEPNA
798
805
799
806
// ColMeans
800
807
// na.rm = TRUE
@@ -828,17 +835,17 @@ class ColMeansImpl<RTYPE, NA, T, true> :
828
835
for (i = 0 ; i < nr; i++) {
829
836
current = ref (i, j);
830
837
if (!detail::check_na (current)) {
831
- detail::incr (res[j], ref (i, j));
838
+ detail::incr (& res[j], ref (i, j));
832
839
++n_ok[j];
833
840
}
834
841
}
835
842
}
836
843
837
844
for (j = 0 ; j < nc; j++) {
838
845
if (n_ok[j]) {
839
- detail::div (res[j], n_ok[j]);
846
+ detail::div (& res[j], n_ok[j]);
840
847
} else {
841
- detail::set_nan (res[j]);
848
+ detail::set_nan (& res[j]);
842
849
}
843
850
}
844
851
@@ -877,17 +884,17 @@ public:
877
884
for (j = 0 ; j < nc; j++) { \
878
885
for (i = 0 ; i < nr; i++) { \
879
886
if (!detail::check_na (ref (i, j))) { \
880
- detail::incr (res[j], ref (i, j)); \
887
+ detail::incr (& res[j], ref (i, j)); \
881
888
++n_ok[j]; \
882
889
} \
883
890
} \
884
891
} \
885
892
\
886
893
for (j = 0 ; j < nc; j++) { \
887
894
if (n_ok[j]) { \
888
- detail::div (res[j], n_ok[j]); \
895
+ detail::div (& res[j], n_ok[j]); \
889
896
} else { \
890
- detail::set_nan (res[j]); \
897
+ detail::set_nan (& res[j]); \
891
898
} \
892
899
} \
893
900
\
@@ -898,7 +905,8 @@ public:
898
905
COL_MEANS_IMPL_RMNA (LGLSXP)
899
906
COL_MEANS_IMPL_RMNA (INTSXP)
900
907
901
-
908
+ #undef COL_MEANS_IMPL_RMNA
909
+
902
910
// ColMeans
903
911
// Input with template parameter NA = false
904
912
// ColMeansImpl<..., NA_RM = false>
@@ -948,16 +956,6 @@ colMeans(const MatrixBase<RTYPE, NA, T>& x, bool na_rm = false) {
948
956
}
949
957
950
958
951
- #undef ROW_SUMS_IMPL_KEEPNA
952
- #undef ROW_SUMS_IMPL_RMNA
953
- #undef COL_SUMS_IMPL_KEEPNA
954
- #undef COL_SUMS_IMPL_RMNA
955
- #undef ROW_MEANS_IMPL_KEEPNA
956
- #undef ROW_MEANS_IMPL_RMNA
957
- #undef COL_MEANS_IMPL_KEEPNA
958
- #undef COL_MEANS_IMPL_RMNA
959
-
960
-
961
959
} // Rcpp
962
960
963
961
#endif // Rcpp__sugar__rowSums_h
0 commit comments