I have 2 numpy arrays: b
and s
. And len(b)==2*len(s)
.
s
has the form:
l r l r l r ...
I what to transform it into:
0 0 l r 0 0 l r 0 0 l r ...
I'm doing it the easy way:
ix = 0
jx = 0
while ix < len(b):
b[ix] = 0
ix += 1
b[ix] = 0
ix += 1
b[ix] = s[jx]
ix += 1
jx += 1
b[ix] = s[jx]
ix += 1
jx += 1
For speed, I'd like to do the same using numpy api but can't get something working.
What numpy methods should I be using?