Max Alekseyev on Tue, 20 May 2025 23:10:46 +0200


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

Re: forpart of zero and fixed length


Hi Bill,

I understand your explanation, but this design decision looks odd to me. You make a distinction between length and size, but personally I care only about size in your terminology. 
The somewhat ugly workaround for generating partitions of a given size whether or not amin is zero is
forpart(p=n, print(p), [amin,amax], if(amin>0,[psize,psize],psize))
Also, there seems to be no simple way to generate all partitions with zero parts for a given range of sizes, as specifying the size range (oddly) disables the zero parts.

Regards,
Max


On Tue, May 20, 2025 at 3:30 PM Bill Allombert <Bill.Allombert@math.u-bordeaux.fr> wrote:
On Tue, May 20, 2025 at 02:52:20PM -0400, Max Alekseyev wrote:
> On a related note, I do not understand why I'm getting different results in
> the following two examples (fist one looks like a bug):
>
> ? forpart(p=5,print(p),[0,5],[2,2])
> Vecsmall([1, 4])
> Vecsmall([2, 3])

This is correct: the length is the number of nonzero entries.

> ? forpart(p=5,print(p),[0,5],2)
> Vecsmall([0, 5])
> Vecsmall([1, 4])
> Vecsmall([2, 3])
>
> Also, in the second case, shouldn't 2 be interpreted as nmax and partitions
> with smaller parts (=1) be also generated?

   By default, parts are positive and we remove zero entries unless amin <= 0, in which case we fix the size #X = nmax.

Cheers,
Bill.