File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -8,18 +8,18 @@ using namespace RcppParallel;
88struct Sum : public Worker
99{
1010 // source vector
11- const RVector<double > input;
11+ const RVector<int > input;
1212
1313 // accumulated value
14- double value;
14+ int value;
1515
1616 // constructors
17- Sum (const NumericVector input) : input(input), value(0 ) {}
17+ Sum (const IntegerVector input) : input(input), value(0 ) {}
1818 Sum (const Sum& sum, Split) : input(sum.input), value(0 ) {}
1919
2020 // accumulate just the element of the range I've been asked to
2121 void operator ()(std::size_t begin, std::size_t end) {
22- value += std::accumulate (input.begin () + begin, input.begin () + end, 0.0 );
22+ value += std::accumulate (input.begin () + begin, input.begin () + end, 0 );
2323 }
2424
2525 // join my value with that of another Sum
@@ -29,7 +29,7 @@ struct Sum : public Worker
2929};
3030
3131// [[Rcpp::export]]
32- double parallelVectorSum (NumericVector x) {
32+ double parallelVectorSum (IntegerVector x) {
3333
3434 // declare the SumBody instance
3535 Sum sum (x);
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ test_that( "linking from a package works", {
1414 intern = TRUE , ignore.stderr = TRUE )
1515 require(RcppParallelTest , lib.loc = templib , quietly = TRUE )
1616
17- v <- as.numeric (c(1 : 10000 ))
17+ v <- as.integer (c(1 : 1000 ))
1818
1919 expect_equal(
2020 sum(v ),
You can’t perform that action at this time.
0 commit comments