support varargin
use the same rand for py and m
equal results with m and py solvers