Hi,
I am writing C code for R, but in middle of the routine I want to call
solve(A,b) function. What is the right way to solve linear set inside C
code? Is it ok to just invoke La_solve()?
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/m
On May 8, 2013, at 2:24 PM, Matwey V. Kornilov wrote:
> Hi,
>
> I am writing C code for R, but in middle of the routine I want to call
> solve(A,b) function. What is the right way to solve linear set inside C code?
> Is it ok to just invoke La_solve()?
>
There is no such thing as La_solve().
Matwey,
There are a number of ways to do this, but it depends on what exactly you
want. Do you want to execute a call to an actual R function from within C,
or do you want to directly call one of R's internal C functions (which may
work but is not future-safe unless it is part of the official API)
Thanks, It is what I was looking for. But now, I poorly understand
environment conception. My initial C function in invoked from R (in some
environment I suppose), how do I know this env, to provide it to eval()?
Or, may I just make a clean env?
10.05.2013 00:13, Gabriel Becker пишет:
Matw
On 10 May 2013 at 13:34, Matwey V. Kornilov wrote:
| Thanks, It is what I was looking for. But now, I poorly understand
| environment conception. My initial C function in invoked from R (in some
| environment I suppose), how do I know this env, to provide it to eval()?
| Or, may I just make a c
On May 10, 2013, at 5:34 AM, Matwey V. Kornilov wrote:
>
> Thanks, It is what I was looking for. But now, I poorly understand
> environment conception. My initial C function in invoked from R (in some
> environment I suppose), how do I know this env, to provide it to eval()? Or,
> may I just m
Thank you all,
the following seems to work just great for me:
PROTECT(sx = eval(lang3(install("solve"),sA,sb),R_BaseEnv))
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
> From: "Matwey V. Kornilov"
>
> the following seems to work just great for me:
>
> PROTECT(sx = eval(lang3(install("solve"),sA,sb),R_BaseEnv))
You need to PROTECT the result of lang3 before calling eval.
And on the other hand, you don't necessarily have to protect
the result of eval (only if you
If you are fine with another package doing the legwork for you, calling an R
function from C++ is very easy:
R> library(Rcpp)
R> cppFunction('NumericVector fun(NumericMatrix X, NumericVector y, Function s)
{ return s(X, y); }')
R> set.seed(42); solve(matrix(rnorm(9),3,3), rep(1,3))
[1] -0.778649