pushed linear sys generalization into mex, tested running/balancing successfully