Bill Allombert on Thu, 01 Aug 2024 17:06:34 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Enumeration of partitions
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Enumeration of partitions
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Thu, 1 Aug 2024 17:06:30 +0200
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Delivery-date: Thu, 01 Aug 2024 17:06:34 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1722524791; bh=7aFEEt/Y8vw3FKK8VyVv4bMTUHf0C77C32/Pi+YxPqQ=; h=Date:From:To:Subject:References:In-Reply-To:From; b=g+HdKHn/+IQAvghHLX9YQvfle/sAlqWRiTkicxudewVjPC2pO3j9gPqyXUy2UVKlJ qGHTlPq/h89n/yfHjZG7Ac1wqHtsd/2JDaVzYLE4qtWQd7DQjmXGHLONe3N957QXRy vFvm0SeHkBXrx969QhetMlgjzXpkIXjUzAyGUSgoxu44BmfGNlXDFBbL5QEM3HTowC GOfoXw0cyfIf4vDUe6tf/vdQ8kNVpZBPpTK+/Hq+4DB3aLtkmD9OO4VctLA1sFrwKI zBeu++WqQKwk55m8qu6jlnx/1fDCT+H7RQx904lC0jYSGf7P+fUucygT5Z+oqYetpb IibH0ZXAQZ2pvzcv715WH1PCm/eZ6UUOJ0ADB9aGpk3HdsBYvgJ1ZFxcZjStEclkWN tO316wpQwcXV/hvDGG5lTac8xK0EOnkR5KR4hpiTI0jVLdlvKE77U9JK+EZvMYTXOV rClsSr9z1J4Wcs5DqS5Wg5I76lrAZ5cNdez17tn59pFPNYTL7ivUmw+o3hBq1Qb0As pJz3Urms8YBrKnJZKMlDMA4kykU0QMqYhz5xI0Q+GbZRpBY6xuwfMyxtuKs4sjYBzz cV8H/e5th5SgGSnpRat4PLxG8McSQZ1CxsPQaTUSeZTLUI8pufrz1/djrrgf1Z6mNT mmlQNwofwjLF74vQB3BCtfbM=
- In-reply-to: <6F814935-2C34-4EF0-835D-DA011D9B6E8B@math.cnrs.fr>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <6F814935-2C34-4EF0-835D-DA011D9B6E8B@math.cnrs.fr>
On Thu, Aug 01, 2024 at 04:49:03PM +0200, Emmanuel ROYER wrote:
> Dear Pari users!
>
> There are two ways of representing a partition of an integer n, either as
> (a_1,...,a_q) where n=a_1+...+a_q
> or in the form
> (1^{b_1},...,n^{b_n}) with n=b_1+2b_2+...+nb_n.
>
> Unless I'm mistaken, partitions(n) returns the partitions in the first form.
> How can we translate the result into the second form as efficiently as
> possible? (Related to: how to count multiplicities in an ordered vector)
You can use matreduce!
? matreduce([1,1,1,1,3]))
%18 = [1,4;3,1]
> ? Partitions(57);
> cpu time = 30,995 ms, real time = 30,995 ms.
> ? Partitions3(57);
> cpu time = 38,106 ms, real time = 38,106 ms.
[matreduce(Vec(x)) | x <- partitions(57)];
*** last result computed in 495 ms.
Cheers,
Bill.