File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -43,9 +43,31 @@ double simd_sum(NumericVector data)
4343 return simd::accumulate (data, 0.0 , plus ());
4444}
4545
46+ #include < boost/simd/arithmetic/include/functions/fast_sqrt.hpp>
47+
48+ // NOTE: To use the bundled SIMD functions, it looks like we need the
49+ // following header. We should expose all of these functions and auto-include
50+ // them in a utility namespace so users don't have to keep track of this sort
51+ // of thing.
52+ #include < boost/dispatch/functor/meta/call.hpp>
53+
54+ // It also stinks that we have to wrap it in our own functor. Surely
55+ // there's a better way?
56+ struct fast_sqrt {
57+ template <typename T>
58+ T operator ()(const T& t) { return boost::simd::fast_sqrt (t); }
59+ };
60+
61+ // [[Rcpp::export]]
62+ NumericVector simd_sqrt (NumericVector data)
63+ {
64+ return simd::transform (data, fast_sqrt ());
65+ }
66+
4667/* ** R
4768data <- as.numeric(1:16)
4869simd_add_two(data)
4970simd_add(data, data)
5071simd_sum(data)
72+ simd_sqrt(data)
5173*/
You can’t perform that action at this time.
0 commit comments