Re: [proposal] forvec over cyc

Karim Belabas <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <[email protected]>
Thanks for the pull request. Merged to master. :-)

Cheers,

    K.B.

* Pascal Molin [2022-11-14 14:00]:
> Dear Pari devs,
> 
> I consider the forvec loop one of the top features of GP programming:
> really useful, and painful to write.
> Still:
> - I find myself writing quite a lot forvec(x=vector(#c,i,[0,c[i]-1]), ... )
> - I also need to iterate over the lattice Z^n
> 
> I propose to improve on these two aspects by extending forvec with the
> following additional syntax: if if cyc is a vector of nonnegative integers,
> forvec(x=cyc, ) would iterate on representatives of Z^n/cyc Z^n.
> 
> In particular, if c has positive entries, forvec(x=c, ...) is a shortcut
> for the former forvec(x=vector(#c,i,[0,c[i]-1]), ... )
> And if c=[0,0..0], it would loop on Z^n. A choice has to be made on the
> ordering used, I consider the consider lexicographic ordering graded by
> L^1-norm.
> 
> Specifically, for n = 3, the loop forvec(x=[0,0,0],print(x)) gives
> [0, 0, 0]
> [-1, 0, 0]
> [0, -1, 0]
> [0, 0, -1]
> [0, 0, 1]
> [0, 1, 0]
> [1, 0, 0]
> [-2, 0, 0]
> [-1, -1, 0]
> [-1, 0, -1]
> ...
> (the loop is infinite)
> 
> Finally, if c is a mixed vector of zero and positive values, forvec(x=c, )
> does what I think the most useful : loop on graded-lex elements, with
> torsion components having L1 weight 0 (so one always iterates over torsion
> elements before moving to the next lattice element).
> 
> So that forvec(x=[2,0],print(x)) gives
> [0, 0]
> [1, 0]
> [0, -1]
> [1, -1]
> [0, 1]
> [1, 1]
> [0, -2]
> [1, -2]
> [0, 2]
> [1, 2]
> ...
> 
> I made a branch pascal-forvec-cyc which adds this syntax.
> I used it myself for some time, if this sounds useful for others and
> reasonable for gp syntax I would be happy to have it merged.
> 
> Remark: I did not implement flags, one I could think of is to iterate on
> centerlifts of the quotient.
> 
> Pascal

    K.B.
--
Karim Belabas  /  U. Bordeaux,  vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
`
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.