Bill Allombert on Wed, 29 Nov 2006 16:20:14 +0100


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

Re: Universal empty objects ?


On Tue, Nov 28, 2006 at 10:13:32AM +0100, Loic Grenie wrote:
> 
>     I was just idling through the code and I noticed that there are
> 
>    - 92 lines containing cgetg(1, t_MAT),
>    - 90 lines containing cgetg(1, t_VEC),
>    - 11 lines containing cgetg(1, t_VECSMALL),
>    - 30 lines containing cgetg(1, t_COL).
> 
>   Wouldn't it be a wonderful idea to create new universal objects
>   gen_nilmat, gen_nilvec, gen_nilvecsmall and gen_nilcol (with maybe shorter
>   names) which would be the corresponding nil objects ?

Well I frankly don't know what would be the impact. How many of them
are used as return values for fringe cases ?

The main advantage of having universal constants is to reduce storage 
requirement for objects with lots of components, most of them being
zero (e.g. polynomials, matrices). I doubt there are PARI objects in
use with hundred of components equal to cgetg(1, t_MAT) as they would
rather look like a design flaw.

On the other hand, I don't see any obvious drawback outside the small
increase in complexity.

But personnaly I would rather add gen_m2=stoi(-2) for symmetry with gen_2.

Cheers,
Bill.