1DIFF(3) User Contributed Perl Documentation DIFF(3)
2
3
4
6 PDL::GSL::DIFF - PDL interface to numerical differentiation routines in
7 GSL
8
10 This is an interface to the numerical differentiation package present
11 in the GNU Scientific Library.
12
14 use PDL;
15 use PDL::GSL::DIFF;
16
17 my $x0 = 3.3;
18
19 my @res = gsldiff(\&myfunction,$x0);
20 # same as above:
21 @res = gsldiff(\&myfunction,$x0,{Method => 'central'});
22
23 # use only values greater than $x0 to get the derivative
24 @res = gsldiff(\&myfunction,$x0,{Method => 'forward'});
25
26 # use only values smaller than $x0 to get the derivative
27 @res = gsldiff(\&myfunction,$x0,{Method => 'backward'});
28
29 sub myfunction{
30 my ($x) = @_;
31 return $x**2;
32 }
33 #line 61 "DIFF.pm"
34
36 diff_central
37 Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)
38
39 info not available
40
41 diff_central does not process bad values. It will set the bad-value
42 flag of all output ndarrays if the flag is set for any of the input
43 ndarrays.
44
45 diff_backward
46 Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)
47
48 info not available
49
50 diff_backward does not process bad values. It will set the bad-value
51 flag of all output ndarrays if the flag is set for any of the input
52 ndarrays.
53
54 diff_forward
55 Signature: (double x(); double [o] res(); double [o] abserr(); SV* function)
56
57 info not available
58
59 diff_forward does not process bad values. It will set the bad-value
60 flag of all output ndarrays if the flag is set for any of the input
61 ndarrays.
62
63 gsldiff
64 This functions serves as an interface to the three differentiation
65 functions present in GSL: gsl_diff_central, gsl_diff_backward and
66 gsl_diff_forward. To compute the derivative, the central method uses
67 values greater and smaller than the point at which the derivative is to
68 be evaluated, while backward and forward use only values smaller and
69 greater respectively. gsldiff() returns both the derivative and an
70 absolute error estimate. The default method is 'central', others can
71 be specified by passing an option.
72
73 Please check the GSL documentation for more information.
74
75 Usage:
76
77 ($d,$abserr) = gsldiff($function_ref,$x,{Method => $method});
78
79 Example:
80
81 #derivative using default method ('central')
82 ($d,$abserr) = gsldiff(\&myf,3.3);
83
84 #same as above with method set explicitly
85 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'central'});
86
87 #using backward & forward methods
88 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'backward'});
89 ($d,$abserr) = gsldiff(\&myf,3.3,{Method => 'forward'});
90
91 sub myf{
92 my ($x) = @_;
93 return exp($x);
94 }
95
97 Feedback is welcome. Log bugs in the PDL bug database (the database is
98 always linked from <http://pdl.perl.org>).
99
101 PDL
102
103 The GSL documentation is online at
104
105 http://www.gnu.org/software/gsl/manual/
106
108 This file copyright (C) 2003 Andres Jordan
109 <andresj@physics.rutgers.edu> All rights reserved. There is no
110 warranty. You are allowed to redistribute this software documentation
111 under certain conditions. For details, see the file COPYING in the PDL
112 distribution. If this file is separated from the PDL distribution, the
113 copyright notice should be included in the file.
114
115 The GSL differentiation routines were written by David Morrison.
116
117
118
119perl v5.34.0 2022-02-28 DIFF(3)