I need to expand a bit sequence packed in UInt32 words, into a vector that is eventually complex floating point (with the sequence elements represented by \pm 1 in the real part).
Currently I’m doing something like the following, for an example with a length-51 sequence stored in two words,
bstr = bits(w1) * bits(w2); bcod = zeros(Complex64, 51); for i in 1:51 bcod[i] = 2.0f0*(49.0f0 - Float32(Cchar(bstr[i]))) - 1.0f0; end
This works but seems kludgy and inefficient. Is there a way to expand the sequence to Int or Float values without going through the intermediate string representation, or bit-shifting and -anding in a loop?