Karim Belabas on Thu, 12 Jan 2023 13:14:40 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: probable bug of "ispower" function in GP: FALSE, apologies!
|
- To: luis.gallardo@math.cnrs.fr
- Subject: Re: probable bug of "ispower" function in GP: FALSE, apologies!
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Thu, 12 Jan 2023 13:13:22 +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=1673525599; c=relaxed/relaxed; bh=thCUYbIBuIhHuTAmg/V8PYcpwxqAH9NyWRwKkkcfw48=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=YF1qHeB2N9uOr79o9da/A7g1m+ny5UIYSyHmQzXZCrcZFJCh3NMu2KmdlJl9WbTas2Cm7IxFaK0/26v0GQfLgZgObm7rdgayQ6dIodEGek4uOnNyISa0vNldQUYsBwGT+g2bgleGHZ9yStbCmizuPZRx1mnpI4/SVAWKBdA6tmrynAiUVb9LcwJgJMgxQL3lc3iZdUP0E/BymwsNmphmjfo4Wobr8OuXFAJcTLXr36c1CUxM26UK1uo06krtX3a5Qt+ij9PxpwgTFLOikRyJReUmFFW+Q12tiF9nhTSpzADekxKGlq03oJXUt2wevz47TGdhTtMm0nFXVgiBzYw55ro1iof7GyWz11C/viDYx9XNal77GP07sjfZYh6fPp8+EmV69aW2uEui3oQGmIgrUaKs9vio8Yx6Zlr07w3hw1nkHzC/N0+OkgrgVZbdnx2W25rcOnu0ExK9QTzUEdUkfuLhTjTCJWTBNhsjpJWxPZEQoeI+64jN/hJwNkqdLt5OQEp1fnHHw+62zWS4MJAI9GRyED8TnOv2WQ9ykTnNe3cA4cL/1nzV4aF0f1s4VNp3layP2ndtIFM4TJ33N8c02JzRENWthsnUWa/H4aZ+Bsx3Sh+1XSR30zzOhX7T2EdIaLl/L/lXBTXZHpg+euzEu/lWU+bM6yhxuOxOjbHbnAA=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1673525599; cv=none; b=eJGjCmiHYFx4d4WvRxr7x+EecUrBYW1F7OkAWbsaCB1tvuvURgP8z7fPDmE2f/qqOwqa81Qr2Q/xuGkmRL9Nx5QV7fHr8qmhcrAdOX3oog0XQe3Ugt4dPvHLeYN7Ets/qvt/isqPt6cqr+4DEFSoRsDCTdsgnQrCz3FGki+YrJFW/V6ixUZRS9kuMpXv+N6mFNCodDYclyiQOdzs+0Ocd5hDA0UwMWVTqGIZQGHRIz+MAMGyKfb7VgKEsCO0xNwhrIW+sGAzTk7zg4guJ/w0Rq4SFTfNeXl7KsxmjMfHBhptigi1ReQeNNLpsmu1UOuQ3ecZ39xnq7Tf3vKutxBJhjnSVuBUouO/TlQWIFdqTIntlaBW8NplXMZep6wwL3tSkFLxjoyKgV9akToUF+Q2FC4O4YSvW60h/f0ywUGJOR2W73Lvpv0yKrPnIE0kQltga87pijZ81lUJv9nR3lDwufOi0q/II9ggikzeG/GNaVfqsjFhV2KDBhK37srB4a8zRdrh7pi0RR3jsNmnNL4WQXZRJBUiRgAfIgTLtJW3ant2359ZtCF1ywHtStsoyGnVHUl8WwnaVD3O0OjaDHFaLXULmsPNqkCdL226swpoQwk8Epk/Ug0Jf/T1i9JSxrtxorLubgkcAzcRwDA8g9WeKgiEWF6g7QIhhHemfC2XYvk=
- Authentication-results: smail; arc=none
- Cc: Vincent Lefevre <vincent@vinc17.net>, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>, pari-dev@pari.math.u-bordeaux.fr, Luis.Gallardo@univ-brest.fr
- Delivery-date: Thu, 12 Jan 2023 13:14:40 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1673525599; bh=thCUYbIBuIhHuTAmg/V8PYcpwxqAH9NyWRwKkkcfw48=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ACs/C2gLlxoFlJJ6xkrS6P4hsQyWeJ2I+/lb6dtyEiYia8OGGm0FokY/Ge3140PVG ueIlfi/9m3ae9Vv4GyOaXUPbpV0wNwtSmHL/eNmdFghsUXiY7/Y/9QhQAxsGwFffOu tozszMlhKxpBK+VTYx//zO4ltn3YwsjWAlCei4C4DTypo6MbPkyIoN8ECYlx1iJttP NkLtq5TjvIokHbWVprmUKQaHDK7nnJb5fbRc0H3CVGd09WPFbQm3HAFLYLmpCqSWL4 ao+qPOKzYaEr2+hSsGgWGDbkj0JuhwjVXmg5XW2SrqUsLnEEgvCNQeLF6SSM58yp0b /WIQwipRCy8c3tc38P9W/DCA+ZA9tvh1vGvjiSTTTMB/5Th8xdfATRckQG8aZHikxT k5EGANRoED71rDPYvDx+IcTWcLPWQxdb0gX/MBJZcG5u+pd85jrCdizAya480jZmSA piIo1ygjizHM1TuwSbuK6Q+rEGpEwWX2TOM41l6Lyp0mXM//WQHNjVFtTBbYNCCS0m 8BOQbgOwM4+wWD0Li8RaWr3MFANvi/SkEociwcogr/f47eZh39pAW33cmDtfqNSwiV /VbEPFHcCEU6pSVb6urm/Bupk3F+QR3iQrzB7yHgBPKwphRUvlUd02a5XB3N+WvyQ3 +eBy/VhinrK9ac4sKhS4ZOi8=
- In-reply-to: <20230112114055.GD9012@zira.vinc17.org>
- Mail-followup-to: luis.gallardo@math.cnrs.fr, Vincent Lefevre <vincent@vinc17.net>, Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>, pari-dev@pari.math.u-bordeaux.fr, Luis.Gallardo@univ-brest.fr
- References: <20221015110556.Horde.DzRB347NPa1ivF_tMR97m6u@webmail.math.cnrs.fr> <Y0sXHmbHi3ZArXpG@seventeen> <20230112121305.Horde.KDGYfCiJflyFSjcbXnamB00@webmail.math.cnrs.fr> <20230112123109.Horde.sK95S0mK7_BhhK_9PxG6uTU@webmail.math.cnrs.fr> <20230112114055.GD9012@zira.vinc17.org>
* Vincent Lefevre [2023-01-12 12:40]:
> On 2023-01-12 12:31:09 +0100, luis.gallardo@math.cnrs.fr wrote:
> > I misunderstood the definition of "ispower"!
> >
> > I wanted a function that identify directly if some integer is a power of 2
>
> I suppose that you can use something like
>
> ispower(64,,&n)
>
> and check that n is 2. But I suppose that for large numbers, this may
> be inefficient because ispower() will not just check for powers of 2.
Use hammingweight(N) == 1.
Or v = valuation(N,2); N >> v == 1 if you need the exact power. (Will be
a little slower.)
Cheers,
K.B.
--
Pr Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
`