"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/GSL/MROOT.pm" (28 May 2022, 3052 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 "MROOT.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::MROOT;
    5 
    6 our @EXPORT_OK = qw(gslmroot_fsolver gslmroot_fsolver );
    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::MROOT ;
   18 
   19 
   20 
   21 
   22 
   23 
   24 #line 68 "gsl_mroot.pd"
   25 
   26 use strict;
   27 use warnings;
   28 
   29 =head1 NAME
   30                                                                     
   31 PDL::GSL::MROOT - PDL interface to multidimensional root-finding routines in GSL
   32                                                                                 
   33 =head1 DESCRIPTION
   34        
   35 This is an interface to the multidimensional root-finding package present in the 
   36 GNU Scientific Library.
   37 
   38 At the moment there is a single function B<gslmroot_fsolver> which provides an interface
   39 to the algorithms in the GSL library that do not use derivatives.  
   40 
   41 
   42 =head1 SYNOPSIS                                      
   43             
   44    use PDL;
   45    use PDL::GSL::MROOT;
   46 
   47    my $init = pdl (-10.00, -5.0);
   48    my $epsabs = 1e-7;
   49 
   50 
   51   $res = gslmroot_fsolver($init, \&rosenbrock,
   52                           {Method => 0, EpsAbs => $epsabs});
   53 
   54  
   55   sub rosenbrock{
   56      my ($x) = @_;
   57      my $c = 1;
   58      my $d = 10;
   59      my $y = zeroes($x);
   60 
   61      my $y0 = $y->slice(0);
   62      $y0 .=  $c * (1 - $x->slice(0));
   63 
   64      my $y1 = $y->slice(1);
   65      $y1 .=  $d * ($x->slice(1) - $x->slice(0)**2);
   66 
   67      return $y;
   68   }
   69 #line 70 "MROOT.pm"
   70 
   71 
   72 
   73 
   74 
   75 
   76 =head1 FUNCTIONS
   77 
   78 =cut
   79 
   80 
   81 
   82 
   83 #line 948 "../../../blib/lib/PDL/PP.pm"
   84 
   85 
   86 
   87 =head2 gslmroot_fsolver
   88 
   89 =for sig
   90 
   91   Signature: (double [io]xfree(n);   double epsabs(); int method(); SV* function1)
   92 
   93 
   94 =for ref
   95 
   96 info not available
   97 
   98 
   99 =for bad
  100 
  101 gslmroot_fsolver does not process bad values.
  102 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  103 
  104 
  105 =cut
  106 #line 107 "MROOT.pm"
  107 
  108 
  109 
  110 #line 949 "../../../blib/lib/PDL/PP.pm"
  111 
  112 sub gslmroot_fsolver {
  113     my ($x, $f_vect) = @_;
  114         my $opt = ref($_[-1]) eq 'HASH' ? pop @_ : {Method => 0, EpsAbs => 1e-3};
  115         if( (ref($x) ne 'PDL')){
  116            barf("Have to pass ndarray as first argument to fsolver\n");
  117         }
  118     my $res = $x->copy;
  119     _gslmroot_fsolver_int($res, $$opt{'EpsAbs'}, $$opt{'Method'}, $f_vect);
  120     return $res;
  121 }
  122 #line 123 "MROOT.pm"
  123 
  124 
  125 
  126 #line 950 "../../../blib/lib/PDL/PP.pm"
  127 
  128 *gslmroot_fsolver = \&PDL::GSL::MROOT::gslmroot_fsolver;
  129 #line 130 "MROOT.pm"
  130 
  131 
  132 
  133 
  134 
  135 #line 114 "gsl_mroot.pd"
  136 
  137 =head1 SEE ALSO
  138 
  139 L<PDL>
  140 
  141 The GSL documentation is online at
  142 
  143   http://www.gnu.org/software/gsl/manual/
  144 
  145 =head1 AUTHOR
  146 
  147 This file copyright (C) 2006 Andres Jordan <ajordan@eso.org> 
  148 and Simon Casassus <simon@das.uchile.cl>
  149 All rights reserved. There is no warranty. You are allowed to redistribute this 
  150 software/documentation under certain conditions. For details, see the file
  151 COPYING in the PDL distribution. If this file is separated from the
  152 PDL distribution, the copyright notice should be included in the file.
  153 
  154 =cut
  155 #line 156 "MROOT.pm"
  156 
  157 
  158 
  159 
  160 # Exit with OK status
  161 
  162 1;