Re: [Rd] pari/gp interface

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Tue 25 Jul 2006 - 20:33:56 GMT

On 7/25/06, Robin Hankin <r.hankin@noc.soton.ac.uk> wrote:
> Hi
>
> I'm developing an R package that
> needs to execute some code written in pari/gp.
>
> I've used this before from an R package (elliptic) but the interface
> is very
> basic: the R function creates a string such as the following:
>
> string <- echo ' ellwp ([ 2+0*I , 0+2*I ], 1+0*I )' | gp -q
>
> And then
>
> system(string)
>
> returns the output from gp which then needs to be text processed
> (translating "I"
> to "i", etc).
>
> I don't think this approach would work under Windows.

I know nothing about pari/gp, but I believe it does work on Windows too. There is system() command available on the Windows version too, but with slightly different arguments (than on Linux say).

Piping is available on Windows too, e.g. "dir | sort", although you should be able to get around that by writing to file instead and using ">" and "<".

You should be careful if your 'string' gets really long. Then it is much better to have a BAT file (and an sh file on Linux) to run your external calls, alternatively you call system() multiple times. However, I would be suprised if 'ellwp' wouldn't accept files as input too.

/Henrik

> Does anyone have any experience of calling pari/gp from R?
>
> Or any ideas for a more portable method than the one above?
>
>
>
>
> [
> PARI/GP is a widely used computer algebra system designed for fast
> computations
> in number theory. It is freely available at
>
> http://pari.math.u-bordeaux.fr/
> ]
>
>
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
> tel 023-8059-7743
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Jul 26 06:36:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 26 Jul 2006 - 06:28:45 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.