Gerhard Niklasch on Fri, 3 May 2002 09:31:03 +0200 (MET DST)


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

Re: Correct use of cgetg


In response to
> Message-ID: <Pine.GSO.4.42.0205030633220.115-100000@elios>
> Date: Fri, 3 May 2002 06:41:26 +0100 (BST)
> From: Mark Chimley <M.Chimley@bristol.ac.uk>
> To: pari-users@list.cr.yp.to
> Subject: Correct use of cgetg

> ... I have never created vectors before,
> but following a read of the manual, I came up with:
> 
> E = cgetg (6, t_VEC);
> E [1] = gzero;
> E [2] = gzero;
> E [3] = A;

E[1] and so forth are longs, so you should do

E[1] = zero;
E[2] = zero;
E[3] = (long)A;

etc.  (zero is the type-long incarnation of gzero).
Cast back to GEN when you want to use a component as a GEN.

Enjoy,
Gerhard