/usr/lib/perl5/PDL/GSL/DIFF.pm is in pdl 1:2.007-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | #
# GENERATED WITH PDL::PP! Don't modify!
#
package PDL::GSL::DIFF;
@EXPORT_OK = qw( gsldiff PDL::PP diff_central PDL::PP diff_backward PDL::PP diff_forward );
%EXPORT_TAGS = (Func=>[@EXPORT_OK]);
use PDL::Core;
use PDL::Exporter;
use DynaLoader;
@ISA = ( 'PDL::Exporter','DynaLoader' );
push @PDL::Core::PP, __PACKAGE__;
bootstrap PDL::GSL::DIFF ;
=head1 NAME
PDL::GSL::DIFF - PDL interface to numerical differentiation routines in GSL
=head1 DESCRIPTION
This is an interface to the numerical differentiation package present in the
GNU Scientific Library.
=head1 SYNOPSIS
use PDL;
use PDL::GSL::DIFF;
my $x0 = 3.3;
my @res = gsldiff(\&myfunction,$x0);
# same as above:
@res = gsldiff(\&myfunction,$x0,{Method => 'central'});
# use only values greater than $x0 to get the derivative
@res = gsldiff(\&myfunction,$x0,{Method => 'forward'});
# use only values smaller than $x0 to get the derivative
@res = gsldiff(\&myfunction,$x0,{Method => 'backward'});
sub myfunction{
my ($x) = @_;
return $x**2;
}
=head1 FUNCTIONS
=head2 gsldiff()
=for ref
This functions serves as an interface to the three differentiation
functions present in GSL: gsl_diff_central, gsl_diff_backward and
gsl_diff_forward. To compute the derivative, the central method uses
values greater and smaller than the point at which the derivative is
to be evaluated, while backward and forward use only values smaller
and greater respectively. gsldiff() returns both the derivative
and an absolute error estimate. The default method is 'central',
others can be specified by passing an option.
Please check the GSL documentation for more information.
=for usage
Usage:
($d,$abserr) = gsldiff($function_ref,$x,{Method => $method});
=for example
Example:
#derivative using default method ('central')
($d,$abserr) = gsldiff(\&myf,3.3);
#same as above with method set explicitly
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'central'});
#using backward & forward methods
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'backward'});
($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'forward'});
sub myf{
my ($x) = @_;
return exp($x);
}
=head1 BUGS
Feedback is welcome. Log bugs in the PDL bug database (the
database is always linked from L<http://pdl.perl.org>).
=head1 SEE ALSO
L<PDL>
The GSL documentation is online at
http://www.gnu.org/software/gsl/manual/
=head1 AUTHOR
This file copyright (C) 2003 Andres Jordan <andresj@physics.rutgers.edu>
All rights reserved. There is no warranty. You are allowed to redistribute
this software documentation under certain conditions. For details, see the file
COPYING in the PDL distribution. If this file is separated from the
PDL distribution, the copyright notice should be included in the file.
The GSL differentiation routines were written by David Morrison.
=cut
=head1 FUNCTIONS
=cut
sub gsldiff{
my $opt;
if (ref($_[$#_]) eq 'HASH'){ $opt = pop @_; }
else{ $opt = {Method => 'central'}; }
die 'Usage: gsldiff(function_ref, x, {Options} )'
if $#_<1 || $#_>2;
my ($f,$x) = @_;
my ($res,$abserr);
if($$opt{Method}=~/cent/i){
($res,$abserr) = PDL::GSL::DIFF::diff_central($x,$f);
}
elsif($$opt{Method}=~/back/i){
($res,$abserr) = PDL::GSL::DIFF::diff_backward($x,$f);
}
elsif($$opt{Method}=~/forw/i){
($res,$abserr) = PDL::GSL::DIFF::diff_forward($x,$f);
}
else{
barf("Unknown differentiation method $method in gsldiff\n");
}
return ($res,$abserr);
}
=head2 diff_central
=for sig
Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
=for ref
info not available
=for bad
diff_central does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*diff_central = \&PDL::diff_central;
=head2 diff_backward
=for sig
Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
=for ref
info not available
=for bad
diff_backward does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*diff_backward = \&PDL::diff_backward;
=head2 diff_forward
=for sig
Signature: (double x(); double [o] res(); double [o] abserr(); SV* funcion)
=for ref
info not available
=for bad
diff_forward does not process bad values.
It will set the bad-value flag of all output piddles if the flag is set for any of the input piddles.
=cut
*diff_forward = \&PDL::diff_forward;
;
# Exit with OK status
1;
|