Ilya Zakharevich on Sat, 21 Jan 2006 22:52:02 +0100


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

Re: Missing functions in CVS


On Sat, Jan 21, 2006 at 02:59:43PM +0100, Karim Belabas wrote:
> > > 3) not used anywhere, 
> > 
> > To the contrary, I expect it was used in about 90% of usages of PARI
> > as library (since - good or bad - Math::Pari is widely used for SSHing).
> 
> I don't understand. You mean that 2-complement semantic for
> shifts of negative integers was intensively used in Math::Pari
> (or by its users) ? Can you give a realistic example ?

The << operator over Math::Pari values was using this version of
gshift3.  [Note that bitvectors are one of the builtin "quasitype" of Perl.]

> > >			and only catered for consistency with an alternative
> > >    definition in a relatively minor case.
> > 
> > "Relatively minor" is, of course, in eyes of a beholder.  There are
> > two usages of left shift: as division by power of 2, and as operation
> > over bit arrays.  You cut out the second usage.  I do not think that
> > bitarray usage is "a relatively minor case".

> bitarrays cater for extreme efficiency, which the GP interpreter
> overhead essentially prevents.

Let me disagree.  First of all, usually bitarrays cater for space, not
for speed (by definition, int is the speediest access unit).  GP has
almost no overhead for size.  Second, GP is only one part of GP/PARI.

> > > 4) easy to emulate at a minor efficiency cost.
> > 
> > Compare with "1" and "2"; if it were so, why not make it such with GMP
> > kernel?
> 
> What I meant was that for bitarray usage, bittest should be sufficient
> (at a minor efficiency cost, agreed).

Hmm?  How can one implement shift in terms of bittest?  And how can
you say that efficiency cost is "minor" if you say that "GP
interpreter prevents efficiency", and the algorithm is "complicated"?

I will be quite happy if gshift3/GMP would just use

  if (x<0) return -((-x-1)<<shiftvalue)-1;

for left shift of negative values (with bitvector-semantic flag) -
given that GMP is slower than native for (my) typical usage anyway.

Hope this helps,
Ilya