armgong / rjulia

R package which integrating R and Julia
GNU General Public License v2.0
145 stars 23 forks source link

Array creation #30

Closed phaverty closed 8 years ago

phaverty commented 8 years ago

This PR contains a workaround for the problem of creating a tuple of array dimensions in when r2j is called for the vector and matrix cases. There are a few smaller optimizations that use memcpy to copy the vector from R to julia or hoist the R data pointer lookup macro. When copying a STRSXP, I use a branch with alternate loops for ASCII or Utf8 rather than branching in the loop.

The end result is a 19X speedup for j2r. If this new arrangement looks good, I can do the same thing for R_Julia_MD_NA and then simplify RDims_JuliaTuple to remove the vector case.

I tried to figure out how to use jl_apply_tuple_type in RDims_JuliaTuple, but failed. I'm sure it can be done, though.

phaverty commented 8 years ago

Fixes #29