[Numpy-discussion] The mu.py script will keep running and never end.

Evgeni Burovski evgeny.burovskiy at gmail.com
Sun Oct 11 08:42:03 EDT 2020


вс, 11 окт. 2020 г., 13:31 Hongyi Zhao <hongyi.zhao at gmail.com>:

> On Sun, Oct 11, 2020 at 3:42 PM Evgeni Burovski
> <evgeny.burovskiy at gmail.com> wrote:
> >
> > On Sun, Oct 11, 2020 at 9:55 AM Evgeni Burovski
> > <evgeny.burovskiy at gmail.com> wrote:
> > >
> > > The script seems to be computing the particle numbers for an array of
> chemical potentials.
> > >
> > > Two ways of speeding it up, both are likely simpler then using dask:
> > >
> > > First: use numpy
> > >
> > > 1. Move constructing mu_all out of the loop (np.linspace)
> > > 2. Arrange the integrands into a 2d array
> > > 3. np.trapz along an axis which corresponds to a single integrand array
> > > (Or avoid the overhead of trapz by just implementing the trapezoid
> formula manually)
> >
> >
> > Roughly like this:
> > https://gist.github.com/ev-br/0250e4eee461670cf489515ee427eb99
>
> I can't find the cython part suggested by you, i.e., move the loop
> into cython. Furthermore, I also learned that the numpy array is
> optimized and has the performance close to C/C++.
>
>
> Basically, it seems pure numpy is OK here and nothing  more sophisticated
> is needed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20201011/23035034/attachment.html>


More information about the NumPy-Discussion mailing list