Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Avraham Adler
Sent from my iPhone > On Dec 5, 2024, at 4:11 PM, Sokol Serguei wrote: > > Luc, > > There can be many reasons explaining the difference in compiled code > performances. Tuning such code to achieve a pick performance is generally a > fine art. > Optimizations techniques can include but are

Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Luc De Wilde
Dirk, that's indeed an easy way to go, but I'm searching for methods that doesn't need to add other dependencies in my package, so the answer of Avraham is the most relevant for me. But off course, thank you for your help! Luc Van: Dirk Eddelbuettel Verzonden

Re: [R-pkg-devel] conditional import of a package?

2024-12-05 Thread Adelchi Azzalini
Hi. Thanks for the additional advice. It now works! I only had to move the assignment of nloptr.methods outside the if(.) block in the first chunk of code, otherwise the variable was undefined for the second block. This issue only showed up when I tried the newly created package on a machine w

Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Dirk Eddelbuettel
Luc, As Tomas mentioned, matrix-multiplication can take advantage of multiple threads, and the 'text book' nexted loops do not do that. Now, one alternative that appeals a lot to me is to farm out to Armadillo which also calls LAPACK for you (as R does). And via RcppArmadillo, the setup becomes

Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Sokol Serguei
Luc, There can be many reasons explaining the difference in compiled code performances. Tuning such code to achieve a pick performance is generally a fine art. Optimizations techniques can include but are not limited to:  - SIMD instructions (and memory alignment for their optimal use);  - ins

Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Luc De Wilde
Thank you very much, Tomas, now it's clear and I'll see what to do with that knowledge! Luc Van: Tomas Kalibera Verzonden: donderdag 5 december 2024 14:39 Aan: Luc De Wilde ; r-package-devel@r-project.org CC: Yves Rosseel Onderwerp: Re: [R-pkg-devel]

Re: [R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Tomas Kalibera
On 12/5/24 14:21, Luc De Wilde wrote: Dear package developers, in creating a package lavaanC for use in lavaan, I need to perform some matrix computations involving matrix products and crossproducts. As far as I see I cannot directly call the C code in the R core. So I copied the code in the

[R-pkg-devel] Cannot create C code with acceptable performance with respect to internal R command.

2024-12-05 Thread Luc De Wilde
Dear package developers, in creating a package lavaanC for use in lavaan, I need to perform some matrix computations involving matrix products and crossproducts. As far as I see I cannot directly call the C code in the R core. So I copied the code in the R core, but the same C/C++ code in a pac

Re: [R-pkg-devel] conditional import of a package?

2024-12-05 Thread Duncan Murdoch
On 2024-12-05 3:06 a.m., Adelchi Azzalini wrote: Thanks, Duncan, for the kind advice. In my understanding, this is what I have done (or I tried to do). My code is as follows: opt.methods <- c("Nelder-Mead", "BFGS", "nlminb") if(requireNamespace("nloptr", quietly = TRUE)) { nloptr.m

Re: [R-pkg-devel] conditional import of a package?

2024-12-05 Thread Sokol Serguei
Le 05/12/2024 à 09:06, Adelchi Azzalini a écrit : Thanks, Duncan, for the kind advice. In my understanding, this is what I have done (or I tried to do). My code is as follows: opt.methods <- c("Nelder-Mead", "BFGS", "nlminb") if(requireNamespace("nloptr", quietly = TRUE)) { nloptr.

Re: [R-pkg-devel] conditional import of a package?

2024-12-05 Thread Adelchi Azzalini
Thanks, Duncan, for the kind advice. In my understanding, this is what I have done (or I tried to do). My code is as follows: opt.methods <- c("Nelder-Mead", "BFGS", "nlminb") if(requireNamespace("nloptr", quietly = TRUE)) { nloptr.methods <- c("newuoa", "bobyqa", "cobyla") if(opt.