Karim Belabas on Mon, 13 Nov 2017 23:31:19 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: ellheight tutorial |
* Bill Allombert [2017-11-13 21:45]: > On Mon, Nov 13, 2017 at 09:30:41PM +0100, g hillartin wrote: > > Since the rewriting of the ellheight0() function, the example at end of > > p.27 of the Tutorial has become inadequate. > > > > It should (at least) read: > > > > hv = ellheightmatrix(e, v) > > ... > > perm = vecsort(vector(#v,i,i), (a,b) -> hv[a,a]>hv[b,b]); > > rather > perm = vecsort(vector(#v,i,i), (a,b) -> hv[a,a]-hv[b,b]); > I think. Here's a complete version, I'll fix the tutorial. e = ellinit([0,0,1,-7,6]) v = List(); for (x = -3, 1000, s = ellordinate(e,x); \ if (#s, listput(v, [x,s[1]]))) v = Vec(v) hv = [ ellheight(e,P) | P <- v ] perm = vecsort(hv,,1) \\ indirect sort v = vecextract(v, perm) N.B. Note that, e.g. ellratpoints(e, 10) finds more points in a more natural way and a fraction of the time; unfortunately, it finds both P and -P, which requires some post processing compared to the above ... Here's a devious possibility : v = ellratpoints(e, 10); \\ naive height of x less than 10 v = vecsort(v, (a,b)->a[1]!=b[1], 8) hv = [ ellheight(e,P) | P <- v ] perm = vecsort(hv,,1) \\ indirect sort v = vecextract(v, perm) In the comparison function, two points having the same x coordinate compare as equal, else as a > b; the '8' flag keeps only one copy (the first one) of "equal" entries... Thanks for your report ! K.B. -- Karim Belabas, IMB (UMR 5251) Tel: (+33) (0)5 40 00 26 17 Universite de Bordeaux Fax: (+33) (0)5 40 00 21 23 351, cours de la Liberation http://www.math.u-bordeaux.fr/~kbelabas/ F-33405 Talence (France) http://pari.math.u-bordeaux.fr/ [PARI/GP] `