def _comp_sum_eeg(beta, ctheta, lut_fun, n_fact):
 n_chunk = (50000000 // ((8 * max(n_fact.shape)) * 2))
 lims = np.concatenate([np.arange(0, beta.size, n_chunk), [beta.size]])
 s0 = np.empty(beta.shape)
 for (start, stop) in zip(lims[:(-1)], lims[1:]):
  coeffs = lut_fun(ctheta[start:stop])
  betans = np.tile(beta[start:stop][:, np.newaxis], (1, n_fact.shape[0]))
  np.cumprod(betans, axis=1, out=betans)
  coeffs *= betans
  s0[start:stop] = np.dot(coeffs, n_fact)
 return s0

def _comp_sum_eeg ( beta , ctheta , lut_fun , n_fact ) : n_chunk = ( 50000000 // ( ( 8 * max ( n_fact . shape ) ) * 2 ) ) lims = np . concatenate ( [ np . arange ( 0 , beta . size , n_chunk ) , [ beta . size ] ] ) s0 = np . empty ( beta . shape ) for ( start , stop ) in zip ( lims [ : ( - 1 ) ] , lims [ 1 : ] ) : coeffs = lut_fun ( ctheta [ start : stop ] ) betans = np . tile ( beta [ start : stop ] [ : , np . newaxis ] , ( 1 , n_fact . shape [ 0 ] ) ) np . cumprod ( betans , axis = 1 , out = betans ) coeffs *= betans s0 [ start : stop ] = np . dot ( coeffs , n_fact ) return s0
lead field dot products using legendre polynomial series .