1INTERP(3) User Contributed Perl Documentation INTERP(3)
2
3
4
6 PDL::GSL::INTERP - PDL interface to Interpolation routines in GSL
7
9 This is an interface to the interpolation package present in the GNU
10 Scientific Library.
11
13 use PDL;
14 use PDL::GSL::INTERP;
15
16 my $x = sequence(10);
17 my $y = exp($x);
18
19 my $spl = PDL::GSL::INTERP->init('cspline',$x,$y);
20
21 my $res = $spl->eval(4.35);
22 $res = $spl->deriv(4.35);
23 $res = $spl->deriv2(4.35);
24 $res = $spl->integ(2.1,7.4);
25
27 Throughout this documentation we strive to use the same variables that
28 are present in the original GSL documentation (see See Also).
29 Oftentimes those variables are called "a" and "b". Since good Perl
30 coding practices discourage the use of Perl variables $a and $b, here
31 we refer to Parameters "a" and "b" as $pa and $pb, respectively, and
32 Limits (of domain or integration) as $la and $lb.
33
35 init()
36 The init method initializes a new instance of INTERP. It needs as input
37 an interpolation type and two ndarrays holding the x and y values to be
38 interpolated. The GSL routines require that x be monotonically
39 increasing and a quicksort is performed by default to ensure that. You
40 can skip the quicksort by passing the option {Sort => 0}.
41
42 The available interpolation types are :
43
44 linear
45 polynomial
46 cspline (natural cubic spline)
47 cspline_periodic (periodic cubic spline)
48 akima (natural akima spline)
49 akima_periodic (periodic akima spline)
50
51 Please check the GSL documentation for more information.
52
53 Usage:
54
55 $blessed_ref = PDL::GSL::INTERP->init($interp_method,$x,$y,$opt);
56
57 Example:
58
59 $x = sequence(10);
60 $y = exp($x);
61
62 $spl = PDL::GSL::INTERP->init('cspline',$x,$y)
63 $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 1}) #same as above
64
65 # no sorting done on x, user is certain that x is monotonically increasing
66 $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 0});
67
68 eval()
69 The function eval returns the interpolating function at a given point.
70 It will barf with an "input domain error" if you try to extrapolate.
71
72 Usage:
73
74 $result = $spl->eval($points);
75
76 Example:
77
78 my $res = $spl->eval($x)
79
80 deriv()
81 The deriv function returns the derivative of the interpolating function
82 at a given point. It will barf with an "input domain error" if you try
83 to extrapolate.
84
85 Usage:
86
87 $result = $spl->deriv($points);
88
89 Example:
90
91 my $res = $spl->deriv($x)
92
93 deriv2()
94 The deriv2 function returns the second derivative of the interpolating
95 function at a given point. It will barf with an "input domain error"
96 if you try to extrapolate.
97
98 Usage:
99
100 $result = $spl->deriv2($points);
101
102 Example:
103
104 my $res = $spl->deriv2($x)
105
106 integ()
107 The integ function returns the integral of the interpolating function
108 between two points. It will barf with an "input domain error" if you
109 try to extrapolate.
110
111 Usage:
112
113 $result = $spl->integ($la,$lb);
114
115 Example:
116
117 my $res = $spl->integ($la,$lb)
118
120 Feedback is welcome.
121
123 PDL
124
125 The GSL documentation for interpolation is online at
126 <https://www.gnu.org/software/gsl/doc/html/interp.html>
127
129 This file copyright (C) 2003 Andres Jordan
130 <andresj@physics.rutgers.edu> All rights reserved. There is no
131 warranty. You are allowed to redistribute this software/documentation
132 under certain conditions. For details, see the file COPYING in the PDL
133 distribution. If this file is separated from the PDL distribution, the
134 copyright notice should be included in the file.
135
136 The GSL interpolation module was written by Gerard Jungman.
137
138
139
140perl v5.34.0 2021-08-16 INTERP(3)