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

Dirk Eddelbuettel edd at debian.org
Wed May 22 18:05:33 CEST 2013


Rodney and I have been over this a bit, without resolution. At my urging, he
posted now on the list (as _everybody_ should: more eyeballs are in fact
better as you can tell from the fact that we still have not found this).

On my side, I just works.  The second command is specific to my machine, but
this is just a git checkout of the gallery and the actual file.



R> setwd("/tmp")
R> system("cp -vax ~/git/rcpp-gallery/src/2012-12-25-armadillo-sparse-matrix.cpp .")
`/home/edd/git/rcpp-gallery/src/2012-12-25-armadillo-sparse-matrix.cpp' -> `./2012-12-25-armadillo-sparse-matrix.cpp'
R> sourceCpp("2012-12-25-armadillo-sparse-matrix.cpp")

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> 


Dirk, puzzled

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


More information about the Rcpp-devel mailing list