1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector subset_test_int(NumericVector x, IntegerVector y) {
return x[y];
}
// [[Rcpp::export]]
NumericVector subset_test_num(NumericVector x, NumericVector y) {
return x[y];
}
// [[Rcpp::export]]
NumericVector subset_test_lgcl(NumericVector x, LogicalVector y) {
return x[y];
}
// [[Rcpp::export]]
NumericVector subset_test_char(NumericVector x, CharacterVector y) {
return x[y];
}
// [[Rcpp::export]]
List subset_test_list(List x, CharacterVector y) {
return x[y];
}
// [[Rcpp::export]]
List subset_test_list_int(List x, IntegerVector y) {
return x[y];
}
// [[Rcpp::export]]
List subset_test_list_lgcl(List x, LogicalVector y) {
return x[y];
}
// [[Rcpp::export]]
NumericVector subset_test_greater_0(NumericVector x) {
return x[ x > 0 ];
}
// [[Rcpp::export]]
List subset_test_literal(List x) {
return x["foo"];
}
// [[Rcpp::export]]
NumericVector subset_test_assign(NumericVector x) {
x[ x > 0 ] = 0;
return x;
}
// [[Rcpp::export]]
NumericVector subset_test_constref(NumericVector const& x, IntegerVector const& y) {
return x[y];
}
// [[Rcpp::export]]
NumericVector subset_assign_subset(NumericVector x) {
NumericVector y(x.size());
y[x > 3] = x[x > 3];
return y;
}
// [[Rcpp::export]]
NumericVector subset_assign_subset2(NumericVector x) {
NumericVector y(x.size());
y[x <= 3] = x[x > 3];
return y;
}
// [[Rcpp::export]]
NumericVector subset_assign_subset3(NumericVector x) {
NumericVector y(x.size());
y[x <= 3] = x[3];
return y;
}
// [[Rcpp::export]]
IntegerVector subset_assign_subset4(NumericVector x) {
IntegerVector y(x.size());
y[x <= 3] = x[x <= 3];
return y;
}
// [[Rcpp::export]]
NumericVector subset_assign_subset5(NumericVector x) {
NumericVector y(x.size());
y[x < 3] = x[x >= 4];
return y;
}
// [[Rcpp::export]]
NumericVector subset_assign_vector_size_1(NumericVector x, int i) {
NumericVector y(1);
y[0]=i;
x[x < 4] = y;
return x;
}
// [[Rcpp::export]]
NumericVector subset_sugar_add(NumericVector x, IntegerVector y)
{
NumericVector result = x[y] + x[y];
return result;
}
|