[Numpy-discussion] Optical autocorrelation calculated with numpy is slow
Charles R Harris
Mon Mar 30 13:39:47 CDT 2009
On Mon, Mar 30, 2009 at 12:23 PM, Anne Archibald
> 2009/3/30 João Luís Silva <email@example.com>:
> > Hi,
> > I wrote a script to calculate the *optical* autocorrelation of an
> > electric field. It's like the autocorrelation, but sums the fields
> > instead of multiplying them. I'm calculating
> > I(tau) = integral( abs(E(t)+E(t-tau))**2,t=-inf..inf)
> You may be in trouble if there's cancellation, but can't you just
> rewrite this as E(t)**2+E(t-tau)**2-2*E(t)*E(t-tau)? Then you have two
> O(n) integrals and one standard autocorrelation...
That should work. The first two integrals are actually the same, but need to
be E(t)*E(t).conj(). The second integral needs twice the real part of
E(t)*E(t-tau).conj(). Numpy correlate should really have the conjugate built
in, but it doesn't.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion