Skip to content

Commit

Permalink
add PCHIP options to Ufunc::partial - #516
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Jan 8, 2025
1 parent 9305c42 commit 6b3e780
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/PDL/Ufunc.pd
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ pp_addpm(<<'EOF');
Take a numerical partial derivative along a given dimension, either
forward, backward, or centred.
See also L</numdiff>, L</diffcentred>, and L<PDL::Slices/mv>, which
are currently used to implement this.
See also L<PDL::Primitive/pchip_chim> and L</numdiff>.
See also L</numdiff>, L</diffcentred>,
L<PDL::Primitive/pchip_chim>, L<PDL::Primitive/pchip_chsp>,
and L<PDL::Slices/mv>, which are currently used to implement this.
Can be used to implement divergence and curl calculations (adapted
from Luis Mochán's work at
Expand Down Expand Up @@ -316,13 +316,17 @@ https://sourceforge.net/p/pdl/mailman/message/58843767/):
$pdl->partial(2, {d=>'c'}); # along dim 2, centred
$pdl->partial(2, {d=>'f'}); # along dim 2, forward
$pdl->partial(2, {d=>'b'}); # along dim 2, backward
$pdl->partial(2, {d=>'p'}); # along dim 2, piecewise cubic Hermite
$pdl->partial(2, {d=>'s'}); # along dim 2, cubic spline
=cut
my %dirtype2func = (
f => \&numdiff,
b => sub { $_[0]->slice('-1:0')->numdiff },
c => \&diffcentred,
p => sub {(PDL::Primitive::pchip_chim($_[0]->xvals, $_[0]))[0]},
s => sub {(PDL::Primitive::pchip_chsp([0,0], [0,0], $_[0]->xvals, $_[0]))[0]},
);
*partial = \&PDL::partial;
sub PDL::partial {
Expand Down

0 comments on commit 6b3e780

Please sign in to comment.