changed all numpy arrays to matrices for clearer matrix multiplication