"Fossies" - the Fresh Open Source Software Archive

Member "PDL-2.080/GENERATED/PDL/Minuit.pm" (28 May 2022, 21280 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 "Minuit.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::Minuit;
    5 
    6 our @EXPORT_OK = qw(mn_init mn_def_pars mn_excm mn_pout mn_stat mn_err mn_contour mn_emat mninit mn_abre mn_cierra mnparm mnexcm mnpout mnstat mnemat mnerrs mncont );
    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::Minuit ;
   18 
   19 
   20 
   21 
   22 
   23 
   24 #line 14 "minuit.pd"
   25 
   26 =head1 NAME
   27 
   28 PDL::Minuit -- a PDL interface to the Minuit library
   29 
   30 =head1 DESCRIPTION
   31 
   32 This package implements an interface to the Minuit minimization routines (part
   33 of the CERN Library)
   34 
   35 =head1 SYNOPSIS
   36 
   37 A basic fit with Minuit will call three functions in this package. First, a basic
   38 initialization is done with mn_init(). Then, the parameters are defined via
   39 the function mn_def_pars(), which allows setting upper and lower bounds. Then
   40 the function mn_excm() can be used to issue many Minuit commands, including simplex
   41 and migrad minimization algorithms (see Minuit manual for more details).
   42 
   43 See the test file minuit.t in the test (t/) directory for a basic example.
   44 
   45 =cut
   46 #line 47 "Minuit.pm"
   47 
   48 
   49 
   50 
   51 
   52 
   53 =head1 FUNCTIONS
   54 
   55 =cut
   56 
   57 
   58 
   59 
   60 #line 37 "minuit.pd"
   61 
   62 
   63 use strict;
   64 use warnings;
   65 
   66 # Package variable
   67 my $mn_options;
   68 sub mn_init{
   69   my $fun_ref = shift;
   70 
   71   $mn_options = { Log => undef,
   72           Title => 'Minuit Fit',
   73           N => undef,
   74                   Unit => undef,
   75                   Function => $fun_ref,
   76         };
   77 
   78   if ( @_ ){
   79     my $args = $_[0];
   80     for my $key (qw/ Log Title Unit/){
   81     $mn_options->{$key} = $args->{$key} if exists $args->{$key};
   82     }
   83   }
   84     
   85   # Check if there was a valid F77 available and barf
   86   # if there was not and the user is trying to pass Log
   87 
   88   if (defined($mn_options->{Log})) { 
   89     $mn_options->{Unit} = 88 unless defined $mn_options->{Unit};
   90   }
   91   else { $mn_options->{Unit} = 6; }
   92            
   93   if (defined (my $logfile = $mn_options->{Log})){ 
   94     if (-e $logfile) { unlink $logfile; }   
   95     PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'new');
   96   }
   97 
   98   PDL::Minuit::mninit(5,$mn_options->{Unit},$mn_options->{Unit});
   99   PDL::Minuit::mnseti($mn_options->{Title});
  100 
  101   if (defined (my $logfile = $mn_options->{Log})){
  102     PDL::Minuit::mn_cierra($mn_options->{Unit});
  103   }
  104 
  105 }
  106 #line 107 "Minuit.pm"
  107 
  108 
  109 
  110 #line 948 "../../blib/lib/PDL/PP.pm"
  111 
  112 
  113 
  114 =head2 mninit
  115 
  116 =for sig
  117 
  118   Signature: (longlong a();longlong b(); longlong c())
  119 
  120 
  121 =for ref
  122 
  123 info not available
  124 
  125 
  126 =for bad
  127 
  128 mninit does not process bad values.
  129 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  130 
  131 
  132 =cut
  133 #line 134 "Minuit.pm"
  134 
  135 
  136 
  137 #line 950 "../../blib/lib/PDL/PP.pm"
  138 
  139 *mninit = \&PDL::Minuit::mninit;
  140 #line 141 "Minuit.pm"
  141 
  142 
  143 
  144 #line 948 "../../blib/lib/PDL/PP.pm"
  145 
  146 
  147 
  148 =head2 mn_abre
  149 
  150 =for sig
  151 
  152   Signature: (longlong l(); char* nombre; char* mode)
  153 
  154 
  155 =for ref
  156 
  157 info not available
  158 
  159 
  160 =for bad
  161 
  162 mn_abre does not process bad values.
  163 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  164 
  165 
  166 =cut
  167 #line 168 "Minuit.pm"
  168 
  169 
  170 
  171 #line 950 "../../blib/lib/PDL/PP.pm"
  172 
  173 *mn_abre = \&PDL::Minuit::mn_abre;
  174 #line 175 "Minuit.pm"
  175 
  176 
  177 
  178 #line 948 "../../blib/lib/PDL/PP.pm"
  179 
  180 
  181 
  182 =head2 mn_cierra
  183 
  184 =for sig
  185 
  186   Signature: (longlong l())
  187 
  188 
  189 =for ref
  190 
  191 info not available
  192 
  193 
  194 =for bad
  195 
  196 mn_cierra does not process bad values.
  197 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  198 
  199 
  200 =cut
  201 #line 202 "Minuit.pm"
  202 
  203 
  204 
  205 #line 950 "../../blib/lib/PDL/PP.pm"
  206 
  207 *mn_cierra = \&PDL::Minuit::mn_cierra;
  208 #line 209 "Minuit.pm"
  209 
  210 
  211 
  212 #line 108 "minuit.pd"
  213 
  214 
  215 sub mn_def_pars{
  216   my $pars  = shift;
  217   my $steps = shift;
  218 
  219   my $n = nelem($pars);
  220   $mn_options->{N} = $n;
  221 
  222   #print "Unit :".$mn_options->{Unit}."\n";
  223 
  224   my @names = map "Par_$_", 0..$n-1;
  225   my $lo_bounds = zeroes($n);
  226   my $up_bounds = zeroes($n);
  227 
  228   if ( @_ ) {
  229      my $opts = $_[0];
  230      $lo_bounds = $opts->{Lower_bounds} if defined $opts->{Lower_bounds};
  231      $up_bounds = $opts->{Upper_bounds} if defined $opts->{Upper_bounds};
  232      if (defined($opts->{Names})){
  233     my $names_t = $opts->{Names};
  234     barf "Names has to be an array reference" unless ref($names_t) eq 'ARRAY';
  235     @names = @$names_t;
  236     barf "Names has to have as many elements as there are parameters " unless ( @names == $n);
  237      }
  238   }
  239 
  240   my $iflag = 0;
  241 
  242   if (defined (my $logfile = $mn_options->{Log})){
  243     PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  244   }
  245 
  246   foreach my $i ( 0..(nelem($pars)-1) ){
  247      my $ii = $i + 1;
  248      $iflag = PDL::Minuit::mnparm($ii,$pars->slice("($i)"),
  249                $steps->slice("($i)"),
  250                $lo_bounds->slice("($i)"),
  251                $up_bounds->slice("($i)"),
  252                $names[$i]);
  253      barf "Problem initializing parameter $i in Minuit, got $iflag" unless ($iflag == 0);
  254   }
  255   
  256   if (defined (my $logfile = $mn_options->{Log})){
  257      PDL::Minuit::mn_cierra($mn_options->{Unit});
  258   }
  259 }
  260 #line 261 "Minuit.pm"
  261 
  262 
  263 
  264 #line 948 "../../blib/lib/PDL/PP.pm"
  265 
  266 
  267 
  268 =head2 mnparm
  269 
  270 =for sig
  271 
  272   Signature: (longlong a(); double b(); double c(); double d(); double e(); longlong [o] ia(); char* str)
  273 
  274 
  275 =for ref
  276 
  277 info not available
  278 
  279 
  280 =for bad
  281 
  282 mnparm does not process bad values.
  283 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  284 
  285 
  286 =cut
  287 #line 288 "Minuit.pm"
  288 
  289 
  290 
  291 #line 950 "../../blib/lib/PDL/PP.pm"
  292 
  293 *mnparm = \&PDL::Minuit::mnparm;
  294 #line 295 "Minuit.pm"
  295 
  296 
  297 
  298 #line 164 "minuit.pd"
  299 
  300 
  301 sub mn_excm{
  302   my $command = shift;
  303   
  304   my $fun_ref = $mn_options->{Function};
  305 
  306   my ($arglis,$narg);
  307   if ( @_ ) { $arglis = shift; $narg = nelem($arglis);}
  308   else { $arglis = pdl(0); $narg = 0; }
  309    
  310   if ( @_ ) { barf "Usage : mn_excm($command, [$arglis]) \n"; }
  311 
  312   if (defined (my $logfile = $mn_options->{Log})){
  313     PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  314   }
  315 
  316   my $iflag = pdl(0);
  317 
  318 
  319   $iflag = PDL::Minuit::mnexcm($arglis, $narg, $command, $fun_ref,$mn_options->{N});
  320   warn "Problem executing command '$command' " unless ($iflag == 0);
  321 
  322   if (defined (my $logfile = $mn_options->{Log})){
  323     PDL::Minuit::mn_cierra($mn_options->{Unit});
  324   }
  325 
  326   return $iflag;
  327 }
  328 #line 329 "Minuit.pm"
  329 
  330 
  331 
  332 #line 948 "../../blib/lib/PDL/PP.pm"
  333 
  334 
  335 
  336 =head2 mnexcm
  337 
  338 =for sig
  339 
  340   Signature: (double a(n); longlong ia(); longlong [o] ib(); char* str; SV* function; IV numelem)
  341 
  342 
  343 =for ref
  344 
  345 info not available
  346 
  347 
  348 =for bad
  349 
  350 mnexcm does not process bad values.
  351 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  352 
  353 
  354 =cut
  355 #line 356 "Minuit.pm"
  356 
  357 
  358 
  359 #line 950 "../../blib/lib/PDL/PP.pm"
  360 
  361 *mnexcm = \&PDL::Minuit::mnexcm;
  362 #line 363 "Minuit.pm"
  363 
  364 
  365 
  366 #line 205 "minuit.pd"
  367 
  368 
  369   sub mn_pout{
  370     barf "Usage: mn_pout(par_number)" unless ($#_ == 0);
  371     my $par_num = shift;
  372     my $n = $mn_options->{N};
  373     if (($par_num < 1) || ($par_num > $n)) { barf "Parameter numbers range from 1 to $n "; }
  374 
  375     if (defined (my $logfile = $mn_options->{Log})){
  376       PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  377     }
  378 
  379     my $val = pdl(0);
  380     my $err = pdl(0);
  381     my $bnd1 = pdl(0);
  382     my $bnd2 = pdl(0);
  383     my $ivarbl = pdl(0);
  384     my $par_name = "          ";
  385     PDL::Minuit::mnpout($par_num,$val,$err,$bnd1,$bnd2,$ivarbl,\$par_name);
  386 
  387     if (defined (my $logfile = $mn_options->{Log})){
  388       PDL::Minuit::mn_cierra($mn_options->{Unit});
  389     }
  390 
  391     return ($val,$err,$bnd1,$bnd2,$ivarbl,$par_name);    
  392   }
  393 #line 394 "Minuit.pm"
  394 
  395 
  396 
  397 #line 948 "../../blib/lib/PDL/PP.pm"
  398 
  399 
  400 
  401 =head2 mnpout
  402 
  403 =for sig
  404 
  405   Signature: (longlong ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d();longlong [o] ib(); SV* str)
  406 
  407 
  408 =for ref
  409 
  410 info not available
  411 
  412 
  413 =for bad
  414 
  415 mnpout does not process bad values.
  416 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  417 
  418 
  419 =cut
  420 #line 421 "Minuit.pm"
  421 
  422 
  423 
  424 #line 950 "../../blib/lib/PDL/PP.pm"
  425 
  426 *mnpout = \&PDL::Minuit::mnpout;
  427 #line 428 "Minuit.pm"
  428 
  429 
  430 
  431 #line 242 "minuit.pd"
  432 
  433 
  434   sub mn_stat{
  435      if (defined (my $logfile = $mn_options->{Log})){
  436        PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  437      }
  438 
  439 
  440      my ($fmin,$fedm,$errdef,$npari,$nparx,$istat) = PDL::Minuit::mnstat();
  441 
  442      if (defined (my $logfile = $mn_options->{Log})){
  443        PDL::Minuit::mn_cierra($mn_options->{Unit});
  444      }
  445 
  446      return ($fmin,$fedm,$errdef,$npari,$nparx,$istat);
  447   }
  448 #line 449 "Minuit.pm"
  449 
  450 
  451 
  452 #line 948 "../../blib/lib/PDL/PP.pm"
  453 
  454 
  455 
  456 =head2 mnstat
  457 
  458 =for sig
  459 
  460   Signature: (double [o] a(); double [o] b(); double [o] c(); longlong [o] ia(); longlong [o] ib(); longlong [o] ic())
  461 
  462 
  463 =for ref
  464 
  465 info not available
  466 
  467 
  468 =for bad
  469 
  470 mnstat does not process bad values.
  471 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  472 
  473 
  474 =cut
  475 #line 476 "Minuit.pm"
  476 
  477 
  478 
  479 #line 950 "../../blib/lib/PDL/PP.pm"
  480 
  481 *mnstat = \&PDL::Minuit::mnstat;
  482 #line 483 "Minuit.pm"
  483 
  484 
  485 
  486 #line 264 "minuit.pd"
  487 
  488 
  489   sub mn_emat{
  490    
  491     if (defined (my $logfile = $mn_options->{Log})){
  492       PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  493     }
  494 
  495     my ($fmin,$fedm,$errdef,$npari,$nparx,$istat) = PDL::Minuit::mnstat();
  496     my $n = $npari->sum->at;
  497     my $mat = zeroes($n,$n);
  498 
  499     PDL::Minuit::mnemat($mat);
  500 
  501     if (defined (my $logfile = $mn_options->{Log})){
  502       PDL::Minuit::mn_cierra($mn_options->{Unit});
  503     }
  504     
  505     return $mat;
  506 
  507   }
  508 #line 509 "Minuit.pm"
  509 
  510 
  511 
  512 #line 948 "../../blib/lib/PDL/PP.pm"
  513 
  514 
  515 
  516 =head2 mnemat
  517 
  518 =for sig
  519 
  520   Signature: (double [o] mat(n,n))
  521 
  522 
  523 =for ref
  524 
  525 info not available
  526 
  527 
  528 =for bad
  529 
  530 mnemat does not process bad values.
  531 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  532 
  533 
  534 =cut
  535 #line 536 "Minuit.pm"
  536 
  537 
  538 
  539 #line 950 "../../blib/lib/PDL/PP.pm"
  540 
  541 *mnemat = \&PDL::Minuit::mnemat;
  542 #line 543 "Minuit.pm"
  543 
  544 
  545 
  546 #line 292 "minuit.pd"
  547 
  548 
  549   sub mn_err{
  550 
  551     barf "Usage: mn_err(par_number)" unless ($#_ == 0);
  552     my $par_num = shift;
  553 
  554     my $n = $mn_options->{N};
  555     if (($par_num < 1) || ($par_num > $n)) { barf "Parameter numbers range from 1 to $n "; }
  556 
  557     if (defined (my $logfile = $mn_options->{Log})){
  558       PDL::Minuit::mn_abre($mn_options->{Unit},$logfile,'old');
  559     }
  560 
  561     my ($eplus,$eminus,$eparab,$globcc) = PDL::Minuit::mnerrs($par_num);
  562 
  563     if (defined (my $logfile = $mn_options->{Log})){
  564       PDL::Minuit::mn_cierra($mn_options->{Unit});
  565     }
  566 
  567     return ($eplus,$eminus,$eparab,$globcc);
  568   }
  569 #line 570 "Minuit.pm"
  570 
  571 
  572 
  573 #line 948 "../../blib/lib/PDL/PP.pm"
  574 
  575 
  576 
  577 =head2 mnerrs
  578 
  579 =for sig
  580 
  581   Signature: (longlong ia(); double [o] a(); double [o] b(); double [o] c(); double [o] d())
  582 
  583 
  584 =for ref
  585 
  586 info not available
  587 
  588 
  589 =for bad
  590 
  591 mnerrs does not process bad values.
  592 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  593 
  594 
  595 =cut
  596 #line 597 "Minuit.pm"
  597 
  598 
  599 
  600 #line 950 "../../blib/lib/PDL/PP.pm"
  601 
  602 *mnerrs = \&PDL::Minuit::mnerrs;
  603 #line 604 "Minuit.pm"
  604 
  605 
  606 
  607 #line 320 "minuit.pd"
  608 
  609 
  610   sub mn_contour{
  611     barf "Usage: mn_contour(par_number_1,par_number_2,npt)" unless ($#_ == 2);
  612     my $par_num_1 = shift;
  613     my $par_num_2 = shift;
  614     my $npt = shift;
  615 
  616     my $fun_ref = $mn_options->{Function};
  617 
  618     my $n = $mn_options->{N};
  619     if (($par_num_1 < 1) || ($par_num_1 > $n)) { barf "Parameter numbers range from 1 to $n "; }
  620     if (($par_num_2 < 1) || ($par_num_2 > $n)) { barf "Parameter numbers range from 1 to $n "; }
  621     if ($npt < 5) { barf "Have to specify at least 5 points in routine contour "; }
  622 
  623     my $xpt = zeroes($npt);
  624     my $ypt = zeroes($npt);
  625     my $nfound = pdl->new;
  626 
  627     PDL::Minuit::mncont($par_num_1,$par_num_2,$npt,$xpt,$ypt,$nfound,$fun_ref,$n);
  628 
  629     if (defined (my $logfile = $mn_options->{Log})){
  630       PDL::Minuit::mn_cierra($mn_options->{Unit});
  631     }
  632 
  633     return ($xpt,$ypt,$nfound);
  634   }
  635 #line 636 "Minuit.pm"
  636 
  637 
  638 
  639 #line 948 "../../blib/lib/PDL/PP.pm"
  640 
  641 
  642 
  643 =head2 mncont
  644 
  645 =for sig
  646 
  647   Signature: (longlong ia(); longlong ib(); longlong ic(); double [o] a(n); double [o] b(n); longlong [o] id(); SV* function; IV numelem)
  648 
  649 
  650 =for ref
  651 
  652 info not available
  653 
  654 
  655 =for bad
  656 
  657 mncont does not process bad values.
  658 It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.
  659 
  660 
  661 =cut
  662 #line 663 "Minuit.pm"
  663 
  664 
  665 
  666 #line 950 "../../blib/lib/PDL/PP.pm"
  667 
  668 *mncont = \&PDL::Minuit::mncont;
  669 #line 670 "Minuit.pm"
  670 
  671 
  672 
  673 #line 358 "minuit.pd"
  674 
  675 
  676 =head2 mn_init()
  677 
  678 =for ref
  679 
  680 The function mn_init() does the basic initialization of the fit. The first argument
  681 has to be a reference to the function to be minimized. The function
  682 to be minimized has to receive five arguments
  683 ($npar,$grad,$fval,$xval,$iflag). The first is the number
  684 of parameters currently variable. The second is the gradient
  685 of the function (which is not necessarily used, see 
  686 the Minuit documentation). The third is the current value of the
  687 function. The fourth is an ndarray with the values of the parameters. 
  688 The fifth is an integer flag, which indicates what
  689 the function is supposed to calculate. The function has to
  690 return the  values ($fval,$grad), the function value and 
  691 the function gradient. 
  692 
  693 There are three optional arguments to mn_init(). By default, the output of Minuit
  694 will come through STDOUT unless a filename $logfile is given
  695 in the Log option. Note that this will mercilessly erase $logfile
  696 if it already exists. Additionally, a title can be given to the fit
  697 by the Title option, the default is 'Minuit Fit'. If the output is
  698 written to a logfile, this is assigned Fortran unit number 88. If for
  699 whatever reason you want to have control over the unit number
  700 that Fortran associates to the logfile, you can pass the number 
  701 through the Unit option.
  702 
  703 =for usage
  704 
  705 Usage:
  706 
  707  mn_init($function_ref,{Log=>$logfile,Title=>$title,Unit=>$unit})
  708 
  709 =for example
  710 
  711 Example:
  712 
  713  mn_init(\&my_function);
  714 
  715  #same as above but outputting to a file 'log.out'.
  716  #title for fit is 'My fit'
  717  mn_init(\&my_function,
  718      {Log => 'log.out', Title => 'My fit'});
  719 
  720 
  721  sub my_function{
  722     # the five variables input to the function to be minimized
  723     # xval is an ndarray containing the current values of the parameters
  724     my ($npar,$grad,$fval,$xval,$iflag) = @_;
  725 
  726 
  727     # Here is code computing the value of the function
  728     # and potentially also its gradient
  729     # ......
  730 
  731     # return the two variables. If no gradient is being computed
  732     # just return the $grad that came as input
  733     return ($fval, $grad);
  734  }
  735 
  736 =head2 mn_def_pars()
  737 
  738 =for ref
  739 
  740 The function mn_def_pars() defines the initial values of the parameters of the function to 
  741 be minimized and the value of the initial steps around these values that the 
  742 minimizer will use for the first variations of the parameters in the search for the minimum.
  743 There are several optional arguments. One allows assigning names to these parameters which 
  744 otherwise get names (Par_0, Par_1,....,Par_n) by default. Another two arguments can give
  745 lower and upper bounds for the parameters via two ndarrays. If the lower and upper bound for a 
  746 given parameter are both equal to 0 then the parameter is unbound. By default these lower and
  747 upper bound ndarrays are set to  zeroes(n), where n is the number of parameters, i.e. the 
  748 parameters are unbound by default. 
  749 
  750 The function needs two input variables: an ndarray giving the initial values of the
  751 parameters and another ndarray giving the initial steps. An optional reference to a 
  752 perl array with the  variable names can be passed, as well as ndarrays
  753 with upper and lower bounds for the parameters (see example below).
  754 
  755 It returns an integer variable which is 0 upon success.
  756 
  757 =for usage
  758 
  759 Usage:
  760 
  761  $iflag = mn_def_pars($pars, $steps,{Names => \@names, 
  762             Lower_bounds => $lbounds,
  763             Upper_bounds => $ubounds})
  764 
  765 
  766 =for example
  767 
  768 Example:
  769 
  770  #initial parameter values
  771  my $pars = pdl(2.5,3.0);          
  772 
  773  #steps
  774  my $steps = pdl(0.3,0.5);     
  775 
  776  #parameter names    
  777  my @names = ('intercept','slope');
  778 
  779  #use mn_def_pars with default parameter names (Par_0,Par_1,...)
  780  my $iflag = mn_def_pars($pars,$steps);
  781 
  782  #use of mn_def_pars explicitly specify parameter names
  783  $iflag = mn_def_pars($pars,$steps,{Names => \@names});
  784 
  785  # specify lower and upper bounds for the parameters. 
  786  # The example below leaves parameter 1 (intercept) unconstrained
  787  # and constrains parameter 2 (slope) to be between 0 and 100
  788  my $lbounds = pdl(0, 0);
  789  my $ubounds = pdl(0, 100);
  790 
  791  $iflag = mn_def_pars($pars,$steps,{Names => \@names, 
  792             Lower_bounds => $lbounds,
  793             Upper_bounds => $ubounds}});
  794 
  795  #same as above because $lbounds is by default zeroes(n)
  796  $iflag = mn_def_pars($pars,$steps,{Names => \@names, 
  797             Upper_bounds => $ubounds}});
  798 
  799 
  800 
  801 =head2 mn_excm()
  802 
  803 The function mn_excm() executes a Minuit command passed as
  804 a string. The first argument is the command string and an optional
  805 second argument is an ndarray with arguments to the command.
  806 The available commands are listed in Chapter 4 of the Minuit 
  807 manual (see url below).
  808 
  809 It returns an integer variable which is 0 upon success.
  810 
  811 =for usage
  812 
  813 Usage:
  814 
  815  $iflag = mn_excm($command_string, {$arglis})
  816 
  817 =for example
  818 
  819 Example:
  820 
  821   #start a simplex minimization
  822   my $iflag = mn_excm('simplex');
  823 
  824   #same as above but specify the maximum allowed numbers of
  825   #function calls in the minimization 
  826   my $arglist = pdl(1000);
  827   $iflag = mn_excm('simplex',$arglist);
  828 
  829   #start a migrad minimization
  830   $iflag = mn_excm('migrad')
  831 
  832   #set Minuit strategy in order to get the most reliable results
  833   $arglist = pdl(2)
  834   $iflag = mn_excm('set strategy',$arglist);
  835 
  836   # each command can be specified by a minimal string that uniquely
  837   # identifies it (see Chapter 4 of Minuit manual). The comannd above
  838   # is equivalent to:
  839   $iflag = mn_excm('set stra',$arglis);
  840 
  841 =head2 mn_pout()
  842 
  843 The function mn_pout() gets the current value of a parameter. It 
  844 takes as input the parameter number and returns an array with the
  845 parameter value, the current estimate of its uncertainty (0 if
  846 parameter is constant), lower bound on the parameter, if any 
  847 (otherwise 0), upper bound on the parameter, if any (otherwise 0),
  848 integer flag (which is equal to the parameter number if variable,
  849 zero if the parameter is constant and negative if parameter is
  850 not defined) and the parameter name.
  851 
  852 =for usage
  853 
  854 Usage:
  855 
  856      ($val,$err,$bnd1,$bnd2,$ivarbl,$par_name) = mn_pout($par_number);
  857 
  858 =head2 mn_stat()
  859 
  860 The function mn_stat() gets the current status of the minimization.
  861 It returns an array with the best function value found so far,
  862 the estimated vertical distance remaining to minimum, the value
  863 of UP defining parameter uncertainties (default is 1), the number
  864 of currently variable parameters, the highest parameter defined
  865 and an integer flag indicating how good the covariance matrix is
  866 (0=not calculated at all; 1=diagonal approximation, not accurate;
  867 2=full matrix, but forced positive definite; 3=full accurate matrix)
  868 
  869 =for usage
  870 
  871 Usage:
  872 
  873     ($fmin,$fedm,$errdef,$npari,$nparx,$istat) = mn_stat();
  874 
  875 =head2 mn_emat()
  876 
  877 The function mn_emat returns the covariance matrix as an ndarray.
  878 
  879 =for usage
  880 
  881 Usage:
  882 
  883   $emat = mn_emat();
  884 
  885 =head2 mn_err()
  886 
  887 The function mn_err() returns the current existing values for 
  888 the error in the fitted parameters. It returns an array
  889 with the positive error, the negative error, the "parabolic" 
  890 parameter error from the error matrix and the global correlation
  891 coefficient, which is a number between 0 and 1 which gives
  892 the correlation between the requested parameter and that linear
  893 combination of all other parameters which is most strongly 
  894 correlated with it. Unless the command 'MINOS' has been issued via
  895 the function mn_excm(), the first three values will be equal.
  896 
  897 =for usage
  898 
  899 Usage:
  900 
  901   ($eplus,$eminus,$eparab,$globcc) = mn_err($par_number);
  902 
  903 =head2 mn_contour()
  904 
  905 The function mn_contour() finds contours of the function being minimized
  906 with respect to two chosen parameters. The contour level is given by 
  907 F_min + UP, where F_min is the minimum of the function and UP is the ERRordef
  908 specified by the user, or 1.0 by default (see Minuit manual). The contour
  909 calculated by this function is dynamic, in the sense that it represents the
  910 minimum of the function being minimized with respect to all the other NPAR-2 parameters
  911 (if any).
  912 
  913 The function takes as input the parameter numbers with respect to which the contour
  914 is to be determined (two) and the number of points $npt required on the contour (>4).
  915 It returns an array with ndarrays $xpt,$ypt containing the coordinates of the contour 
  916 and a variable $nfound indicating the number of points actually found in the contour.
  917 If all goes well $nfound will be equal to $npt, but it can be negative if the input
  918 arguments are not valid, zero if less than four points have been found or <$npt if the
  919 program could not find $npt points.
  920 
  921 =for usage
  922 
  923 Usage: 
  924 
  925   ($xpt,$ypt,$nfound) = mn_contour($par_number_1,$par_number_2,$npt)
  926 
  927 =head1 SEE ALSO
  928 
  929 L<PDL>
  930 
  931 The Minuit documentation is online at
  932 
  933   http://wwwasdoc.web.cern.ch/wwwasdoc/minuit/minmain.html
  934 
  935 =head1 AUTHOR
  936 
  937 This file copyright (C) 2007 Andres Jordan <ajordan@eso.org>.
  938 All rights reserved. There is no warranty. You are allowed to redistribute this 
  939 software/documentation under certain conditions. For details, see the file
  940 COPYING in the PDL distribution. If this file is separated from the
  941 PDL distribution, the copyright notice should be included in the file.
  942 
  943 =cut
  944 #line 945 "Minuit.pm"
  945 
  946 
  947 
  948 
  949 
  950 
  951 # Exit with OK status
  952 
  953 1;