def _comp_sums_meg(beta, ctheta, lut_fun, n_fact, volume_integral):
 sums = np.empty((n_fact.shape[1], len(beta)))
 n_chunk = (50000000 // ((8 * max(n_fact.shape)) * 2))
 lims = np.concatenate([np.arange(0, beta.size, n_chunk), [beta.size]])
 for (start, stop) in zip(lims[:(-1)], lims[1:]):
  bbeta = np.tile(beta[start:stop][np.newaxis], (n_fact.shape[0], 1))
  bbeta[0] *= beta[start:stop]
  np.cumprod(bbeta, axis=0, out=bbeta)
  np.einsum('ji,jk,ijk->ki', bbeta, n_fact, lut_fun(ctheta[start:stop]), out=sums[:, start:stop])
 return sums

def _comp_sums_meg ( beta , ctheta , lut_fun , n_fact , volume_integral ) : sums = np . empty ( ( n_fact . shape [ 1 ] , len ( beta ) ) ) n_chunk = ( 50000000 // ( ( 8 * max ( n_fact . shape ) ) * 2 ) ) lims = np . concatenate ( [ np . arange ( 0 , beta . size , n_chunk ) , [ beta . size ] ] ) for ( start , stop ) in zip ( lims [ : ( - 1 ) ] , lims [ 1 : ] ) : bbeta = np . tile ( beta [ start : stop ] [ np . newaxis ] , ( n_fact . shape [ 0 ] , 1 ) ) bbeta [ 0 ] *= beta [ start : stop ] np . cumprod ( bbeta , axis = 0 , out = bbeta ) np . einsum ( 'ji,jk,ijk->ki' , bbeta , n_fact , lut_fun ( ctheta [ start : stop ] ) , out = sums [ : , start : stop ] ) return sums
lead field dot products using legendre polynomial series .