[Rcpp-devel] sourceCpp issue: code vs. file

Dirk Eddelbuettel edd at debian.org
Wed May 22 19:23:14 CEST 2013


And for completeness, here is the invocation that fails for Rodney:


R> sourceCpp(verbose=TRUE, rebuild=TRUE, file="2012-12-25-armadillo-sparse-matrix.cpp")

Generated extern "C" functions 
--------------------------------------------------------


#include <Rcpp.h>

RcppExport SEXP sourceCpp_44697_convertSparse(SEXP matSEXP) {
BEGIN_RCPP
    Rcpp::RNGScope __rngScope;
    S4 mat = Rcpp::as<S4 >(matSEXP);
    convertSparse(mat);
    return R_NilValue;
END_RCPP
}

Generated R functions 
-------------------------------------------------------

`.sourceCpp_44697_DLLInfo` <- dyn.load('/tmp/Rtmpr8HLMP/sourcecpp_38624d1a5d0a/sourceCpp_73760.so')

convertSparse <- Rcpp:::sourceCppFunction(function(mat) {}, TRUE, `.sourceCpp_44697_DLLInfo`, 'sourceCpp_44697_convertSparse')

rm(`.sourceCpp_44697_DLLInfo`)

Building shared library
--------------------------------------------------------

DIR: /tmp/Rtmpr8HLMP/sourcecpp_38624d1a5d0a

/usr/lib/R/bin/R CMD SHLIB -o 'sourceCpp_73760.so' --preclean '2012-12-25-armadillo-sparse-matrix.cpp' 
ccache g++-4.7 -I/usr/share/R/include -DNDEBUG    -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -I"/usr/local/lib/R/site-library/Rcpp/include"   -fpic  -g0 -O3 -Wall -pipe -Wno-variadic-macros -pedantic -c 2012-12-25-armadillo-sparse-matrix.cpp -o 2012-12-25-armadillo-sparse-matrix.o
g++-4.7 -shared -o sourceCpp_73760.so 2012-12-25-armadillo-sparse-matrix.o -llapack -lblas -lgfortran -lm -lquadmath -L/usr/local/lib/R/site-library/Rcpp/lib -lRcpp -Wl,-rpath,/usr/local/lib/R/site-library/Rcpp/lib -lQuantLib -L/usr/lib/R/lib -lR

R>   suppressMessages(library(Matrix))

R>   i <- c(1,3:8) 

R>   j <- c(2,9,6:10) 

R>   x <- 7 * (1:7)

R>   A <- sparseMatrix(i, j, x = x) 

R>   print(A)
8 x 10 sparse Matrix of class "dgCMatrix"
                             
[1,] . 7 . . .  .  .  .  .  .
[2,] . . . . .  .  .  .  .  .
[3,] . . . . .  .  .  . 14  .
[4,] . . . . . 21  .  .  .  .
[5,] . . . . .  . 28  .  .  .
[6,] . . . . .  .  . 35  .  .
[7,] . . . . .  .  .  . 42  .
[8,] . . . . .  .  .  .  . 49

R>   convertSparse(A)
SpMat res:
[matrix size: 8x10; n_nonzero: 7; density: 8.75%]

     (0, 1)          7.0000
     (3, 5)         21.0000
     (4, 6)         28.0000
     (5, 7)         35.0000
     (2, 8)         14.0000
     (6, 8)         42.0000
     (7, 9)         49.0000


R> 

Methinks there may be something particular to your box.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list