Max Alekseyev on Sat, 24 Feb 2018 22:24:25 +0100


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

Re: forpart() behavior


Dear Bill,

Could you please support of partitions of 0 when amin=0 as in
"forpart(p=0,print(p),[0,5],3)"?
It would be very natural to produce a vector of all zeros.

Relatedly, I see nothing wrong in having nmax=0 when nmin=0:

? forpart(p=0,print(p),[0,5],[0,0])
  ***   at top-level: forpart(p=0,print(p),[0,5],[0,0])
  ***                             ^---------------------
  ***   incorrect type in forpart [expect 0<=min<=max, 0<max] (t_VEC).
  ***   Break loop: type 'break' to go back to GP prompt

That is, the "0<max" condition seems superfluous here (also, I'd
change min/max to nmin/nmax in this error message to be consistent
with the documentation).

Thanks!
Max

On Sat, Feb 24, 2018 at 4:02 PM, Bill Allombert
<Bill.Allombert@math.u-bordeaux.fr> wrote:
> On Sat, Feb 24, 2018 at 09:16:03PM +0100, Bill Allombert wrote:
>> On Sat, Feb 24, 2018 at 12:06:39PM -0500, Max Alekseyev wrote:
>> > Hello!
>> >
>> > In PARI/GP version Version 2.10.0 (development 21603-bef585b) I observe:
>> >
>> > ===
>> > ? forpart(p=1,print(p),[0,5],3)
>> > Vecsmall([0, 0, 1])
>> > ? forpart(p=0,print(p),[0,5],3)
>> > ? forpart(p=1,print(p),[0,5],[3,4])
>> > Vecsmall([0, 1, 1, -1])
>> > ===
>> >
>> > I believe "forpart(p=0,print(p),[0,5],3)" should produce "Vecsmall([0, 0, 0])",
>> > and "forpart(p=1,print(p),[0,5],[3,4])" should produce "Vecsmall([0,
>> > 0, 1])" and "Vecsmall([0, 0, 0, 1])".
>
> No, see below:
>
>> It is a bug I introduced a long time ago in commit 941833e2
>>
>> Older version give correctly:
>> ? partitions(1,[0,5],[3,4])
>> %3 = [Vecsmall([0,0,0,1])]
>
> Actually, this is wrong too. The doc says:
> the length is the number of nonzero entries.
> So the correct result is [].
>
> Cheers,
> Bill.
>