[Rcpp-devel] Rccp code with vector and matrix inputs and matrix output

Dirk Eddelbuettel edd at debian.org
Fri Mar 28 14:36:26 CET 2014


On 28 March 2014 at 13:51, Petre Caraiani wrote:
| Thank you for your quick reply!
| I corrected the issue mentioned by you, but I get the same error.
| It must be a beginner's issue.
| 
| The data is quite big, but this kind of output could be produced with any
| random data, I guess.
| 
| Namely, using the Rcpp, I get Am as:
|        [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
| [,13]
|   [1,] 0.1825   NA   NA   NA   NA   NA   NA   NA   NA   
| NA    NA    NA    NA

[...]

|  [14,]     NA   NA   NA   NA   NA   NA   NA   NA  
| NA    NA    NA    NA    NA
|  and only NAs everywhere else
| 
| while I get this using the pure R code:
|   X0   X0.1   X0.2   X0.3   X0.4   X0.5   X0.6   X0.7  
| X0.8   X0.9  X0.10  X0.11  X0.12
| 1  0.1811 0.1797 0.1784 0.1770 0.1757 0.1743 0.1730 0.1717 0.1704 0.1691
| 0.1678 0.1665 0.1653

[...]

| 33 0.1580 0.1594 0.1607 0.1621 0.1635 0.1648 0.1662 0.1677 0.1691 0.1705 0.1720
| 0.1734 0.1749

You have something that builds, which is a good first step.  But it doesn't
give the results you want.  So now you need to debug this. In most cases you
can reduce a larger problem to a smaller problem so I'd try to get, say, a
3 x 3 matrix taken care of the same way in both implementations.

Good luck,  Dirk

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


More information about the Rcpp-devel mailing list