Hi Ed,

I've added https://github.com/PDLPorters/pdl/issues/518 to hold comments on
benchmarking PDL. I'll take a run at it when the weather gets warmer (it's
still cold in the PC room 8-} ), but I've linked to my previous experience
in case anyone else wants to have a go.
But be warned - benchmarking tickles the obsessive part of your brain
something fierce.

cheers,
Boyd

On Tue, 7 Jan 2025 at 20:16, Ed . <ej...@hotmail.com> wrote:

> Hi Luis and all,
>
> Two points:
>
>    - I've been looking at how Julia does loop fusion, in order to steal
>    ideas; these are now starting to form more concretely, which I think is
>    good! But I also looked up how it does on performance, and learned of a
>    thread where they discussed a benchmark:
>    https://discourse.julialang.org/t/programming-language-benchmark-2/108429 -
>    I'd like us to have a benchmark in that for PDL, does anyone feel like
>    having a go? Boyd?
>    - I've now added a Ufunc::diffcentred (based on Luis's rotate algorithm),
>    and Ufunc::partial; the latter adjusts Luis's work to take an ndarray as
>    first param so it can be a method, and takes instruction on which method to
>    use (centred (default), forward, backward). I'm about to add a PCHIP option
>    too, currently only using
>    https://metacpan.org/pod/PDL::Primitive#pchip_chim, but it would be
>    possible to use pchip_chic which offers more control of boundary
>    conditions. Feedback welcome.
>
> Best regards,
> Ed
>
> ------------------------------
> *From:* Luis Mochan <moc...@icf.unam.mx>
> *Sent:* 21 November 2024 15:55
> *To:* Ed . <ej...@hotmail.com>
> *Cc:* Boyd Duffee <boyd.duf...@gmail.com>; pdl-devel <
> pdl-devel@lists.sourceforge.net>; perldl <
> pdl-gene...@lists.sourceforge.net>
> *Subject:* Re: [Pdl-devel] curl of vector
>
> On Thu, Nov 21, 2024 at 03:09:37PM +0000, Ed . wrote:
> > Hi Luis,
> >
> > Thank you for both the code and the explanation! I was aware of the
> limitations of diffover for this (including its name - just "diff" caused
> clashes with Text::Diff in a downstream module). I'm proposing to rename
> "diffover" to "numdiff" (for numerical differentiation) in the next version
> of PDL, any objections?
>
> However, it just takes the differences between consecutive values. I
> would call it firstdiff, as there are also second, third,
> etc. diffs. These are analogous, but not equal, to the corresponding
> (first, second, etc.) derivatives one find in calculus, and may be
> used to build approximate derivatives, as in the examples.
>
> > I considered using diff2 in my quickly-written prototype, but chose
> > diffover so as not to shrink the dim by 1.
>
> There are other PDL methods that allow the user to specify what to do
> with the boundaries. Maybe the same should be done here. In my
> solution the boundary could be kept if the function is periodic, but
> otherwise, it should be thrown away. Another alternative is to add
> values beyond the boundary: repeating the boundary value would
> correspond to a 0 value for the derivative at the boundary. One could
> also add f_{n+1}=2f_{n}-f_{n-1}, which would correspond to a null
> curvature at the boundary. Or the easiest, which is to trim down the
> derivative at the boundary by droping the last element for forward
> differences, the first for backward differences and both for centered
> differences.
>
> > I am also keen to capture the 3 functions you've made, probably with
> > "partial" going into Ufunc, and gaining an options param that has
> > "difference" of either "forward", "backward", or "centred", or
> > "shrink" using diff2. "div" and "curl" would then "just" be examples
> > in the docs. Does anyone see any difficulties with this? Boyd, I don't
> > feel this would clash with an Advent posting in any important way, but
> > I'm very pleased to hear your thoughts if you disagree :-)
>
> Would be useful.
>
> Notice that I assumed the function was defined on a regular grid. If
> not, more elaborate schemes would be needed to estimate the centered
> derivative.
>
> Another alternative for finding derivative, which may be useful in
> some cases, is to make a Fourier transform of the data, multiply it by
> i()*(wavevector) and then transform back.
>
> Best regards,
> Luis
>
>
> >
> > Best regards,
> > Ed
> >
>
>
> --
>
>                                                                   o
> W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> Av. Universidad s/n CP 62210         |                           (*)/\/  \
> Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
> GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
>
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to