function k = ij2k(i,j,m)
k = (i-1)*m + j; 