[Rcpp-devel] Why this is not working

Honglang Wang wanghonglang2008 at gmail.com
Tue Dec 4 01:25:18 CET 2012

Dear All,
Why the following code is not working:

// [[Rcpp::depends(RcppArmadillo)]]
#include <Rcpp.h>
#include <RcppArmadillo.h>

using namespace Rcpp;

// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
// [[Rcpp::export]]
List test(NumericVector yr, NumericMatrix Xr) {
  int n = Xr.nrow(), k = Xr.ncol();
  arma::mat X(Xr.begin(), n, k, false);
  NumericMatrix Y = arma::randu<mat>(3,3);
  arma::colvec y(yr.begin(), yr.size(), false);
  X.each_col()+= y;
  Y.each_col()%= y;
  NumericMatrix Z = arma::repmat(X,4,5);
  return List::create(Named("Addition") = X,Named("Multiplication") = Y,
Named("Rep") =Z);


Best wishes!

Honglang Wang

Office C402 Wells Hall
Department of Statistics and Probability
Michigan State University
1579 I Spartan Village, East Lansing, MI 48823
wangho16 at msu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121203/44699ba6/attachment-0001.html>

More information about the Rcpp-devel mailing list