|
|
PIEBALDconsult wrote: You don't mean a big integer class?
No, I prefer to roll my own, only my functions process only positive integers. I do not use C++ or .NET, I am a MASM(5,6,7,8,9) programmer. OBTW, I read the class documentation but could not find a SQRT function, did I miss it somewhere?
If you are interested, I can email you the RSA.txt file (if you do not already have it) and you could implement and test the SQRT function and report the timings from the big integer class. My timings were taken on an HP Pavilion dv7-6c23cl - 6GB memory, quad AMD, 2.5GHz, 32 bit assembly, console application.
What I was looking for was anyone's WAG about how long the square roots of 576 bit to 2048 bit integers should take.
Dave.
|
|
|
|
|
I have several more questions to ask about bignumb processing, but since you were were the only one to respond to my original question I thought I'd just ask you directly via email, however your email seams to be blocked so I will ask here directly.
When you select the low limit for a potential P value of 40% of the decimal digit count, what would that be? Lets take a simple example - 40% of a 15 digit number would be 6 digits. My assumption is that it would be 100,000, 6 digits and the lowest number in 6 digits. If I wanted to insure that this was an odd number, would that change to 99,999 or to 999,999? 99,999 is not a 6 digit number, but 999,999 is certainly greater than the minimum 6 digit number of 100,000. Which should be used as the limit to match what RSA would generate for encryption?
To calculate this in binary, consider that 10^14 is 100,000,000,000,000 (15 digits) = 0x3,8D7E,A4C6,8000 (50 bits). 40% of 50 bits is 20 bits. The lowest 20 bit number is 0x8,0000 (the lowest number in 20 bits). If I wanted to insure that this was an odd number, would that change to 0x7,FFFF or 0xF,FFFF? 0x7,FFFF is just a 19 bit number, but 0xF,FFFF is certainly is certainly greater than the minimum 20 bit number of 0x8,0000.
The upper limit of 45% is easier to figure out. Just create the maximum number for that digit count (or bit count) and increment the count and create the
number as a base to a power, then decrement the result by 1 (it will always be odd, either 99999... or FFFFF...).
Dave.
|
|
|
|
|
It seems you know more about it than I do.
|
|
|
|
|
Thank you for the reply. I guess I'll just select the smallest low number to guarantee that I get most of the created keys. I already plan to check that low limit and if I find that that low limit value is above the solution value, I will just use it as a high limit and use the value 1 as thee low limit.
Dave.
|
|
|
|
|
hello all,
first of all escuse me for my English.
I am looking for help at the following problem:
at my final project for Bsc i get data and need to decide if a threshold had been crossed (tha data IS NOT BOOLEAN.. i get data about the velocity of an object)
the deffinition : if i get that for 1sec at least the given data is above threshold - It has been crossed.
it ofcourse complicated beacuse i need to filter "noise".
i thought to use "ALPHA FILTER" or "X/Y decision" or "Avarege" and other.. but i am sure that someone did a these on that and there is a proven algorythm to handle it.
thanks for all yours replies
sincerely yours,
sia
|
|
|
|
|
Need a lot more detail. What programming language? Where are you stuck exactly?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello everyone.
I'm looking for an algorithm to track the numbers at least duplicate content in a two-dimensional array to draw complex objects composed of rectangles, squares, triangles, hexagons, etc.
The constraints are:
- I require at least how many numbers should not be duplicated
- The vertices of the objects must contain at least duplicate numbers except those required
- Objects should be placed symmetrically
An example here:
example
In the example you can see duplicate values 0,10,15,18,19,25*,35,45,50 and the three individual numbers. * shared between two objects
The numbers 16,27,46 are the three numbers that I requested unduplicated
Course can be traced different combinations of objects that match the given condition.
They are looking for a fast algorithm. I have processing times biblical!
Thank you in advance
|
|
|
|
|
Looks like there is more than one problem.
I think you should give more details, like short data list with an explanation of how you deal with the problem (may be code snipset, or algorithm.)
Question: numbers are integers ? minimum and maximum values ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
I have been working with C# using the FlickrNET API in order to create a slideshow that shows images from Flickr based on a single word search term.
This has been easy enough to implement thus far but the images shown on the slideshow are sometimes repetitive i.e. they show 10 of the same thing taken at a different angle by a single user.
As I am a bit of a newby to coding more generally I was looking for general advice or pointers on the best way to randomize these images according to their other related tags. So one way this might work is if someone searched "London" it could show everything with the tag "London" but use the other tags to organize the images so they are more diverse.
|
|
|
|
|
for example:
9 = 1001 in binary so the function GetNumOfBinary(9) = 2.
I know I can do it in o(n) (time) by convert it to binary and exam digit by digit.
I've been told I can do it using space as much as I need.
How can I do it? (it's seems impossible because I need to check every digit, doesn't matter which way I do it and it'll be still o(n))
|
|
|
|
|
Read this - http://en.wikipedia.org/wiki/Hamming_weight[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
תפסיק לספר לה' כמה הצרות שלך גדולות, תספר לצרות שלך כמה ה' גדול!
|
|
|
|
|
Thank you for the answer. This is the answer I was looking for.
Thank for the other for the answers.
|
|
|
|
|
There are several algorithms listed here[^]. For a 32-bit integer, you probably want "Counting bits set, in parallel[^]":
int CountBitsSet(int v)
{
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
Just don't ask me to explain how it works!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Just don't ask me to explain how it works! How, how indeed...http://en.wikipedia.org/wiki/Hamming_weight[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
תפסיק לספר לה' כמה הצרות שלך גדולות, תספר לצרות שלך כמה ה' גדול!
|
|
|
|
|
It first sums pairs of adjacent bits, then it sums the groups of 2, then the same thing with the nibbles, and finally it cheats and sums the bytes with a multiplication.
|
|
|
|
|
if you're using c++ gcc - __builtin_popcount
|
|
|
|
|
Member 11055093 wrote: I've been told I can do it using space as much as I need.
Fastest way with unlimited space would be a lookup table.
|
|
|
|
|
It depends on your abstract model. With the usual model, you can't do any better than O(n) (so o(n) is not happening, or did you write a lower case o by accident?) - obviously on a plain old Turing machine, you're going to have to read every bit.
But this problem is in NC. You could sum n/2 pairs of bits, then n/4 pairs of "2bit numbers", n/8 pairs of nibbles, etc, and you're done in log n steps, with each step taking logarithmic time too (adders) (sometimes not counted), all with a polynomial number of processing elements.
Similarly in "broadword computing", you would say that you could compute this in O(log n) broadword steps - using the same construction, but now every layer is a couple of steps (mask and add) (with the addition counted as 1 step, instead of as a circuit of depth O(log n))
Practically, on 32bit words but "pretending 32 is not a constant", you can still use the same construction for an O(log n) algorithm possibly with a multiplication trick to do several sums at once (already shown in answers) or lookup tables or (with as much space as you need, you could cheat terribly and compute any mapping from 32bit integers to anything in a single step), if available, the popcnt instruction.
For arrays you could use a pshufb-based trick[^] (pshufb is awesome).
|
|
|
|
|
I am new here, i have not found a link for Python,so i figured i'd ask any way.
I am trying to come up with an algorithm where you have several x-axis points like
d = [-5, -3.5, -2.8, -0.6, 1.2, 3.4, 5.6] and where you prompt the user to enter a certain point, the program should give the closest point to the entered value by the user.
Thank you.
|
|
|
|
|
This is nothing to do with Python, or any other language. It's a simple matter of sorting the intial values into order and then searching for the two points closest to the one entered by the user. Could be speeded up by binary chop (Google for that).
|
|
|
|
|
I know about the sorting part,i don't need to Google it, iam looking for the acquisition part(capture that nearest number) maybe you can enlighten me.
|
|
|
|
|
I suggested a solution in my previous reply.
|
|
|
|
|
You can lead a horse to water...
|
|
|
|
|
I think Richard was suggesting that you google "Binary chop" not sorting.
Try a search of "python binary search closest value" - the first hit that came up for me (in Google) was an answer to the same homework question
|
|
|
|
|