Pass a scratch array to the weighted least squares calculation

To cut down on the allocate/free activity and the copying.