Using 0-based indices for matrix.