fix a bug when using column major matrix