[Rd] Using SQLBulkOperations in RODBC

2013-02-20 Thread Alireza Mahani
I have a question for the R core development team: Are there any near-term plans to incorporate the ODBC API function SQLBulkOperations into the RODBC package? As you are probably well aware, the sqlSave() function uses a row-by-row insert (even in the 'fast' version) that imposes heavy DB

[Rd] Creating model frame from R formula inside compiled code

2012-04-24 Thread Alireza Mahani
I am developing a custom regression package, which accepts a formula object as way of setting up the model matrix and response variable from a data frame. For large data sets, I expect that going through R memory might be too slow, so I'm thinking about reading the data directly into C (e.g. from

[Rd] How to call an MPI-enabled program from R?

2011-09-22 Thread Alireza Mahani
Conceptually, how is it possible to call an MPI-parallelized code in C from R? My experience with MPI so far indicates that one has to launch an MPI-enabled binary using a command like mpiexec -n number of processes name of binary In other words, I'm not sure how to create an MPI 'library' and

[Rd] Is it possible to pass a function argument from R to compiled code in C?

2011-09-20 Thread Alireza Mahani
it's going to be nearly impossible to pass a function from R to C. Are there any exact or approximate solutions available? Thank you, Alireza Mahani -- View this message in context: http://r.789695.n4.nabble.com/Is-it-possible-to-pass-a-function-argument-from-R-to-compiled-code-in-C

Re: [Rd] Is it possible to pass a function argument from R to compiled code in C?

2011-09-20 Thread Alireza Mahani
OK, thanks. But there are two issues with using .Call: 1- I may give up performance if I am literally running R code inside C, right? In some ways, wouldn't it defy the purpose of calling a compiled code if I end up back in R? 2- If I use the .Call interface, the resulting code will be tailored

Re: [Rd] How to safely using OpenMP pragma inside a .C() function?

2011-08-30 Thread Alireza Mahani
I have no R API calls inside the parallelized block. I will work on creating a self-contained example and post it for your review. Thanks! -Alireza -- View this message in context: http://r.789695.n4.nabble.com/How-to-safely-use-OpenMP-pragma-inside-a-C-function-tp3777036p3778482.html Sent from

[Rd] How to safely using OpenMP pragma inside a .C() function?

2011-08-29 Thread Alireza Mahani
? Thank you, Alireza Mahani -- View this message in context: http://r.789695.n4.nabble.com/How-to-safely-using-OpenMP-pragma-inside-a-C-function-tp3777036p3777036.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org

Re: [Rd] Best practices for writing R functions

2011-07-23 Thread Alireza Mahani
The fact that R doesn't automatically copy the function argument is very useful when you mainly want to pass arguments to another function. Thanks to all of you for mentioning this! Another trick to reduce verbosity of code (and focus on algorithm logic rather than boilerplate code) is to

[Rd] Best practices for writing R functions

2011-07-22 Thread Alireza Mahani
I am developing an R package for internal use, and eventually for public release. My understanding is that there is no easy way to avoid copying function arguments in R (i.e. we don't have the concept of pointers in R), which makes me wary of freely creating chains of function calls since each

[Rd] Measuring and comparing .C and .Call overhead

2011-07-19 Thread Alireza Mahani
Further pursuing my curiosity to measure the efficiency of R/C++ interface, I conducted a simple matrix-vector multiplication test using .C and .Call functions in R. In each case, I measured the execution time in R, as well as inside the C++ function. Subtracting the two, I came up with a measure

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

[Rd] Manipulating single-precision (float) arrays in .Call functions

2011-07-18 Thread Alireza Mahani
I am writing a wrapper function in C++ that calls a GPU kernel. My array type for the GPU kernel is float, so I would like my wrapper function to receive float arrays from R. I understand that I can use 'as.single' in R to copy a double-precision vector from R in single-precision format while

Re: [Rd] Manipulating single-precision (float) arrays in .Call functions

2011-07-18 Thread Alireza Mahani
Duncan, Thank you for your reply. This is a rather unfortunate limitation, because for large data sizes there is a significant difference between the performance of '.C' and '.Call'. I will have to do some tests to see what sort of penalty I incur for copying from double to float inside my C++

Re: [Rd] Manipulating single-precision (float) arrays in .Call functions

2011-07-18 Thread Alireza Mahani
Simon, Thank you for elaborating on the limitations of R in handling float types. I think I'm pretty much there with you. As for the insufficiency of single-precision math (and hence limitations of GPU), my personal take so far has been that double-precision becomes crucial when some sort of

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