1. ## bit shifting a mask

Hi

Looking for more newbie help

Could anyone give me pointers with regard to the follow text (from a real programmer!!).

>Start with mask=binary1000000000000000, n=0, n2=0 and >y=0. Have the sequency numbers in an array sequency(n).

>If you get a non zero when ANDing the mask and the sequency >(n2) then add co-efficient(n2) to y, if it's a 0 then subtract it.. Do >this for n2=0 to 16 (the number of coefficients) and y is the >current output..

>Using this method I just maintain a sample count according to >required frequency to know when to right shift the mask and >increment n - so all the summing is done when the mask >changes. And y is static until then.. When n>31 you reset the >mask and n.

The array seqeuncer(n) is my hadamard matrix:

11111111111111111111111111111111
11111111111111110000000000000000
11111111000000000000000011111111
11111111000000001111111100000000
11110000000011111111000000001111
11110000000011110000111111110000
11110000111100000000111100001111
11110000111100001111000011110000
11000011110000111100001111000011
11000011110000110011110000111100
11000011001111000011110011000011
11000011001111001100001100111100
11001100001100111100110000110011
11001100001100110011001111001100
11001100110011000011001100110011
11001100110011001100110011001100

Thanks

2. ## Uh.... What's your question?

Are you having a problem with the algorithm, or the programming details?

I can't help you with the algorithm, because I don't even know what a hadamard matrix is!

My initial approach would be to avoid the use of actual binary. I'd use a 2-dimensional array of integers (with each cell containing an integer one, or zero). With actual binary, you have to take into account the limited number of bits in an integer, and you'd need "extra" programming to handle binary I/O, etc.

There is some good information about bit-shifting in the Programming FAQ.

Popular pages Recent additions