def _magnetic_dipole_objective(x, B, B2, coils, scale, method):
 if (method == 'forward'):
  fwd = _magnetic_dipole_field_vec(x[np.newaxis, :], coils)
 else:
  from .preprocessing.maxwell import _sss_basis
  fwd = _sss_basis(dict(origin=x, int_order=1, ext_order=0), coils).T
 fwd = np.dot(fwd, scale.T)
 one = np.dot(linalg.svd(fwd, full_matrices=False)[2][:3], B)
 one *= one
 Bm2 = one.sum()
 return (B2 - Bm2)

def _magnetic_dipole_objective ( x , B , B2 , coils , scale , method ) : if ( method == 'forward' ) : fwd = _magnetic_dipole_field_vec ( x [ np . newaxis , : ] , coils ) else : from . preprocessing . maxwell import _sss_basis fwd = _sss_basis ( dict ( origin = x , int_order = 1 , ext_order = 0 ) , coils ) . T fwd = np . dot ( fwd , scale . T ) one = np . dot ( linalg . svd ( fwd , full_matrices = False ) [ 2 ] [ : 3 ] , B ) one *= one Bm2 = one . sum ( ) return ( B2 - Bm2 )
project data onto right eigenvectors of whitened forward .