From |uc@r @end|ng |rom |edor@project@org  Tue Jun 18 20:35:13 2019
From: |uc@r @end|ng |rom |edor@project@org (=?UTF-8?Q?I=C3=B1aki_Ucar?=)
Date: Tue, 18 Jun 2019 20:35:13 +0200
Subject: [Rd] Fast way to call an R function from C++?
In-Reply-To: <CAGiFhPONJoEeWWdtTyHw=Y5or1ad3pXtydLNQyONzU3FPatgPA@mail.gmail.com>
References: <CAGiFhPONJoEeWWdtTyHw=Y5or1ad3pXtydLNQyONzU3FPatgPA@mail.gmail.com>
Message-ID: <CALEXWq2g2XFAZ4tzjWuP65PDKXVx1HFK3DvsWVhtV18T61vKEQ@mail.gmail.com>

On Tue, 18 Jun 2019 at 19:41, King Jiefei <szwjf08 at gmail.com> wrote:
>
> [...]
>
> It is clear to see that calling an R function in R is the fast one, it is
> about 5X faster than ` R_forceAndCall ` and ` Rf_eval`. the latter two
> functions have a similar performance and using Rcpp is the worst one. Is it
> expected? Why is calling an R function from C++ much slower than calling
> the function from R? Is there any faster way to do the function call in C++?

Yes, there is: enable fast evaluation by setting
-DRCPP_USE_UNWIND_PROTECT, or alternatively, use

// [[Rcpp::plugins(unwindProtect)]]

I?aki



[Rd] Fast way to call an R function from C++?
=?UTF-8?Q?I=C3=B1aki_Ucar?=