I got a matrix A, with the following bytes as rows:
11111110  (0xfe)
11111000  (0xf8)
10000100  (0x84)
10010010  (0x92)
My program reads a byte from stdin with the function sys.stdin.read(1). Suppose I receive the byte x 10101010 (0xaa). Is there a way using numpy to perform the multiplication:
>>> A.dot(x)
0x06 (00000110)
As A is a 4x8 matrix, compossed by 4 bytes as rows, and x is an 8 bit array, I was expecting to receive the (nibble 0110) byte 0000 0110 as a result of the multiplication A * x, treating bits as elements of the matrix. 
If the elements of the matrix were treated as binary bytes, the result would be:
>>> A = np.array([[1,1,1,1,1,1,1,0],[1,1,1,1,1,0,0,0],[1,0,0,0,0,1,0,0],[1,0,0,1,0,0,1,0]])
>>> x = np.array([1,0,1,0,1,0,1,0])
>>> A.dot(x)%2
array([0, 1, 1, 0])
 
    