Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-19 Thread Alireza Mahani
Prof. Bates, It looks like you read my mind! I am working on writing an R package for high-performance MCMC estimation of a class of Hierarchical Bayesian models most often used in the field of quantitative marketing. This would essentially be a parallelized version of Peter Rossi's bayesm package

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-19 Thread Douglas Bates
I just saw that I left a syntax error in the .R and the first _Rout.txt files. Notice that in the second _Rout.txt file the order of the arguments in the constructors for the MMatrixXd and the MVectorXd are in a different order than in the .R and the first _Rout.txt files. The correct order has t

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-19 Thread Douglas Bates
On Thu, Jul 14, 2011 at 10:21 AM, Alireza Mahani wrote: > (I am using a LINUX machine) > > Jeff, > > In creating reproducible results, I 'partially' answered my question. I have > attached two scripts, 'mvMultiply.r' and 'mvMultiply.cc'. Please copy both > files into your chosen directory, then ru

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-14 Thread Alireza Mahani
You are absolutely right Gabe! I removed the line 'dim(A) <- dim(A)[1] * dim(A)[2]' and my code still executes properly. As you said, matrices are internally stored as one-dimensional arrays (column-major by default), it's just that R exposes them differently by assigning different attributes to th

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-14 Thread Gabriel Becker
On Thu, Jul 14, 2011 at 8:21 AM, Alireza Mahani wrote: > (I am using a LINUX machine) > > Jeff, > > In creating reproducible results, I 'partially' answered my question. I > have > attached two scripts, 'mvMultiply.r' and 'mvMultiply.cc'. Please copy both > files into your chosen directory, then r

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-14 Thread Alireza Mahani
(I am using a LINUX machine) Jeff, In creating reproducible results, I 'partially' answered my question. I have attached two scripts, 'mvMultiply.r' and 'mvMultiply.cc'. Please copy both files into your chosen directory, then run 'Rscript mvMultiply.r' in that directory while changing the two boo

Re: [Rd] Performance of .C and .Call functions vs. native R code

2011-07-14 Thread Jeff Ryan
The .Call overhead isn't the issue. If you'd like some insight into what you are doing wrong (and right), you need to provide code for the list to reproduce your timings with. This is outlined in the posting guide as well. Best, Jeff On Jul 13, 2011, at 8:28 AM, asmahani wrote: > Hello, >

[Rd] Performance of .C and .Call functions vs. native R code

2011-07-14 Thread asmahani
Hello, I am in the process of writing an R extension for parallelized MCMC, with heavy use of compiled code (C++). I have been getting my feet wet by implementing a simple matrix-vector multiplication function in C++ (which calls a BLAS level 2 function dgemv), and comparing it to the '%*%' operat