Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <RcppArmadillo.h>
  2. // [[Rcpp::depends(RcppArmadillo)]]
  3.  
  4. // [[Rcpp::export]]
  5. arma::vec liml_omg_vapply(arma::mat& v1, arma::mat& omgi, arma::mat& v2) {
  6.     arma::vec out(v1.n_rows);
  7.     arma::mat res(1, 1);
  8.     for (long i = 0; i < v1.n_rows; i++) {
  9.         // works fine
  10.         res = v1.row(i) * omgi * v2.row(i).t();
  11.         out(i) = res(0, 0);
  12.         // compile complains about it not being a function call
  13.         out(i) = (v1.row(i) * omgi * v2.row(i).t())(0, 0);
  14.     }
  15.     return out;
  16. }
  17.  
  18. // compiled in R returns:
  19.  
  20. file4d1578fe0fe7.cpp: In function β€˜arma::vec liml_omg_vapply(arma::mat&, arma::mat&, arma::mat&)’:
  21. file4d1578fe0fe7.cpp:16:61: error: no match for call to β€˜(arma::enable_if2<true, const arma::Glue<arma::Glue<arma::subview_row<double>, arma::Mat<double>, arma::glue_times>, arma::Op<arma::subview_row<double>, arma::op_htrans>, arma::glue_times> >::result {aka const arma::Glue<arma::Glue<arma::subview_row<double>, arma::Mat<double>, arma::glue_times>, arma::Op<arma::subview_row<double>, arma::op_htrans>, arma::glue_times>}) (int, int)’
  22.              out(i) = (v1.row(i) * omgi * v2.row(i).t())(0, 0);
  23.                                                              ^
  24. make: *** [file4d1578fe0fe7.o] Error 1
  25. g++ -I/usr/share/R/include -DNDEBUG    -I"/home/james/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include" -I"/home/james/R/x86_64-pc-linux-gnu-library/3.2/RcppArmadillo/include" -I"/tmp/Rtmpsrp0A7"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c file4d1578fe0fe7.cpp -o file4d1578fe0fe7.o
  26. /usr/lib/R/etc/Makeconf:143: recipe for target 'file4d1578fe0fe7.o' failed
  27. Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  :
  28.   Error 1 occurred building shared library.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement