Bill Allombert on Wed, 05 Apr 2017 16:51:06 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: writing a "module" in pari-gp

On Wed, Apr 05, 2017 at 02:30:04PM +0100, Kevin Buzzard wrote:
> The second thing I do is to read in my module code, called
> drinfeldslopes.g, which implements all the functions I want. The code
> looks like this
> q=9
> B=100
> \\
> \\ that's the global variables set
> \\
> del()=[some pari function which will return a power series in t to
> precision O(t^B)]
> etc etc
> so the first thing I do is to edit drinfeldslopes.g and change the
> inbuilt values of q and B so they're the values I want.
> I then \r the file drinfeldslopes.g in the fresh session and then I
> have all my functions producing Drinfeld forms etc etc and I can do
> calculations. For example I can run del() and it prints out the
> Drinfeld modular form version of the Delta function for F_q[T] to
> precision t^B; I didn't need q or B as an input because they're
> globally fixed for the session.
> This worked fine in the 1990s but I do wonder whether nowadays I could
> be doing something more sophisticated. In python or sage I could
> imagine importing a module and then running some initial code to set
> some parameters.

Well fundamentally, you can use the same underlying technique:
write a function initmodule:

that set q and B and run whathever initialization code is necessary.

(You can also use 't instead of t so that the value of t
does not interfer with the polynomial variable t.)

Then do
\r drinfeldslopes.g

> Another thing I'd really like is that certain functions can take a
> long time to run (e.g. computing del() when B is large) so I would
> ideally like to remember the values of computations if they have been
> done already. This is an independent question but is this sort of
> thing possible or easy nowadays? This should just be a quick look-up
> -- do I have to write this myself?

Do you want to remember it across a session or to save it to keep it
between sessions ?

You can use maps, see ??call for a (too) generic example.
A simpler version:

delcache=Map(); \\in initmodule

  if(mapisdefined(delcache, n, &res)