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 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
|
# This file was automatically generated by SWIG (https://www.swig.org).
# Version 4.2.0
#
# Do not make changes to this file unless you know what you are doing - modify
# the SWIG interface file instead.
package Math::GSL::Interp;
use base qw(Exporter);
use base qw(DynaLoader);
package Math::GSL::Interpc;
bootstrap Math::GSL::Interp;
package Math::GSL::Interp;
@EXPORT = qw();
# ---------- BASE METHODS -------------
package Math::GSL::Interp;
sub TIEHASH {
my ($classname,$obj) = @_;
return bless $obj, $classname;
}
sub CLEAR { }
sub FIRSTKEY { }
sub NEXTKEY { }
sub FETCH {
my ($self,$field) = @_;
my $member_func = "swig_${field}_get";
$self->$member_func();
}
sub STORE {
my ($self,$field,$newval) = @_;
my $member_func = "swig_${field}_set";
$self->$member_func($newval);
}
sub this {
my $ptr = shift;
return tied(%$ptr);
}
# ------- FUNCTION WRAPPERS --------
package Math::GSL::Interp;
*gsl_error = *Math::GSL::Interpc::gsl_error;
*gsl_stream_printf = *Math::GSL::Interpc::gsl_stream_printf;
*gsl_strerror = *Math::GSL::Interpc::gsl_strerror;
*gsl_set_error_handler = *Math::GSL::Interpc::gsl_set_error_handler;
*gsl_set_error_handler_off = *Math::GSL::Interpc::gsl_set_error_handler_off;
*gsl_set_stream_handler = *Math::GSL::Interpc::gsl_set_stream_handler;
*gsl_set_stream = *Math::GSL::Interpc::gsl_set_stream;
*gsl_interp_accel_alloc = *Math::GSL::Interpc::gsl_interp_accel_alloc;
*gsl_interp_accel_reset = *Math::GSL::Interpc::gsl_interp_accel_reset;
*gsl_interp_accel_free = *Math::GSL::Interpc::gsl_interp_accel_free;
*gsl_interp_alloc = *Math::GSL::Interpc::gsl_interp_alloc;
*gsl_interp_init = *Math::GSL::Interpc::gsl_interp_init;
*gsl_interp_name = *Math::GSL::Interpc::gsl_interp_name;
*gsl_interp_min_size = *Math::GSL::Interpc::gsl_interp_min_size;
*gsl_interp_type_min_size = *Math::GSL::Interpc::gsl_interp_type_min_size;
*gsl_interp_eval_e = *Math::GSL::Interpc::gsl_interp_eval_e;
*gsl_interp_eval = *Math::GSL::Interpc::gsl_interp_eval;
*gsl_interp_eval_deriv_e = *Math::GSL::Interpc::gsl_interp_eval_deriv_e;
*gsl_interp_eval_deriv = *Math::GSL::Interpc::gsl_interp_eval_deriv;
*gsl_interp_eval_deriv2_e = *Math::GSL::Interpc::gsl_interp_eval_deriv2_e;
*gsl_interp_eval_deriv2 = *Math::GSL::Interpc::gsl_interp_eval_deriv2;
*gsl_interp_eval_integ_e = *Math::GSL::Interpc::gsl_interp_eval_integ_e;
*gsl_interp_eval_integ = *Math::GSL::Interpc::gsl_interp_eval_integ;
*gsl_interp_free = *Math::GSL::Interpc::gsl_interp_free;
*gsl_interp_bsearch = *Math::GSL::Interpc::gsl_interp_bsearch;
*gsl_interp_accel_find = *Math::GSL::Interpc::gsl_interp_accel_find;
############# Class : Math::GSL::Interp::gsl_interp_accel ##############
package Math::GSL::Interp::gsl_interp_accel;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::Interp );
%OWNER = ();
%ITERATORS = ();
*swig_cache_get = *Math::GSL::Interpc::gsl_interp_accel_cache_get;
*swig_cache_set = *Math::GSL::Interpc::gsl_interp_accel_cache_set;
*swig_miss_count_get = *Math::GSL::Interpc::gsl_interp_accel_miss_count_get;
*swig_miss_count_set = *Math::GSL::Interpc::gsl_interp_accel_miss_count_set;
*swig_hit_count_get = *Math::GSL::Interpc::gsl_interp_accel_hit_count_get;
*swig_hit_count_set = *Math::GSL::Interpc::gsl_interp_accel_hit_count_set;
sub new {
my $pkg = shift;
my $self = Math::GSL::Interpc::new_gsl_interp_accel(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
Math::GSL::Interpc::delete_gsl_interp_accel($self);
delete $OWNER{$self};
}
}
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
############# Class : Math::GSL::Interp::gsl_interp ##############
package Math::GSL::Interp::gsl_interp;
use vars qw(@ISA %OWNER %ITERATORS %BLESSEDMEMBERS);
@ISA = qw( Math::GSL::Interp );
%OWNER = ();
%ITERATORS = ();
*swig_type_get = *Math::GSL::Interpc::gsl_interp_type_get;
*swig_type_set = *Math::GSL::Interpc::gsl_interp_type_set;
*swig_xmin_get = *Math::GSL::Interpc::gsl_interp_xmin_get;
*swig_xmin_set = *Math::GSL::Interpc::gsl_interp_xmin_set;
*swig_xmax_get = *Math::GSL::Interpc::gsl_interp_xmax_get;
*swig_xmax_set = *Math::GSL::Interpc::gsl_interp_xmax_set;
*swig_size_get = *Math::GSL::Interpc::gsl_interp_size_get;
*swig_size_set = *Math::GSL::Interpc::gsl_interp_size_set;
*swig_state_get = *Math::GSL::Interpc::gsl_interp_state_get;
*swig_state_set = *Math::GSL::Interpc::gsl_interp_state_set;
sub new {
my $pkg = shift;
my $self = Math::GSL::Interpc::new_gsl_interp(@_);
bless $self, $pkg if defined($self);
}
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
Math::GSL::Interpc::delete_gsl_interp($self);
delete $OWNER{$self};
}
}
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
delete $OWNER{$ptr};
}
sub ACQUIRE {
my $self = shift;
my $ptr = tied(%$self);
$OWNER{$ptr} = 1;
}
# ------- VARIABLE STUBS --------
package Math::GSL::Interp;
*GSL_VERSION = *Math::GSL::Interpc::GSL_VERSION;
*GSL_MAJOR_VERSION = *Math::GSL::Interpc::GSL_MAJOR_VERSION;
*GSL_MINOR_VERSION = *Math::GSL::Interpc::GSL_MINOR_VERSION;
*GSL_POSZERO = *Math::GSL::Interpc::GSL_POSZERO;
*GSL_NEGZERO = *Math::GSL::Interpc::GSL_NEGZERO;
*GSL_SUCCESS = *Math::GSL::Interpc::GSL_SUCCESS;
*GSL_FAILURE = *Math::GSL::Interpc::GSL_FAILURE;
*GSL_CONTINUE = *Math::GSL::Interpc::GSL_CONTINUE;
*GSL_EDOM = *Math::GSL::Interpc::GSL_EDOM;
*GSL_ERANGE = *Math::GSL::Interpc::GSL_ERANGE;
*GSL_EFAULT = *Math::GSL::Interpc::GSL_EFAULT;
*GSL_EINVAL = *Math::GSL::Interpc::GSL_EINVAL;
*GSL_EFAILED = *Math::GSL::Interpc::GSL_EFAILED;
*GSL_EFACTOR = *Math::GSL::Interpc::GSL_EFACTOR;
*GSL_ESANITY = *Math::GSL::Interpc::GSL_ESANITY;
*GSL_ENOMEM = *Math::GSL::Interpc::GSL_ENOMEM;
*GSL_EBADFUNC = *Math::GSL::Interpc::GSL_EBADFUNC;
*GSL_ERUNAWAY = *Math::GSL::Interpc::GSL_ERUNAWAY;
*GSL_EMAXITER = *Math::GSL::Interpc::GSL_EMAXITER;
*GSL_EZERODIV = *Math::GSL::Interpc::GSL_EZERODIV;
*GSL_EBADTOL = *Math::GSL::Interpc::GSL_EBADTOL;
*GSL_ETOL = *Math::GSL::Interpc::GSL_ETOL;
*GSL_EUNDRFLW = *Math::GSL::Interpc::GSL_EUNDRFLW;
*GSL_EOVRFLW = *Math::GSL::Interpc::GSL_EOVRFLW;
*GSL_ELOSS = *Math::GSL::Interpc::GSL_ELOSS;
*GSL_EROUND = *Math::GSL::Interpc::GSL_EROUND;
*GSL_EBADLEN = *Math::GSL::Interpc::GSL_EBADLEN;
*GSL_ENOTSQR = *Math::GSL::Interpc::GSL_ENOTSQR;
*GSL_ESING = *Math::GSL::Interpc::GSL_ESING;
*GSL_EDIVERGE = *Math::GSL::Interpc::GSL_EDIVERGE;
*GSL_EUNSUP = *Math::GSL::Interpc::GSL_EUNSUP;
*GSL_EUNIMPL = *Math::GSL::Interpc::GSL_EUNIMPL;
*GSL_ECACHE = *Math::GSL::Interpc::GSL_ECACHE;
*GSL_ETABLE = *Math::GSL::Interpc::GSL_ETABLE;
*GSL_ENOPROG = *Math::GSL::Interpc::GSL_ENOPROG;
*GSL_ENOPROGJ = *Math::GSL::Interpc::GSL_ENOPROGJ;
*GSL_ETOLF = *Math::GSL::Interpc::GSL_ETOLF;
*GSL_ETOLX = *Math::GSL::Interpc::GSL_ETOLX;
*GSL_ETOLG = *Math::GSL::Interpc::GSL_ETOLG;
*GSL_EOF = *Math::GSL::Interpc::GSL_EOF;
*gsl_interp_linear = *Math::GSL::Interpc::gsl_interp_linear;
*gsl_interp_polynomial = *Math::GSL::Interpc::gsl_interp_polynomial;
*gsl_interp_cspline = *Math::GSL::Interpc::gsl_interp_cspline;
*gsl_interp_cspline_periodic = *Math::GSL::Interpc::gsl_interp_cspline_periodic;
*gsl_interp_akima = *Math::GSL::Interpc::gsl_interp_akima;
*gsl_interp_akima_periodic = *Math::GSL::Interpc::gsl_interp_akima_periodic;
@EXPORT_OK = qw/
gsl_interp_accel_alloc
gsl_interp_accel_find
gsl_interp_accel_reset
gsl_interp_accel_free
gsl_interp_alloc
gsl_interp_init
gsl_interp_name
gsl_interp_min_size
gsl_interp_eval_e
gsl_interp_eval
gsl_interp_eval_deriv_e
gsl_interp_eval_deriv
gsl_interp_eval_deriv2_e
gsl_interp_eval_deriv2
gsl_interp_eval_integ_e
gsl_interp_eval_integ
gsl_interp_free
gsl_interp_bsearch
$gsl_interp_linear
$gsl_interp_polynomial
$gsl_interp_cspline
$gsl_interp_cspline_periodic
$gsl_interp_akima
$gsl_interp_akima_periodic
/;
%EXPORT_TAGS = ( all => \@EXPORT_OK );
__END__
=encoding utf8
=head1 NAME
Math::GSL::Interp - Interpolation
=head1 SYNOPSIS
use Math::GSL::Interp qw/:all/;
my $x_array = [ 0.0, 1.0, 2.0, 3.0, 4.0 ];
# check that we get the last interval if x == last value
$index_result = gsl_interp_bsearch($x_array, 4.0, 0, 4);
print "The last interval is $index_result \n";
=head1 DESCRIPTION
=over 1
=item C<gsl_interp_accel_alloc()>
This function returns a pointer to an accelerator object, which is a kind of
iterator for interpolation lookups. It tracks the state of lookups, thus
allowing for application of various acceleration strategies.
=item C<gsl_interp_accel_find($a, $x_array, $size, $x)>
This function performs a lookup action on the data array $x_array of size
$size, using the given accelerator $a. This is how lookups are performed during
evaluation of an interpolation. The function returns an index i such that
$x_array[i] <= $x < $x_array[i+1].
=item C<gsl_interp_accel_reset>
=item C<gsl_interp_accel_free($a)>
This function frees the accelerator object $a.
=item C<gsl_interp_alloc($T, $alloc)>
This function returns a newly allocated interpolation object of type $T for
$size data-points. $T must be one of the constants below.
=item C<gsl_interp_init($interp, $xa, $ya, $size)>
This function initializes the interpolation object interp for the data (xa,ya)
where xa and ya are arrays of size size. The interpolation object (gsl_interp)
does not save the data arrays xa and ya and only stores the static state
computed from the data. The xa data array is always assumed to be strictly
ordered, with increasing x values; the behavior for other arrangements is not
defined.
=item C<gsl_interp_name($interp)>
This function returns the name of the interpolation type used by $interp.
=item C<gsl_interp_min_size($interp)>
This function returns the minimum number of points required by the
interpolation type of $interp. For example, Akima spline interpolation requires
a minimum of 5 points.
=item C<gsl_interp_eval_e($interp, $xa, $ya, $x, $acc)>
This functions returns the interpolated value of y for a given point $x, using
the interpolation object $interp, data arrays $xa and $ya and the accelerator
$acc. The function returns 0 if the operation succeeded, 1 otherwise and the y
value.
=item C<gsl_interp_eval($interp, $xa, $ya, $x, $acc)>
This functions returns the interpolated value of y for a given point $x, using
the interpolation object $interp, data arrays $xa and $ya and the accelerator
$acc.
=item C<gsl_interp_eval_deriv_e($interp, $xa, $ya, $x, $acc)>
This function computes the derivative value of y for a given point $x, using
the interpolation object $interp, data arrays $xa and $ya and the accelerator
$acc. The function returns 0 if the operation succeeded, 1 otherwise and the d
value.
=item C<gsl_interp_eval_deriv($interp, $xa, $ya, $x, $acc)>
This function returns the derivative d of an interpolated function for a given
point $x, using the interpolation object interp, data arrays $xa and $ya and
the accelerator $acc.
=item C<gsl_interp_eval_deriv2_e($interp, $xa, $ya, $x, $acc)>
This function computes the second derivative d2 of an interpolated function for
a given point $x, using the interpolation object $interp, data arrays $xa and
$ya and the accelerator $acc. The function returns 0 if the operation
succeeded, 1 otherwise and the d2 value.
=item C<gsl_interp_eval_deriv2($interp, $xa, $ya, $x, $acc)>
This function returns the second derivative d2 of an interpolated function
for a given point $x, using the interpolation object $interp, data arrays $xa
and $ya and the accelerator $acc.
=item C<gsl_interp_eval_integ_e($interp, $xa, $ya, $a, $b, $acc)>
This function computes the numerical integral result of an interpolated
function over the range [$a, $b], using the interpolation object $interp, data
arrays $xa and $ya and the accelerator $acc. The function returns 0 if the
operation succeeded, 1 otherwise and the result value.
=item C<gsl_interp_eval_integ($interp, $xa, $ya, $a, $b, $acc)>
This function returns the numerical integral result of an interpolated function
over the range [$a, $b], using the interpolation object $interp, data arrays
$xa and $ya and the accelerator $acc.
=item C<gsl_interp_free($interp)> - This function frees the interpolation object $interp.
=item C<gsl_interp_bsearch($x_array, $x, $index_lo, $index_hi)>
This function returns the index i of the array $x_array such that $x_array[i]
<= x < $x_array[i+1]. The index is searched for in the range
[$index_lo,$index_hi].
=back
This module also includes the following constants :
=over 1
=item C<$gsl_interp_linear>
Linear interpolation
=item C<$gsl_interp_polynomial>
Polynomial interpolation. This method should only be used for interpolating
small numbers of points because polynomial interpolation introduces large
oscillations, even for well-behaved datasets. The number of terms in the
interpolating polynomial is equal to the number of points.
=item C<$gsl_interp_cspline>
Cubic spline with natural boundary conditions. The resulting curve is piecewise
cubic on each interval, with matching first and second derivatives at the
supplied data-points. The second derivative is chosen to be zero at the first
point and last point.
=item C<$gsl_interp_cspline_periodic>
Cubic spline with periodic boundary conditions. The resulting curve is
piecewise cubic on each interval, with matching first and second derivatives at
the supplied data-points. The derivatives at the first and last points are also
matched. Note that the last point in the data must have the same y-value as the
first point, otherwise the resulting periodic interpolation will have a
discontinuity at the boundary.
=item C<$gsl_interp_akima>
Non-rounded Akima spline with natural boundary conditions. This method uses the
non-rounded corner algorithm of Wodicka.
=item C<$gsl_interp_akima_periodic>
Non-rounded Akima spline with periodic boundary conditions. This method uses
the non-rounded corner algorithm of Wodicka.
=back
=head1 AUTHORS
Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
|