Bill Allombert on Tue, 06 Feb 2024 17:59:29 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Looping over ordered partitions
|
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: Looping over ordered partitions
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Tue, 6 Feb 2024 17:59:07 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1707238748; c=relaxed/relaxed; bh=cnV2IXLPXjPUYcR1pAKJO+uTJfEavWCme9QkbM2DYNc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=NlhPm2a9mwhfn6bdnJuLfX2lFa9Lnq/OGz4LGYdW+APtpJmadyXcqyVvm9g64cyDT73AnMqf32D8RupFkK7mh6i8rTvS4qiBKcNMMDUoxJgSSW3VAmnLkTKSxBB7vVhj9pVRT6C5Yt/843aR12U8Bf/+j3S0HEZolWI2Hp++jGCaWJ1aJf0IGg4T07E+N3R0Uda9fmEtW9jxjK9BXaE0/eHP+qo/jsjnFWhRDN3bS2CuXC5aYLIuf7RaWg2MFpWaHVEgpMVqcpoMwNkq9Mentl8OaN+9rbzVGsGSTmsEgdVgBVhndCDlqemBFXg7aPpTy7AFF+wju3xE3NMXXg2JEE7LtWKr6RK0trx4leGg2TDstCCNsMZVCFrx4pkk0QJmPhhhU2ymSAvoqPJ83lkYr0Ox9WgZP3/YzClnAVp95epsqOgH8kxytoU/tr7JUzBLJJcTXyhUtSbvo0CSHm3iujdTNRWrFZ+4mTQEnv6oool0wqoerRqEI1BFss3L95ZfMhgZ3suK9PpXQtsFZ9srBaL3/Rvj+wN/a0yDA+Rw5WZseCUVuKy9YUfg7uotYdI+L/jg4LWfggtMzwbQe2xmJLX/tPPT6+9VI1gUQJuoVXxiuwiETF6MU4Qk11OLYCHIdD2j3U6/TlKzhz84A1eUBSy1EbXtS7+5xllZWzZBZTM=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1707238748; cv=none; b=fB5Hk45cO/xi1L1yDzsSkGwBd6G8V8SUZi+cKieFygaJX4F7lGqccTuees2kfRGxpe+Ip6NVZTh+7MyLI9uXMUW3putaJBahziPXjLQWGtgsPgH10BMDZSMEOaUuqmO8ekYDy5S5m0EtPfpEmeG9yxPPsUGSCEKFkCcsCjy/LCcRi4IE0NhzGISKBo5Ji3TOvKt/s2zqbR3be2rGFj98R9cynZQ2Inx2xrZiPiIYobmk+NoSTzrpQkGrAHqwk53fDcUyUPo2QVz/ys11RuraoJAYJBDscimwJ26aNMAG8i9cnMxj896mVIpuhsHAtxj5P+ZYxuKf2NudjDWClkTI+81I95MJiCGTFp7vBBGviLTKlJb1Szxw/pJQUzK4MlaADh2Kd0dL5dwr3lghIJ4lPLl2f4ub+mBNk8k3Z1cTWYbWNB2WhxHDmzeeu5rTOyQS/eaDwLU55UP87kffLykGe6goOYKmcxa7vBmed6Qxo+ex4/K/LeKr8+1/dZT33giFCEu1Fd82EkNWyANjFk2vPq6/OCWWM2kAd3X6MLYuoX5/jvn8MKDK0gpeDDX6+nSX9MXPnURMVg3g3slPhv40tBooea8YZ2RMg4PYVaX5X1Q5RB4AbWc55JygbVraANzxxX6HlAABU/k4m3YryxYdHnAUWmbal5W7axyUzE+YeXY=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Delivery-date: Tue, 06 Feb 2024 17:59:29 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1707238748; bh=cnV2IXLPXjPUYcR1pAKJO+uTJfEavWCme9QkbM2DYNc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=jYFjZ5Aa1BcFfrfl4AfuGUsd/1uzv6JT8iLKSornNt1aEkm6eVQxz5a92Jrh4z1mc elW5fS0k5IwQhPudkE5GzgeDEoxgDmEUOW6gjwKXbH3en+V81cWUtMJyMnN4QqRv/6 lvOchZ8BAVQ9ht5JCM+ocujP2hAOPhwxwqMXvurCcGa3Z7x3+ibrK9JHnOlnWgEMPd eojpve0xZ+zyPDOFYm59MW4Gk3HqAUsM4iYLgO2opVHPP2uuDXecuKOG6QtyHqyfyP VlC0D5KeVj1stlh+4TQBEFmSnB/Y8AsY0JKHeeJDNAp/9KbINTxzLkrxojHri/zQDs 4V71u/DswQXauLI1rKTWW/BVYni++AYPBz/TKVi1NpXJ+qqFHfuk7d70XZOGxuRedp IUNJGOaSTTcZBKDfGc1eANg5gYlOhjfp1VF9ULPmDYnaat5qbtuIPngrgS7o3yUclJ lXGj4hUfCRKEkTSNTy2yi6AGwIVXwZ9Bet2C581BI2XHz3SUU/PCh52sjMjisgYcft zgIdBHcnPFATNc968T+KxUqyk2be+pplygPVgLMzkcaQ1rT6pJGMF4IjKtoIsk4dfD nH3B922/lVI1hJfLNyWY4dJSqYI4BKpcXrzTa2Yv0XUP/Y9eCuLCYR7Q8BwsrTD32k v9FM67ps6WdBrqSl6CVNizG4=
- In-reply-to: <CANXmBjwYhFiwRrYUGZMsWyjwP955_ogiNMYDwKbENhhPGQhekA@mail.gmail.com>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <CANXmBjwYhFiwRrYUGZMsWyjwP955_ogiNMYDwKbENhhPGQhekA@mail.gmail.com>
On Tue, Feb 06, 2024 at 11:46:55AM -0500, Charles Greathouse wrote:
> The looping commands force and forpart are very convenient. I have a
> problem I was working on which is looking for the smallest vector (in terms
> of vecsum) with a certain property. What is the best way to perform such a
> search in PARI/GP?
>
> In my case I have dimension/vector length 11 and sum < 31. (I have an
> instance with sum 31 but it's probably not optimal.)
>
> I can do a forvec, but even forvec(v=vector(11,i,[1,7]), ...) takes a long
> time (and spends a lot of time looking at values with sum > 30), and I miss
> instances with numbers larger than 7. Or else I can use forpart but then I
> need to permute the values (and in my case I definitely have duplicate
> values, so naive 11! permutations are wasteful and slow).
Use forpart + forperm!
forpart(x=30,forperm(x,p,print(p)),,[11,11])
Cheers,
Bill.