Max Alekseyev on Sat, 24 Feb 2018 23:27:00 +0100


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

Re: forpart() behavior


On Sat, Feb 24, 2018 at 4:50 PM, Bill Allombert
<Bill.Allombert@math.u-bordeaux.fr> wrote:
> On Sat, Feb 24, 2018 at 04:24:15PM -0500, Max Alekseyev wrote:
>> 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.
>
> this is inconsistent with the documentation: the result must
> be a vector with 3 non-zero components.

Why?
According to the documentation, nmax when amin=0 gives the length
(i.e., number of components), but the components don't have to be all
nonzero.
E.g., similar construction for partitions of 1 gives a vector with 3
components, with only one of them being nonzero.

? forpart(p=1,print(p),[0,5],3)
Vecsmall([0, 0, 1])

>
>> 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).
>
> So you would like it to be the empty Vecsmall ?

In this case - yes.
But a similar example "forpart(p=0,print(p),[0,5],[0,3])" should give
Vecsmall([0, 0, 0]).

>
>> (also, I'd change min/max to nmin/nmax in this error message to be consistent
>> with the documentation).
>
> The same code is used to check nmin/nmax and amin/amax.

Ok, this was a rather minor suggestion.

Regards,
Max