Skip to content

Commit 57c4ab2

Browse files
committedDec 21, 2012
always use rcpp export
1 parent 0d247a6 commit 57c4ab2

4 files changed

+6
-0
lines changed
 

‎_posts/2012-12-19-sugar-for-high-level-vector-operations.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ third one:
2121
#include <Rcpp.h>
2222
using namespace Rcpp;
2323

24+
// [[Rcpp::export]]
2425
NumericVector foo(NumericVector x, NumericVector y) {
2526
int n = x.size() ;
2627
NumericVector res( n ) ;
@@ -54,6 +55,7 @@ numeric and comparison operators yields the identical one-line
5455
implementation:
5556

5657
{% highlight cpp %}
58+
// [[Rcpp::export]]
5759
NumericVector fooSugar(NumericVector x, NumericVector y) {
5860
return ifelse( x < y, x*x, -(y*y) );
5961
}

‎_posts/2012-12-20-simulating-pi.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ looks almost as compact.
5454
#include <Rcpp.h>
5555
using namespace Rcpp;
5656

57+
// [[Rcpp::export]]
5758
double piSugar(const int N) {
5859
RNGScope scope; // ensure RNG gets set/reset
5960
NumericVector x = runif(N);

‎src/2012-12-19-sugar-for-high-level-vector-operations.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <Rcpp.h>
1818
using namespace Rcpp;
1919

20+
// [[Rcpp::export]]
2021
NumericVector foo(NumericVector x, NumericVector y) {
2122
int n = x.size() ;
2223
NumericVector res( n ) ;
@@ -50,6 +51,7 @@ foo <- function(x, y){
5051
* implementation:
5152
*/
5253

54+
// [[Rcpp::export]]
5355
NumericVector fooSugar(NumericVector x, NumericVector y) {
5456
return ifelse( x < y, x*x, -(y*y) );
5557
}

‎src/2012-12-20-simulating-pi.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ c(piR(1000), piR(10000), piR(100000), piR(1000000))
4545
#include <Rcpp.h>
4646
using namespace Rcpp;
4747

48+
// [[Rcpp::export]]
4849
double piSugar(const int N) {
4950
RNGScope scope; // ensure RNG gets set/reset
5051
NumericVector x = runif(N);

0 commit comments

Comments
 (0)
Please sign in to comment.