initial mex implementation for real 1d