![]() |
|
|
#34 | |
|
Mar 2009
468 Posts |
Quote:
IMO ldesnogu cannot be slower than you. |
|
|
|
|
|
|
#35 | |
|
Nov 2003
22×5×373 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.... |
|
|
|
|
|
|
#36 | |
|
(loop (#_fork))
Feb 2006
Cambridge, England
72×131 Posts |
Quote:
If you don't have a power-of-two radix then you can't use the bit-twiddling methods at all; and if you do have a power-of-two 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 2011-07-07 at 15:25 |
|
|
|
|
|
|
#37 | |
|
Nov 2003
22×5×373 Posts |
Quote:
|
|
|
|
|
|
|
#38 | |
|
Nov 2003
22×5×373 Posts |
Quote:
For a radix that is a power of 2, you are entirely correct. logs will be slower. |
|
|
|
|
|
|
#39 | |
|
May 2011
France
16110 Posts |
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 ![]() |
|
|
|
|
|
|
#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. |
|
|
|
|
|
#41 | |
|
May 2011
France
7×23 Posts |
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 |
|
|
|
|
|
|
#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. |
|
|
|
|
|
|
#43 |
|
May 2011
France
101000012 Posts |
I say BSL
not BSF so no problem if n= or -1 BL reteur or 31BSL Bit sighifiant left BSR Bit signifiant rigth BSL-BSR BFR a,R Bsl a,R1 Sub R1,R1,R3 RTN R3 n-&(n-1) MOVA,R MOV A,R1 Sub R1,1,R3 AND R1,R2,R3 RTN R3 It ' snear ![]() ![]() ![]()
|
|
|
|
|
|
#44 |
|
Dec 2010
Monticello
111000000112 Posts |
The way this is handled in a code like P95 is that tests are run at run-time 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. |
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| More Power!!!! | petrw1 | Teams | 10 | 2019-10-15 17:36 |
| TDP as power used? | CRGreathouse | Hardware | 9 | 2016-02-06 18:46 |
| How much power am I really using? | petrw1 | Lounge | 19 | 2013-12-13 13:00 |
| Power??? | JohnFullspeed | Programming | 5 | 2011-08-30 16:28 |
| IBM Power 6 | Unregistered | Information & Answers | 7 | 2008-08-30 14:36 |