|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 00003 // this version expands convolve8_cpp by making Vec mimic the structure of 00004 // NumericVector. It peforms well, so this is is not the structure of 00005 // NumericVector that is the problem. So what is it then ? 00006 // 00007 // could it be because NumericVector is in a different library than 00008 // this code, so that operator[] is not inlined ? 00009 // 00010 // clues: 00011 // - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3538.html 00012 00013 #include <Rcpp.h> 00014 00015 #include "convolve10_cpp.h" 00016 00017 RcppExport SEXP convolve10cpp(SEXP a, SEXP b){ 00018 Rcpp::NumericVector xa(a); 00019 Rcpp::NumericVector xb(b); 00020 int n_xa = xa.size() ; 00021 int n_xb = xb.size() ; 00022 int nab = n_xa + n_xb - 1; 00023 Rcpp::NumericVector xab(nab); 00024 00025 Vec vab(xab.begin()), va(xa.begin()), vb(xb.begin()) ; 00026 00027 for (int i = 0; i < n_xa; i++) 00028 for (int j = 0; j < n_xb; j++) 00029 vab[i + j] += va[i] * vb[j]; 00030 00031 return xab ; 00032 } 00033 00034 #include "loopmacro.h" 00035 LOOPMACRO_CPP(convolve10cpp) 00036