"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/GSL/INTERP.pm" (28 May 2022, 7860 Bytes) of package /linux/misc/PDL-2.080.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "INTERP.pm" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.079_vs_2.080.

    1 #
    2 # GENERATED WITH PDL::PP! Don't modify!
    3 #
    4 package PDL::GSL::INTERP;
    5 
    6 our @EXPORT_OK = qw( );
    7 our %EXPORT_TAGS = (Func=>\@EXPORT_OK);
    8 
    9 use PDL::Core;
   10 use PDL::Exporter;
   11 use DynaLoader;
   12 
   13 
   14    
   15    our @ISA = ( 'PDL::Exporter','DynaLoader' );
   16    push @PDL::Core::PP, __PACKAGE__;
   17    bootstrap PDL::GSL::INTERP ;
   18 
   19 
   20 
   21 
   22 
   23 
   24 #line 6 "gsl_interp.pd"
   25 
   26 use strict;
   27 use warnings;
   28 
   29 =head1 NAME
   30 
   31 PDL::GSL::INTERP - PDL interface to Interpolation routines in GSL
   32 
   33 =head1 DESCRIPTION
   34 
   35 This is an interface to the interpolation package present in the
   36 GNU Scientific Library.
   37 
   38 =head1 SYNOPSIS
   39 
   40    use PDL;
   41    use PDL::GSL::INTERP;
   42 
   43    my $x = sequence(10);
   44    my $y = exp($x);
   45 
   46    my $spl = PDL::GSL::INTERP->init('cspline',$x,$y);
   47 
   48    my $res = $spl->eval(4.35);
   49    $res = $spl->deriv(4.35);
   50    $res = $spl->deriv2(4.35);
   51    $res = $spl->integ(2.1,7.4);
   52 
   53 =head1 NOMENCLATURE
   54 
   55 Throughout this documentation we strive to use the same variables that
   56 are present in the original GSL documentation (see L<See
   57 Also|"SEE-ALSO">). Oftentimes those variables are called C<a> and
   58 C<b>. Since good Perl coding practices discourage the use of Perl
   59 variables C<$a> and C<$b>, here we refer to Parameters C<a> and C<b>
   60 as C<$pa> and C<$pb>, respectively, and Limits (of domain or
   61 integration) as C<$la> and C<$lb>.
   62 #line 63 "INTERP.pm"
   63 
   64 
   65 
   66 
   67 
   68 
   69 =head1 FUNCTIONS
   70 
   71 =cut
   72 
   73 
   74 
   75 
   76 #line 948 "../../../blib/lib/PDL/PP.pm"
   77 
   78 
   79 
   80 =head2 init
   81 
   82 =for sig
   83 
   84   Signature: (double x(n); double y(n); gsl_spline *spl)
   85 
   86 =for ref
   87 
   88 The init method initializes a new instance of INTERP. It needs as
   89 input an interpolation type and two ndarrays holding the x and y
   90 values to be interpolated. The GSL routines require that x be
   91 monotonically increasing and a quicksort is performed by default to
   92 ensure that. You can skip the quicksort by passing the option
   93 {Sort => 0}.
   94 
   95 The available interpolation types are :
   96 
   97 =over 2
   98 
   99 =item linear
  100 
  101 =item polynomial
  102 
  103 =item cspline (natural cubic spline)
  104 
  105 =item cspline_periodic  (periodic cubic spline)
  106 
  107 =item akima (natural akima spline)
  108 
  109 =item akima_periodic  (periodic akima spline)
  110 
  111 =back
  112 
  113 Please check the GSL documentation for more information.
  114 
  115 =for usage
  116 
  117 Usage:
  118 
  119     $blessed_ref = PDL::GSL::INTERP->init($interp_method,$x,$y,$opt);
  120 
  121 =for example
  122 
  123 Example:
  124 
  125     $x = sequence(10);
  126     $y = exp($x);
  127 
  128     $spl = PDL::GSL::INTERP->init('cspline',$x,$y)
  129     $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 1}) #same as above
  130 
  131     # no sorting done on x, user is certain that x is monotonically increasing
  132     $spl = PDL::GSL::INTERP->init('cspline',$x,$y,{Sort => 0});
  133 
  134 
  135 =for bad
  136 
  137 init does not process bad values.
  138 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  139 
  140 
  141 =cut
  142 #line 143 "INTERP.pm"
  143 
  144 
  145 
  146 #line 949 "../../../blib/lib/PDL/PP.pm"
  147 
  148 sub init {
  149   my $opt;
  150   if (ref($_[$#_]) eq 'HASH'){ $opt = pop @_; }
  151   else{ $opt = {Sort => 1}; }
  152   my ($class,$type,$x,$y) = @_;
  153   if( (ref($x) ne 'PDL') || (ref($y) ne 'PDL') ){
  154     barf("Have to pass ndarrays as arguments to init method\n");
  155   }
  156   if($$opt{Sort} != 0){
  157     my $idx = PDL::Ufunc::qsorti($x);
  158     $x = $x->index($idx);
  159     $y = $y->index($idx);
  160   }
  161   my $ene = nelem($x);
  162   my $obj1 = new_spline($type,$ene);
  163   my $obj2 = new_accel();
  164   _init_int($x,$y,$$obj1);
  165   my @ret_a = ($obj1,$obj2);
  166   return bless(\@ret_a, $class);
  167 }
  168 #line 169 "INTERP.pm"
  169 
  170 
  171 
  172 #line 950 "../../../blib/lib/PDL/PP.pm"
  173 
  174 *init = \&PDL::GSL::INTERP::init;
  175 #line 176 "INTERP.pm"
  176 
  177 
  178 
  179 #line 948 "../../../blib/lib/PDL/PP.pm"
  180 
  181 
  182 
  183 =head2 eval
  184 
  185 =for sig
  186 
  187   Signature: (double x(); double [o] out(); gsl_spline *spl;gsl_interp_accel *acc)
  188 
  189 =for ref
  190 
  191 The function eval returns the interpolating function at a given point.
  192 It will barf with an "input domain error" if you try to extrapolate.
  193 
  194 =for usage
  195 
  196 Usage:
  197 
  198     $result = $spl->eval($points);
  199 
  200 =for example
  201 
  202 Example:
  203 
  204     my $res = $spl->eval($x)
  205 
  206 
  207 
  208 =for bad
  209 
  210 eval processes bad values.
  211 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  212 
  213 
  214 =cut
  215 #line 216 "INTERP.pm"
  216 
  217 
  218 
  219 #line 949 "../../../blib/lib/PDL/PP.pm"
  220 
  221 sub eval {
  222   my $opt;
  223   my ($obj,$x) = @_;
  224   my $s_obj = $$obj[0];
  225   my $a_obj = $$obj[1];
  226   _eval_int($x,my $o=PDL->null,$$s_obj,$$a_obj);
  227   $o;
  228 }
  229 #line 230 "INTERP.pm"
  230 
  231 
  232 
  233 #line 950 "../../../blib/lib/PDL/PP.pm"
  234 
  235 *eval = \&PDL::GSL::INTERP::eval;
  236 #line 237 "INTERP.pm"
  237 
  238 
  239 
  240 #line 948 "../../../blib/lib/PDL/PP.pm"
  241 
  242 
  243 
  244 =head2 deriv
  245 
  246 =for sig
  247 
  248   Signature: (double x(); double [o] out(); gsl_spline *spl;gsl_interp_accel *acc)
  249 
  250 =for ref
  251 
  252 The deriv function returns the derivative of the
  253 interpolating function at a given point.
  254 It will barf with an "input domain error" if you try to extrapolate.
  255 
  256 =for usage
  257 
  258 Usage:
  259 
  260     $result = $spl->deriv($points);
  261 
  262 =for example
  263 
  264 Example:
  265 
  266     my $res = $spl->deriv($x)
  267 
  268 
  269 
  270 =for bad
  271 
  272 deriv does not process bad values.
  273 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  274 
  275 
  276 =cut
  277 #line 278 "INTERP.pm"
  278 
  279 
  280 
  281 #line 949 "../../../blib/lib/PDL/PP.pm"
  282 
  283 sub deriv {
  284   my ($obj,$x) = @_;
  285   my $s_obj = $$obj[0];
  286   my $a_obj = $$obj[1];
  287   _deriv_int($x,my $o=PDL->null,$$s_obj,$$a_obj);
  288   $o;
  289 }
  290 #line 291 "INTERP.pm"
  291 
  292 
  293 
  294 #line 950 "../../../blib/lib/PDL/PP.pm"
  295 
  296 *deriv = \&PDL::GSL::INTERP::deriv;
  297 #line 298 "INTERP.pm"
  298 
  299 
  300 
  301 #line 948 "../../../blib/lib/PDL/PP.pm"
  302 
  303 
  304 
  305 =head2 deriv2
  306 
  307 =for sig
  308 
  309   Signature: (double x(); double [o] out(); gsl_spline *spl;gsl_interp_accel *acc)
  310 
  311 =for ref
  312 
  313 The deriv2 function returns the second derivative
  314 of the interpolating function at a given point.
  315 It will barf with an "input domain error" if you try to extrapolate.
  316 
  317 =for usage
  318 
  319 Usage:
  320 
  321     $result = $spl->deriv2($points);
  322 
  323 =for example
  324 
  325 Example:
  326 
  327     my $res = $spl->deriv2($x)
  328 
  329 
  330 
  331 =for bad
  332 
  333 deriv2 does not process bad values.
  334 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  335 
  336 
  337 =cut
  338 #line 339 "INTERP.pm"
  339 
  340 
  341 
  342 #line 949 "../../../blib/lib/PDL/PP.pm"
  343 
  344 sub deriv2 {
  345   my ($obj,$x) = @_;
  346   my $s_obj = $$obj[0];
  347   my $a_obj = $$obj[1];
  348   _deriv2_int($x,my $o=PDL->null,$$s_obj,$$a_obj);
  349   $o;
  350 }
  351 #line 352 "INTERP.pm"
  352 
  353 
  354 
  355 #line 950 "../../../blib/lib/PDL/PP.pm"
  356 
  357 *deriv2 = \&PDL::GSL::INTERP::deriv2;
  358 #line 359 "INTERP.pm"
  359 
  360 
  361 
  362 #line 948 "../../../blib/lib/PDL/PP.pm"
  363 
  364 
  365 
  366 =head2 integ
  367 
  368 =for sig
  369 
  370   Signature: (double a(); double b(); double [o] out(); gsl_spline *spl;gsl_interp_accel *acc)
  371 
  372 =for ref
  373 
  374 The integ function returns the integral
  375 of the interpolating function between two points.
  376 It will barf with an "input domain error" if you try to extrapolate.
  377 
  378 =for usage
  379 
  380 Usage:
  381 
  382     $result = $spl->integ($la,$lb);
  383 
  384 =for example
  385 
  386 Example:
  387 
  388     my $res = $spl->integ($la,$lb)
  389 
  390 
  391 
  392 =for bad
  393 
  394 integ does not process bad values.
  395 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  396 
  397 
  398 =cut
  399 #line 400 "INTERP.pm"
  400 
  401 
  402 
  403 #line 949 "../../../blib/lib/PDL/PP.pm"
  404 
  405 sub integ {
  406   my ($obj,$la,$lb) = @_;
  407   my $s_obj = $$obj[0];
  408   my $a_obj = $$obj[1];
  409   _integ_int($la,$lb,my $o=PDL->null,$$s_obj,$$a_obj);
  410   $o;
  411 }
  412 #line 413 "INTERP.pm"
  413 
  414 
  415 
  416 #line 950 "../../../blib/lib/PDL/PP.pm"
  417 
  418 *integ = \&PDL::GSL::INTERP::integ;
  419 #line 420 "INTERP.pm"
  420 
  421 
  422 
  423 
  424 
  425 #line 45 "gsl_interp.pd"
  426 
  427 =head1 BUGS
  428 
  429 Feedback is welcome.
  430 
  431 =head1 SEE ALSO
  432 
  433 L<PDL>
  434 
  435 The GSL documentation for interpolation is online at
  436 L<https://www.gnu.org/software/gsl/doc/html/interp.html>
  437 
  438 =head1 AUTHOR
  439 
  440 This file copyright (C) 2003 Andres Jordan <andresj@physics.rutgers.edu>
  441 All rights reserved. There is no warranty. You are allowed to redistribute this
  442 software/documentation under certain conditions. For details, see the file
  443 COPYING in the PDL distribution. If this file is separated from the
  444 PDL distribution, the copyright notice should be included in the file.
  445 
  446 The GSL interpolation module was written by Gerard Jungman.
  447 
  448 =cut
  449 #line 450 "INTERP.pm"
  450 
  451 
  452 
  453 
  454 # Exit with OK status
  455 
  456 1;