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 init()
28 The init method initializes a new instance of INTERP. It needs as input
29 an interpolation type and two piddles holding the x and y values to be
30 interpolated. The GSL routines require that x be monotonically
31 increasing and a quicksort is performed by default to ensure that. You
32 can skip the quicksort by passing the option {Sort => 0}.
33
34 The available interpolation types are :
35
36 · linear
37
38 · polynomial
39
40 · cspline (natural cubic spline)
41
42 · cspline_periodic (periodic cubic spline)
43
44 · akima (natural akima spline)
45
46 · akima_periodic (periodic akima spline)
47
48 Please check the GSL documentation for more information.
49
50 Usage:
51
52 $blessed_ref = PDL::GSL::INTERP->init($interp_method,$x,$y,$opt);
53
54 Example:
55
56 $x = sequence(10);
57 $y = exp($x);
58
59 $spl = PDL::GSL::INTERP->init('cspline',$x,$y)
60 $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 1}) #same as above
61
62 # no sorting done on x, user is certain that x is monotonically increasing
63 $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 0});
64
65 eval()
66 The function eval returns the interpolating function at a given point.
67 By default it will barf if you try to extrapolate, to comply silently
68 if the point to be evaluated is out of range pass the option
69 {Extrapolate => 1}
70
71 Usage:
72
73 $result = $spl->eval($points,$opt);
74
75 Example:
76
77 my $res = $spl->eval($x)
78 $res = $spl->eval($x,{Extrapolate => 0}) #same as above
79
80 # silently comply if $x is out of range
81 $res = $spl->eval($x,{Extrapolate => 1})
82
83 deriv()
84 The deriv function returns the derivative of the interpolating function
85 at a given point. By default it will barf if you try to extrapolate, to
86 comply silently if the point to be evaluated is out of range pass the
87 option {Extrapolate => 1}
88
89 Usage:
90
91 $result = $spl->deriv($points,$opt);
92
93 Example:
94
95 my $res = $spl->deriv($x)
96 $res = $spl->deriv($x,{Extrapolate => 0}) #same as above
97
98 # silently comply if $x is out of range
99 $res = $spl->deriv($x,{Extrapolate => 1})
100
101 deriv2()
102 The deriv2 function returns the second derivative of the interpolating
103 function at a given point. By default it will barf if you try to
104 extrapolate, to comply silently if the point to be evaluated is out of
105 range pass the option {Extrapolate => 1}
106
107 Usage:
108
109 $result = $spl->deriv2($points,$opt);
110
111 Example:
112
113 my $res = $spl->deriv2($x)
114 $res = $spl->deriv2($x,{Extrapolate => 0}) #same as above
115
116 # silently comply if $x is out of range
117 $res = $spl->deriv2($x,{Extrapolate => 1})
118
119 integ()
120 The integ function returns the integral of the interpolating function
121 between two points. By default it will barf if you try to extrapolate,
122 to comply silently if one of the integration limits is out of range
123 pass the option {Extrapolate => 1}
124
125 Usage:
126
127 $result = $spl->integ($a,$b,$opt);
128
129 Example:
130
131 my $res = $spl->integ($a,$b)
132 $res = $spl->integ($a,$b,{Extrapolate => 0}) #same as above
133
134 # silently comply if $a or $b are out of range
135 $res = $spl->eval($a,$b,{Extrapolate => 1})
136
138 Feedback is welcome.
139
141 PDL
142
143 The GSL documentation is online at
144
145 http://sources.redhat.com/gsl/ref/gsl-ref_toc.html
146
148 This file copyright (C) 2003 Andres Jordan
149 <andresj@physics.rutgers.edu> All rights reserved. There is no
150 warranty. You are allowed to redistribute this software/documentation
151 under certain conditions. For details, see the file COPYING in the PDL
152 distribution. If this file is separated from the PDL distribution, the
153 copyright notice should be included in the file.
154
155 The GSL interpolation module was written by Gerard Jungman.
156
157
158
159perl v5.12.3 2011-03-31 INTERP(3)