10-27-2013 11:38 AM
Dear
I have this problem it really so complex to solve for me
its not home work its related to my academic research
I have two stream of bits each one with fixed n bits length as follow:
x=1,1,1,1,0,0,0,0
y=1,1,1,0,0,0,0,0
I need to extract the following information
a1, the number of overlapping 1s:in this case is 3
a2, the number of overlapping 1s of X and 0s of Y :in this case is 1
a3, the number of overlapping 0s of X and 1s of Y:in this case is 0
a4, the number of overlapping 0s on both x,y.:in this case is 4
thank in advance
best regards
Solved! Go to Solution.
10-27-2013 12:08 PM
Mangood,
I have assumed the stream of bits as boolean array
so here is an idea
10-27-2013 12:11 PM
10-27-2013 12:47 PM - edited 10-27-2013 12:47 PM
Altenbach is right, we need some clarification on data types. Even if they are numeric values, you can still do bitwise comparisons with the comparison functions. And, just FYI neos, this is a much simpler way to count the number of true booleans in an array:
10-27-2013 01:02 PM - edited 10-27-2013 01:02 PM
Sorry, I was posting by phone earlier. Here's what you can do.
(If the arrays are large, you need to convert to I32 before summing)
10-27-2013 01:25 PM
dears
thank you to all
all answers amazing but i will consider the last post as solution
kudos for all
10-27-2013 01:45 PM - edited 10-27-2013 01:47 PM
just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.
10-27-2013 11:34 PM
just FYI neos, this is a much simpler way to count the number of true booleans in an array:
Yes Greg, for number of trues and numbers of false also ( if total array size - number of true ), i would not have thought of it myself for the first time. thanks.
Christian,
Now i think i am learning LabVIEW. I am thinking RUBE and you are getting it.
10-28-2013 10:29 AM - edited 10-28-2013 10:30 AM
@alexderjuengere wrote:
just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.
Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:
10-28-2013 10:44 AM
@alexderjuengere wrote:
just for fun, here's a numeric approach. the u8 arrays are limited to 0 and 1.
There are other serious limitations, for example if the count is more that 256, you're in trouble. 😄
@for(imstuck) wrote:
Alex, I think the idea was a binary representation, not a decimal array of 1's or zeros:
For the more general case of large packed binary arrays (e.g. 8 booleans/U8), my code can be re-used almost unchanged, except for the summation which would use a U8 lookup table to get the bit count per byte and sum those up.