|
Ok, but then it doesn't help at all - you then have two pieces that are both half the original length, but together they're just as many bits to count as you had before.
|
|
|
|
|
Yah, that's why its fuzzy and I call swim because the lower half now has to shift and try again, or something.
I truly dk, this is one that I never mastered. I thought my post would generate interest but I hoped there might be someone else out there active with this sort of thing. More specifically, someone active in this particular forum who is doing the same nonsense I am. I notice here there dwell engineers, most sites are full of k-12 folks but my math is weak for formally describing what is going-on in my work.
I have parallel rotate xforms for discrete 8x8x8 manifolds, parallel collision and collision detectors for the same but no bit counter.
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
Hi,
the AND and OR stuff doesn't bring you a step closer; consider two bits A and B, their AND and OR:
A B AND OR
0 0 0 0
1 1 1 1
0 1 0 1
1 0 0 1
So, yes, the number of bits set remains the same when you replace A and B by (A AND B) and (A OR B). In fact there is only one out of four lines that shows a difference. But so what? it still is two bits that need to be counted.
There are several ways to count bits in a word; I have shown you the obvious ones; Harold has provided a complex mask-and-shift one; there are variations on those, especially when not all bits in a word can be set (say you have a guaranteed zero in every odd position (0a0b0c...). But none of those will be remarkably faster overall.
|
|
|
|
|
I think I have failed to impress the nature of the problem and the constraint that it be a bitmap. Too bad.
There are very good links from aptroot. And his links may indeed take me away.
Your supposition that the OR and AND at the top of a swim loop buy nothing is wrong.
No one has yet suggested a CA solution.
Oh yeah, my notion of "swim" came from feeding fish in a tank: if you sprinkle the food in a corner they all travel from random locations in the tank to the corner with the food.
Tadeusz Westawic
Sum quid sum.
|
|
|
|
|
Harold,
Seems that SSE instructions (PUNPCCKLBW) could be used to split up BYTES to WORDS, then the WORDS (actually LoByte of the word) used to table lookup to convert to a count, then packed add could be used to accumulate these counts, then further split to DWORDS and repeat. It is amazing what speedups can be seen with SSE conversions of simple things like string compare and strchr.
Dave.
|
|
|
|
|
Probably, but SSE has POPCNT as well.. ok that's SSE4, not just SSE2 like PUNPCKLBW (which I assume you mean)
I didn't 1-vote you, btw.
|
|
|
|
|
Harold,
Yes, I was referring to SSE2. Almost everyone has it. And, I just never worry about the voting, but it seems seems other Helpful Harrys have bumped it up.
Dave.
|
|
|
|
|
in my experience, a table lookup can go a long way, using either an 8-bit or a 16-bit index, and repeating for each 8/16-bit fraction of the data.
And then, are you sure you need the count? and nothing else?
chances are counting the bits is bus bandwidth limited already, so combining it with another operation may pay off big time.
|
|
|
|
|
Anyone know a desktop calculator that takes mixed hex and decimal inputs?
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
Windows 7 calculator does this, and I know there are other freebies out there. Google will tell you - ask for programmer calculator.
It's time for a new signature.
|
|
|
|
|
new sig
Tadeusz Westawic
Caveat juris excretorium.
|
|
|
|
|
Tadeusz Westawic wrote: mind is failing in old age
Sounds like me!
It's time for a new signature.
|
|
|
|
|
In my opinion Google is a good way to study!
|
|
|
|
|
where is the algorithm question?
|
|
|
|
|
Didn't Math forum get consolidated to this room? This is not forum for Math question?
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
This forum used to be called "Math and Algoritms" or something similar. But the math unfortunately had to go, so now it is about algorithms only. Advice on software selection is mostly handled in the Lounge now.
|
|
|
|
|
The Windows XP calculator allows this too.
|
|
|
|
|
The Windows Vista calculator has an option for hex calculations...choose the scientific option from the view menu.
|
|
|
|
|
Thanks All,
The salient feature I needed was mixing radices in same operation which the VISTA calculator allows.
Thanks once more.
Tadeusz Westawic
Caveat juris excretorium.
|
|
|
|
|
|
I'm looking for a solution to an equation that looks familiar, but I've forgotten too much in 30 years. I'm hoping one of our younger folks ( or mathematically skilled old farts ) can help.
Given the equation:
4R/D = Φ - sinΦ
what is the value of Φ given that D is constant, and R is known from other independent calculations? WolframAlpha came up with a nice graph, but I need an analytic solution that I can use to return a definite numeric answer to the calling program. Any solutions out there?
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I don't think that has an analytical solution, but it's pretty easy to solve numerically by using one of various techniques to find the root of
Φ - sin(&Phi) - (4*R/D) = 0.
Since -1 <= sin(&Phi) <= 1, you should be able to find an excellent starting point for iterating.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
That wasn't the answer I was hoping for, but you may be right. This may come down to solving a problem in more than one variable, using linear programming techniques or some other optimization methodology. The problem set involves a flow of fluid through a pipe; I want to be able to vary the slope of the pipe, or change the amount of liquid dumped into it and predict what the depth of water will be under steady state conditions; transient analysis is completely beyond my pay grade.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I agree with Walt, a few iterations of Newton-Raphson[^] should solve that numerically.
|
|
|
|
|
yup Newton Raphsom method would do it.
Also It would be helpful to find out what are the ranges of possible values of phi, say if phi belongs in -1 to 1 you can apply sine series formula to phi.
|
|
|
|