Be careful about sortMatrix(). It must be called rightly after building the matrix.
Debugging BCG() in Matrix.h