Added function for calculating the Q-matrix.