renjin icon indicating copy to clipboard operation
renjin copied to clipboard

Adding arima.c, make build work

Open tninja opened this issue 7 years ago • 5 comments

The arima.c get copied here, it include ARIMA_transPars function. C_ARIMA_transPars is defined in renjin.R. The build is working now, but for some reason the arima() report ERROR: Could not resolve native method ARIMA_transPars.

@akbertram, do you have any clue what I missed? Thanks in advance.

tninja avatar Aug 14 '16 05:08 tninja

Can one of the admins verify this patch?

bddbot avatar Aug 14 '16 05:08 bddbot

@bddbot add to whitelist

akbertram avatar Aug 14 '16 07:08 akbertram

Looks good!

I think you are probably missing an entry in the stat package's NAMESPACE file.

Can you also add a simple test case for the arima function? See test.stats.runmed.R for a simple example.

Thanks again!

akbertram avatar Aug 14 '16 07:08 akbertram

Not quite easy..

After adding stuffs inside arima.c to NAMESPACE, now it report:

arima(lh, order = c(3,0,0), optim.method="Nelder-Mead") ERROR: Sorry! polyroot not yet implemented! java.lang.ClassNotFoundException: org.renjin.primitives.R$primitive$polyroot

Found a do_polyroot function inside complex.c of R source code: SEXP attribute_hidden do_polyroot(SEXP call, SEXP op, SEXP args, SEXP rho)

Not sure how to get this thing work, I don't even know where to put complex.c. Do you have any clue?

tninja avatar Aug 14 '16 18:08 tninja

Yes, this is a bit trickier. polyroot is an internal base function that basically has two parts:

  1. R_cpolyroot and its subroutines constitute the actual C implementation of the algorithm and is largely independent of any R types or methods. It can be added to the math/nmath module or perhaps we can create a new math/complex module.

  2. The do_polyroot() is the R wrapper for R_cpolyroot. Because it's in the base package, it's difficult to compile the C code directly, so I'd suggest just porting it to Java. In Renjin, internal functions are implemented as static methods and registered in the Primitives class. See the complex function as an example.

akbertram avatar Aug 15 '16 08:08 akbertram