compile MATRIX