Karim BELABAS on Thu, 28 Jan 1999 12:37:52 +0100 (MET)

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

Re: Lists?

[Paul van Wamelen:]
> What is the best way to set up a lookup table in gp. As a t_VEC or a t_LIST?  
> Why? I'm using a lot of vectors of vectors but it seems very slow. The same  
> thing in Mathematica is much faster...!

The best would be to program the thing in C (then use install). From within
GP the best you can do is to use lists and use setsearch/listintert

 * if the table is fixed, use listsort, then setsearch.
 * if the list is built incrementally, setsearch(l, elt, 1) return the index
where elt should be inserted in l (0 if already there), then (list)insert it.
  if (index = setsearch(l, elt, 1),
    listinsert(l, elt, index)


P.S: hashing may speed up things depending on the exact context
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
PARI/GP Home Page: http://hasse.mathematik.-tu-muenchen.de/ntsw/pari/