def _bem_inf_pots(mri_rr, bem_rr, mri_Q=None):
 diff = (bem_rr.T[np.newaxis, :, :] - mri_rr[:, :, np.newaxis])
 diff_norm = np.sum((diff * diff), axis=1)
 diff_norm *= np.sqrt(diff_norm)
 diff_norm[(diff_norm == 0)] = 1
 if (mri_Q is None):
  return (diff / diff_norm[:, np.newaxis, :])
 else:
  return (np.einsum('ijk,mj->imk', diff, mri_Q) / diff_norm[:, np.newaxis, :])

def _bem_inf_pots ( mri_rr , bem_rr , mri_Q = None ) : diff = ( bem_rr . T [ np . newaxis , : , : ] - mri_rr [ : , : , np . newaxis ] ) diff_norm = np . sum ( ( diff * diff ) , axis = 1 ) diff_norm *= np . sqrt ( diff_norm ) diff_norm [ ( diff_norm == 0 ) ] = 1 if ( mri_Q is None ) : return ( diff / diff_norm [ : , np . newaxis , : ] ) else : return ( np . einsum ( 'ijk,mj->imk' , diff , mri_Q ) / diff_norm [ : , np . newaxis , : ] )
compute the infinite medium potential in all 3 directions .