20110707, 14:36  #34  
Mar 2009
2×19 Posts 
Quote:
IMO ldesnogu cannot be slower than you. 

20110707, 14:37  #35  
Nov 2003
1110100100100_{2} Posts 
Quote:
I am not computing just the log of the first limb. I suggest computing an approximation to the log of the entire number. If R is the radix, then let N = sum A_i R^i i=0,M be a representation. Compute an approximation to the log of A_M R^M, and not just an approximation to log(A_M) by itself. log(R) can be precomputed. Only if M*log(R) + log(A_M) is close to an int do the other limbs need to be checked.... 

20110707, 15:25  #36  
(loop (#_fork))
Feb 2006
Cambridge, England
6,379 Posts 
Quote:
If you don't have a poweroftwo radix then you can't use the bittwiddling methods at all; and if you do have a poweroftwo radix then adding a large multiple of log(2) to something that you're wanting to check for being a multiple of log(2) isn't obviously an efficient way to proceed. Last fiddled with by fivemack on 20110707 at 15:25 

20110707, 15:38  #37  
Nov 2003
2^{2}×5×373 Posts 
Quote:


20110707, 15:41  #38  
Nov 2003
2^{2}×5×373 Posts 
Quote:
For a radix that is a power of 2, you are entirely correct. logs will be slower. 

20110707, 16:11  #39  
May 2011
France
7×23 Posts 
helpme:I m so bad
Quote:
I leave the mathematics for intelligent men like you You must learn modesty when you don't know orenot understand you say it. I don't know math so I ask when I need. It is thn Principe oaf education you learn when you will b and adult. no one except you find errors in my code There is only you to say that? But you never says where I make error For the power of 2 you don't explain us where my method was badyou only says that I I am bad. (Most significant bit= Less significant bit The value have 1 bit and LSB (not LSD) have the exact power) Sorry you don't understand hat you knows some thing that i do't know like Fermat factorization(thank to jasonp for is answer) but I also knows somethings that you don't know and perhaps useful for you I NEVER SAYS THAT I KNOW THE MATHS PERHAPS YOU UNDERSTAND THAT THE COMPUTER HAVE NOT THE HUMAN LOGIC BUT A LOGIC teach BY HUMAN. YOU WILL UNDERSTAND WHY THE Karatsuba MULTIPLICATION IS BAD FOR THE COMPUTER YO MAKE A STEP IMPORTANT OR WHY A SHIT DIVISIOIN IS NOT ALWAYS GOOD I wait your explication but I begin to know you You censure my tread to when,you dont have to answer Whereis the Chirtenson mail where he say tthat I can code more 20 lins.e Censurde also (Moderation is not censure) please answer to 1 why my method for thr power2 is bad? 2 why Karatsuba is bad for computer? 3 Why the mul by 3 in TSis bad ? John 

20110707, 23:22  #40 
Dec 2010
Monticello
5×359 Posts 
Hi John:
It is not that your method for the power of 2 won't work, it's that the amount of time the instructions you propose takes varies widely depending on exactly which intel CPU you are on. There are slightly faster methods. 
20110708, 06:05  #41  
May 2011
France
7·23 Posts 
Power 2
It's better to say why the solution id less better than other
which say Quote:
In the solution ons cycle for the sob 1 for 1 the and ,4 for the comp No problem it's faster but like I say if you want to knnow thr power my method give it. It 's better than a search n a list. John 

20110709, 15:13  #42  
Dec 2010
Monticello
5×359 Posts 
Quote:
http://mersenneforum.org/showpost.ph...5&postcount=20 There's also a context issue  if you have enough memory in L1 cache, you can simply create a logarithm table for one byte, and index by the byte into it to get either an error (not an even power of 2) or the logarithm base 2. A lot of this depends on how frequently you actually get an even power of two; you want the most common case to be fastest. All of these will be faster than a naive search of a list, as you say. 

20110709, 19:39  #43 
May 2011
France
7·23 Posts 
Error
I say BSL not BSF so no problem if n= or 1 BL reteur or 31
BSL Bit sighifiant left BSR Bit signifiant rigth BSLBSR BFR a,R Bsl a,R1 Sub R1,R1,R3 RTN R3 n&(n1) MOVA,R MOV A,R1 Sub R1,1,R3 AND R1,R2,R3 RTN R3 It ' snear 
20110710, 15:54  #44 
Dec 2010
Monticello
5·359 Posts 
The way this is handled in a code like P95 is that tests are run at runtime to decide which alternative is fastest, then the fastest alternative is run.
Thus, if you think BSL/BSR might be best on some machines, the program runs a little test of BSL/BSR on realistic data and gets the timing. Then the program runs the subtracting 1 method against the same data, and gets the timing. My table lookup method might also be fastest, so the program tests that, too. One of them will be fastest, so that is the one that you use for the majority of the work. Lavalamp has assured us that the people making chessplaying codes get very different results with BSL/BSR depending on which CPU is used. 
Thread Tools  
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
More Power!!!!  petrw1  Teams  10  20191015 17:36 
TDP as power used?  CRGreathouse  Hardware  9  20160206 18:46 
How much power am I really using?  petrw1  Lounge  19  20131213 13:00 
Power???  JohnFullspeed  Programming  5  20110830 16:28 
IBM Power 6  Unregistered  Information & Answers  7  20080830 14:36 