Thread: bit shifting a mask

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    4

    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. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Question 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 subscribe to a feed

Similar Threads

  1. A Question About Unit Testing
    By Tonto in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2006, 08:22 PM
  2. Bit Shifting question (simple)
    By theeld in forum C Programming
    Replies: 2
    Last Post: 10-10-2006, 02:09 PM
  3. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  4. Copy bit to bit
    By Coder2Die4 in forum C Programming
    Replies: 15
    Last Post: 06-26-2003, 09:58 AM
  5. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM