Numarray and bitwise shifting

Fabrizio facelle at libero.it
Thu Nov 7 14:51:49 EST 2002


Hi,

Is there a way to perform bitwise shifting in a Numarray array ?

E.g. ; I have an array defined like this :

a = numarray.array([[1,0,0,1], [1,1,1,0]], type ='Bool')
print a

[[1,0,0,1]
[1,1,1,0]]

and I want to rightshift it by one position; that it, tranform it into :

[[0,1,0,0]
[1,1,1,1]]



I have tried the following three ways:

1-
a = numarray.rshift(a,1)

2-
a = a >> 1

3-
a = operator.rshift(a,1)

but they all lead to the same result which is not what I expected.


TIA


Fabrizio








More information about the Python-list mailing list