add support for new SUB_MAT and SUB_MAT2

now A[i][j] refers to the element in i-th row and j-th column.
A[x] refers to the x-th element columnwise.