From: Michael C. <mc...@us...> - 2004-09-06 12:49:00
|
Update of /cvsroot/octave/octave-forge/main/optim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23415/main/optim Modified Files: bfgsmin-example.m bfgsmin.cc bisectionstep.cc finitedifference.cc lbfgsmin.cc newtonstep.cc Log Message: Improvement of help strings and argument checking for internal use functions. Still need to check types. Index: bfgsmin.cc =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/bfgsmin.cc,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- bfgsmin.cc 29 Jun 2004 09:44:47 -0000 1.5 +++ bfgsmin.cc 6 Sep 2004 12:48:49 -0000 1.6 @@ -64,7 +64,7 @@ DEFUN_DLD(bfgsmin, args, , - "bfgsmin: bfgs minimization of a function.\n\ + "bfgsmin: bfgs minimization of a function. See bfgsmin-example.m\n\ \n\ [x, obj, convergence] = bfgsmin(\"f\", {args}, {control}, {tols})\n\ \n\ @@ -100,7 +100,7 @@ In this example, x is optimized since it's the first\n\ element of the cell array, y is a fixed constant = 1\n\ \n\ -bfgsmin(\"f\", {ones(2,1), 1}, [10,2,1,1])\n\ +bfgsmin(\"f\", {ones(2,1), 1}, {10,2,1,1})\n\ \n\ bfgsmin final results: Iteration 1\n\ Stepsize 0.0000000\n\ Index: bisectionstep.cc =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/bisectionstep.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bisectionstep.cc 28 Jun 2004 11:57:42 -0000 1.2 +++ bisectionstep.cc 6 Sep 2004 12:48:49 -0000 1.3 @@ -33,8 +33,21 @@ #include <octave/lo-ieee.h> #include <float.h> -DEFUN_DLD(bisectionstep, args, , "bisectionstep.cc") +DEFUN_DLD(bisectionstep, args, , "bisectionstep.cc - for internal use by bfgsmin and related functions") { + + int nargin = args.length (); + if (nargin < 3) + { + error("bisectionstep: you must supply at least 3 arguments"); + return octave_value_list(); + } + + if (nargin > 4) + { + error("bisectionstep: you must supply at most 4 arguments"); + return octave_value_list(); + } std::string f (args(0).string_value()); Cell f_args (args(1).cell_value()); ColumnVector dx (args(2).column_vector_value()); Index: finitedifference.cc =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/finitedifference.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- finitedifference.cc 28 Jun 2004 11:57:42 -0000 1.2 +++ finitedifference.cc 6 Sep 2004 12:48:49 -0000 1.3 @@ -18,9 +18,18 @@ // finite differences for numeric differentiation #include <oct.h> #include <float.h> -DEFUN_DLD(finitedifference, args, ,"finitedifference, C++ version\n\ -differences for numgradient and numhessian") +DEFUN_DLD(finitedifference, args, ,"finitedifference,\n\ +for internal use by numgradient and numhessian") { + + + int nargin = args.length (); + if (!(nargin == 2)) + { + error("finitedifference: you must supply exactly 2 arguments"); + return octave_value_list(); + } + double x = args(0).double_value(); int order = args(1).int_value(); int test; Index: newtonstep.cc =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/newtonstep.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- newtonstep.cc 28 Jun 2004 11:57:42 -0000 1.2 +++ newtonstep.cc 6 Sep 2004 12:48:49 -0000 1.3 @@ -28,8 +28,24 @@ #include <octave/lo-ieee.h> #include <float.h> -DEFUN_DLD(newtonstep, args, , "newtonstep.cc") +DEFUN_DLD(newtonstep, args, , "newtonstep.cc - for internal use by bfgsmin and related functions") { + + + int nargin = args.length (); + if (nargin < 3) + { + error("newtonstep: you must supply at least 3 arguments"); + return octave_value_list(); + } + + if (nargin > 4) + { + error("bisectionstep: you must supply at most 4 arguments"); + return octave_value_list(); + } + + std::string f (args(0).string_value()); Cell f_args (args(1).cell_value()); Matrix dx (args(2).matrix_value()); Index: lbfgsmin.cc =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/lbfgsmin.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- lbfgsmin.cc 29 Jun 2004 09:45:24 -0000 1.4 +++ lbfgsmin.cc 6 Sep 2004 12:48:49 -0000 1.5 @@ -96,7 +96,7 @@ DEFUN_DLD(lbfgsmin, args, , - "lbfgsmin: limited memory bfgs minimization of a function.\n\ + "lbfgsmin: limited memory bfgs minimization of a function. See lbfgsmin-example.m\n\ \n\ [x, obj, convergence] = lbfgsmin(\"f\", {args}, {control}, {tols}]\n\ \n\ @@ -132,7 +132,7 @@ In this example, x is optimized since it's the first\n\ element of the cell array, y is a fixed constant = 1\n\ \n\ -lbfgsmin(\"f\", {ones(2,1), 1}, [10,2,1,1])\n\ +lbfgsmin(\"f\", {ones(2,1), 1}, {10,2,1,1})\n\ \n\ bfgsmin final results: Iteration 1\n\ Stepsize 0.0000000\n\ Index: bfgsmin-example.m =================================================================== RCS file: /cvsroot/octave/octave-forge/main/optim/bfgsmin-example.m,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- bfgsmin-example.m 26 May 2004 13:28:17 -0000 1.1 +++ bfgsmin-example.m 6 Sep 2004 12:48:49 -0000 1.2 @@ -33,7 +33,7 @@ printf("EXAMPLE 1: Numeric gradient"); x0 = ones(2,1); y0 = 2*ones(2,1); -control = {50,2,1,1}; # maxiters, verbosity, conv. reg., arg_to_min +control = {-1,2,1,1}; # maxiters, verbosity, conv. reg., arg_to_min [theta, obj_value, convergence] = bfgsmin("objective1", {x0, y0}, control); printf("\n"); |