Attached below is a patch to the gsl package for adding the binding for
the bessel_zero_Jnu function of the GSL library.

There must be still several function in GSL library that are not bound in
the gsl package.  I am proposing this patch just because I nedeed the
bessel_zero_Jnu function in my own work.

Note that this patch introduces the new template double_int_to_double,
which may be useful in the future.

All the best,

Rafael
Description: Add binding for the bessel_zero_Jnu function
Author: Rafael Laboissiere <raf...@laboissiere.net>
Last-Update: 2012-05-27

--- octave-gsl-1.0.8.orig/PKG_ADD
+++ octave-gsl-1.0.8/PKG_ADD
@@ -30,6 +30,7 @@ autoload ("bessel_Yn", fullfile (filepar
 autoload ("bessel_Ynu", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
 autoload ("bessel_zero_J0", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
 autoload ("bessel_zero_J1", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
+autoload ("bessel_zero_Jnu", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
 autoload ("beta_gsl", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
 autoload ("Chi", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
 autoload ("Ci", fullfile (fileparts (mfilename ("fullpath")), "gsl_sf.oct"));
--- octave-gsl-1.0.8.orig/src/buildgsl_sf.sh
+++ octave-gsl-1.0.8/src/buildgsl_sf.sh
@@ -1183,6 +1183,17 @@ EOF
 ./replace_template.sh int_int_double_to_double.cc.template >> gsl_sf.cc
 
 
+# (double, int) to double
+
+export octave_name=bessel_zero_Jnu
+export    funcname=gsl_sf_bessel_zero_Jnu
+cat << \EOF > docstring.txt
+These routines compute the location of the n-th positive zero of the
+Bessel function J_x().
+EOF
+./replace_template.sh double_int_to_double.cc.template >> gsl_sf.cc
+
+
 export octave_name=hyperg_U
 export    funcname=gsl_sf_hyperg_U
 cat << \EOF > docstring.txt
--- /dev/null
+++ octave-gsl-1.0.8/src/double_int_to_double.cc.template
@@ -0,0 +1,119 @@
+DEFUN_DLD(GSL_OCTAVE_NAME, args, nargout, "\
+  -*- texinfo -*-\n\
+@deftypefn {Loadable Function} {@var{y} =} GSL_OCTAVE_NAME (@var{x}, @var{n})\n\
+@deftypefnx {Loadable Function} {[@var{y}, @var{err}] =} GSL_OCTAVE_NAME (@dots{})\n\
+\n\
+GSL_FUNC_DOCSTRING
+\n\
+@var{err} contains an estimate of the absolute error in the value @var{y}.\n\
+\n\
+This function is from the GNU Scientific Library,\n\
+see @url{http://www.gnu.org/software/gsl/} for documentation.\n\
+@end deftypefn\n\
+")
+{
+    int i;
+    dim_vector dv;
+    
+    gsl_set_error_handler (octave_gsl_errorhandler);
+    
+    if(args.length() != 2) {
+	print_usage ();
+	return octave_value();
+    }
+    if(!args(0).is_real_type() || !args(1).is_real_type()) {
+        error("The arguments must be real.");
+	print_usage ();	    
+	return octave_value();
+    }
+
+    // Nice combinatorial explosion here
+    NDArray x = args(0).array_value();
+    NDArray n = args(1).array_value();    
+    if(n.length() == x.length()) {
+	dv = x.dims();
+    	NDArray y(dv);
+	int len = x.length();
+	if(nargout < 2) {
+	    for(i = 0; i < len; i++) {
+		y.xelem(i) = GSL_FUNC_NAME (x.xelem(i),
+                                            static_cast<int>(n.xelem(i)));
+	    }
+	    return octave_value(y);	    
+	} else {
+	    NDArray err(dv);
+	    gsl_sf_result result;
+	    octave_value_list retval;
+	    for(i = 0; i < len; i++) {
+		GSL_FUNC_NAME_e (x.xelem(i),
+                                 static_cast<int>(n.xelem(i)), &result);
+		y.xelem(i) = result.val;
+		err.xelem(i) = result.err;
+	    }
+	    retval(1) = octave_value(err);
+	    retval(0) = octave_value(y);
+	    return retval;
+	}
+    } else if(n.length() == 1) {
+	dv = x.dims();
+    	NDArray y(dv);
+	int len = x.length();
+	int nint = static_cast<int>(n.xelem(0));
+	if(nargout < 2) {
+	    for(i = 0; i < len; i++) {
+		y.xelem(i) = GSL_FUNC_NAME (x.xelem(i), nint);
+	    }
+	    return octave_value(y);	    
+	} else {
+	    NDArray err(dv);
+	    gsl_sf_result result;
+	    octave_value_list retval;
+	    for(i = 0; i < len; i++) {
+		GSL_FUNC_NAME_e (x.xelem(i), nint, &result);
+		y.xelem(i) = result.val;
+		err.xelem(i) = result.err;
+	    }
+	    retval(1) = octave_value(err);
+	    retval(0) = octave_value(y);
+	    return retval;
+	}
+    } else if(x.length() == 1) {
+	dv = n.dims();
+    	NDArray y(dv);
+	int len = n.length();
+	double xdouble = x.xelem(0);
+	if(nargout < 2) {
+	    for(i = 0; i < len; i++) {
+		y.xelem(i) = GSL_FUNC_NAME (xdouble,
+                                            static_cast<int>(n.xelem(i)));
+	    }
+	    return octave_value(y);	    
+	} else {
+	    NDArray err(dv);
+	    gsl_sf_result result;
+	    octave_value_list retval;
+	    for(i = 0; i < len; i++) {
+		GSL_FUNC_NAME_e (xdouble,
+                                 static_cast<int>(n.xelem(i)), &result);
+		y.xelem(i) = result.val;
+		err.xelem(i) = result.err;
+	    }
+	    retval(1) = octave_value(err);
+	    retval(0) = octave_value(y);
+	    return retval;
+	}
+    } else {
+	error("First and second argument must either have the same size, or one of them must be scalar.");
+	print_usage ();	
+    }
+
+    return octave_value();
+
+}
+
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to