New version of gexpmq_mex.cpp