Bill Allombert on Wed, 28 Dec 2022 20:19:09 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: A022921-code
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Wed, 28 Dec 2022 20:17:54 +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=1672255079; c=relaxed/relaxed; bh=fUQztnBsCIakLev3QnXnPZBqh+hdnY85htyqCUKH6NQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=XmCoa7SF8yBC9ZXZp08ZvShe6LPh7tnFEyYDx7qHqII6BBN7a0LzFVn2V4cQQVaPm1G0UulDZWNP55BYIMfn0tKFrL6Qd1fyVjhGqL4f9wsj7KMIoPjfPlUDC1jGHxFZLBlSpACmOzYd0rYvf3C9k9EgG6Y7pViYkYQ//nR/JJgPhIGOwBgruVBgNVOPFMuLlRNTEqDYSuFCrD5v78RONwtkY6HrfsbTodmns/gZnObDml8wQpQUg1u+ZhSWdnT9RukP2GiwdDrcwxKxPVtatj0W+0j2Nd4ggviVmMBrVH67LnBD6uL2H4q0sR2ZvkhGSkFXDroh7ZBZU3QqvthzcguRhuAjg9aflSjiXYOiM8Uq6bzEJdhZIs5nTGzse16lF4rRuEisH/baRZCIEYyg58swgQcBQRCaBkGYuB+A4rg22UhXCZI4g5XOXmITYG5ehj3MFwZH9BVzSLMctwdmcesieLL+YRfKxAngP5s5EM1+vYR9fjKJvrE1ascWrsbuR4lsdfN6ixOpI/oWu8WS0EK03LNiOgN4ZUEhkkit8N17D8rnGVaY1hT+PpQuMJcJ2YzCX1Qygg3vg9uhBYPRBnJv8vWOnWcgSBf2UsODtwPzobGA0AI5czoAD9cenomSfGuFxbB8dCORJHdbmBGU77hSYh22NBhuXWy8+Ty3F78=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1672255079; cv=none; b=poabB4lq5dGtLqyUJw+/Bu5POWFwN1gpiIAAwbhNdG8oB4GuU5BXq/pk0e4Po+S/HIcfJJyuC4J97C3YGG5ReAQlMitrboaVDtLjOBzFM772NYCT9ldyLAtDHlGtCmRMDq07t3m5deGGury99QmytF1ZgZsPw8iCC2csxQrCDGe3pPmFihwc4SyOZ4GNM4nj7x/eo6Dod3obV11bq52jmSuZuqs44MGtPv6Lu8NJbODIGY/dr/MmI+devaz0jYYQqTbxKn0Wjl7YgbpqJ+qQSTF7ZQcJkhfC7i6+esWBrTMNjYW6tNFJTBo1276XLDc9BwWHrBjh9BVZox+snC7gVrZ/1jv440XKPqXMJCiUc28fIhNZrGPJITuTmHM2+Fj7pRhX/P5CnyXO2uSTk1N7KZ0ImcSu8X1/f5igE3n9/Ls6n6wfgn20/QX0X1tyVQkcSq1Zat/uiHsNQv9hkMt13xe5iiMY4bYS2/DBuUDgQdcZ4hyGuiSpCPMAQ+zJO4Ljshu9D7+ZbQ1wVNZ2GXUlUErdYjOtFAbBg8CWRTsgBtgL4yshblCrrxknJtn4swF/iTWEEOfeVJV66QEOfUE92/fvQOH9PSyTNdT8az60CQIs4Uy9H1AAqNdcJO+IMaLKVBhXiiQ2n5GzUBKLvwEi/KAjre+BM3ITF7BP+vU4vVY=
- Authentication-results: smail; arc=none
- Delivery-date: Wed, 28 Dec 2022 20:19:09 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1672255078; bh=fUQztnBsCIakLev3QnXnPZBqh+hdnY85htyqCUKH6NQ=; h=Date:From:To:Subject:References:In-Reply-To:From; b=E10kal9kjejHBtv4sLQ0/2m2efOvxvQRug4mZKQJvo60CWydCEiO/qLH4SP1D+XFL t2BBeP4mfrOxlqp3KDReSGJ3tcIDlelq1yH+AJ1TlgF6snUqMz4CV8oRjE1LeCZ+w/ 18wf/ItSwJzxXafN0K/WST+Mejh3TbA8ef21EdR4LFogEgZ35FGaHiOaITRAJBB9IA mbAMJLpoqNKR/fgHyB5odtu7ggFK9ANwqOyYtDOYWLJaWytcCMle6VJEOqanVszcay z454VajqsXJycx56J745IS8WMjDhYnR//mDFOwlV6MxkYJUfnlAxkRBOgNhOgTqHBh rJofISKpfGs9srst12+/htghlaADGP07WiAryn3rBqImmmoIiwLxBnbdKacjwx91l6 Yvur5+QC+isifezYFEzHtZZEn7/jkAW9Jc2YAB39OFXMUHUjF9pID7bfs7xWQ42faA ocbB1itefCHqYpTZqpg/cD8+eDpchhLtAysNO63fCbbZpnBYOmc8Hxq7/Dsi6Uvm88 /PbOtRdzJjz36X/jUduYGaVRusdvbGnzS0rB6PeVEu1V18SQmTBZmgnALQKrZBkKR8 lPNv0TDMeNpW3Q6x21NNX7ctJHjQbKXcGWXDX/gOhFgiBom0p8Ff4nLASj77H8CJsX FeXt25F8Tl/dfgs3znxUrPcA=
- In-reply-to: <5ca3aa12-ac8a-1203-141a-b5564dff8eae@isolution.nl>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <22f99a3f-71e6-40b4-2fe2-4976ce949665@isolution.nl> <Y6x0FqK00IJGPYWB@math.u-bordeaux.fr> <5ca3aa12-ac8a-1203-141a-b5564dff8eae@isolution.nl>
On Wed, Dec 28, 2022 at 07:53:49PM +0100, Ruud H.G. van Tol wrote:
>
> On 2022-12-28 17:51, Karim Belabas wrote:
> > * Ruud H.G. van Tol [2022-12-28 16:28]:
> > > [ logint(3^(n+1),2) - logint(3^n,2) |n<-[0..98]]
> > >
> > > is half as fast as
> > >
> > > my(n0=logint(3^0,2)); [ -n0 + n0=logint(3^(n+1),2) |n<-[0..98]]
> > >
> > > but IMO looks ugly.
> > >
> > > Is there a both "nice" and fast way to do similar?
> > Not sure about "nice"; but faster, definitely:
> >
> > ? N = 30000;
> > ? w0 = [logint(3^(n+1),2) - logint(3^n,2) | n<-[0..N]];
> > time = 767 ms.
> >
> > ? my(n0=logint(3^0,2)); w1 = [-n0 + n0=logint(3^(n+1),2) |n<-[0..N]];
> > time = 355 ms.
> >
> > ? my(v = [logint(x,2) | x <-powers(3, N+1)]); w = vector(#v-1, i, v[i+1]-v[i]);
> > time = 20 ms.
> >
> > ? [w == w0, w == w1]
> > %4 = [1, 1]
>
> Pretty "nice" to me.
>
>
> I'm testing on an M1-Max, and could *not* run your fastest alternative under
> 120ms.
>
>
> But then I slightly changed it to
>
> my(v = [logint(x,2) | x <-powers(3, N+1, 1)]); w = vector(#v-1, i, v[i+1]-v[i])
>
> (so added the explicit '1' with powers)
>
> and then it would run at least twice as fast, and would (sometimes) finish in 29ms.
> How weird is that? (No need to answer!)
It is not:
CHANGES
15- powers(t_INT, ...) was very slow
This will be fixed in 2.15.2 which should be released soon.
Cheers,
Bill.