def _fit_eval(rd, B, B2, fwd_svd=None, fwd_data=None, whitener=None):
 if (fwd_svd is None):
  fwd = _dipole_forwards(fwd_data, whitener, rd[np.newaxis, :])[0]
  (uu, sing, vv) = linalg.svd(fwd, overwrite_a=True, full_matrices=False)
 else:
  (uu, sing, vv) = fwd_svd
 gof = _dipole_gof(uu, sing, vv, B, B2)[0]
 return (1.0 - gof)

def _fit_eval ( rd , B , B2 , fwd_svd = None , fwd_data = None , whitener = None ) : if ( fwd_svd is None ) : fwd = _dipole_forwards ( fwd_data , whitener , rd [ np . newaxis , : ] ) [ 0 ] ( uu , sing , vv ) = linalg . svd ( fwd , overwrite_a = True , full_matrices = False ) else : ( uu , sing , vv ) = fwd_svd gof = _dipole_gof ( uu , sing , vv , B , B2 ) [ 0 ] return ( 1.0 - gof )
calculate the residual sum of squares .