Least-squares fitting without inv