add least squares for AMatrix in API