Mercurial > hg > octave-nkf
changeset 15802:b6b95d041813
maint: merge in Steven's Faddeeva changes
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Mon, 17 Dec 2012 08:59:28 -0500 |
parents | 2e30a1aadff2 (current diff) d9b8333df5e4 (diff) |
children | 9f17e8278540 |
files | |
diffstat | 11 files changed, 277 insertions(+), 80 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/Makefile.am +++ b/libinterp/Makefile.am @@ -291,10 +291,10 @@ if AMCOND_BUILD_DOCS install-data-hook: install-oct install-built-in-docstrings else -install-data-hook: install-oct +install-data-hook: install-oct uninstall-built-in-docstrings endif -uninstall-local: uninstall-oct +uninstall-local: uninstall-oct uninstall-built-in-docstrings if AMCOND_ENABLE_DYNAMIC_LINKING install-oct: @@ -330,8 +330,11 @@ install-built-in-docstrings: $(MKDIR_P) $(DESTDIR)$(octetcdir) $(INSTALL_DATA) DOCSTRINGS $(DESTDIR)$(octetcdir)/built-in-docstrings + +uninstall-built-in-docstrings: + rm -f $(DESTDIR)$(octetcdir)/built-in-docstrings endif -.PHONY: install-built-in-docstrings +.PHONY: install-built-in-docstrings uninstall-built-in-docstrings CLEANFILES = \ $(DLDFCN_PKG_ADD_FILE) \
--- a/libinterp/octave-value/ov-java.cc +++ b/libinterp/octave-value/ov-java.cc @@ -84,9 +84,9 @@ static int octave_java_refcount = 0; static long octave_thread_ID = -1; -bool Vjava_convert_matrix = false; -bool Vjava_unsigned_conversion = true; -bool Vjava_debug = false; +bool Vjava_matrix_autoconversion = false; +bool Vjava_unsigned_autoconversion = true; +bool Vdebug_java = false; class JVMArgs { @@ -130,7 +130,7 @@ if (line.length () > 2 && (line.find ("-D") == 0 || line.find ("-X") == 0)) java_opts.push_back (line); - else if (line.length () > 0 && Vjava_debug) + else if (line.length () > 0 && Vdebug_java) std::cerr << "invalid JVM option, skipping: " << line << std::endl; } } @@ -163,7 +163,7 @@ vm_args.options = new JavaVMOption [vm_args.nOptions]; for (std::list<std::string>::const_iterator it = java_opts.begin (); it != java_opts.end (); ++it) { - if (Vjava_debug) + if (Vdebug_java) std::cout << *it << std::endl; vm_args.options[index++].optionString = strsave ((*it).c_str ()); } @@ -293,19 +293,19 @@ { std::getline (fs, line); - if (line.length () > 1) + if (line.length () > 0) { - if (line.at(0) == '#' || line.at(0) == '%') + if (line[0] == '#' || line[0] == '%') ; // skip comments else { // prepend separator character classpath.append (dir_path::path_sep_str ()); - // append content of line without trailing blanks - int iLast = line.find_last_not_of (' '); + // append content of line without whitespace + int last = line.find_last_not_of (" \t\f\v\r\n"); - classpath.append (file_ops::tilde_expand (line.substr (0, iLast+1))); + classpath.append (file_ops::tilde_expand (line.substr (0, last+1))); } } } @@ -314,7 +314,6 @@ return (classpath); } - static std::string initial_class_path (void) { @@ -336,41 +335,54 @@ // initialize static classpath to octave.jar retval = jar_file; - // The base classpath has been set. Try to find the optional - // file "classpath.txt" in two places. The users classes will - // take precedence over the settings defined in the package - // directory. + // The base classpath has been set. + // Try to find an optional file specifying classpaths in 3 places. + // 1) Current directory + // 2) User's home directory + // 3) Octave installation directory where octave.jar resides - std::string str_filename = "classpath.txt"; - std::string cp_file; - file_stat cp_exists; + // The filename is "javaclasspath.txt", but historically + // has been "classpath.txt" so both are supported. + std::string cp_list[] = {"javaclasspath.txt", "classpath.txt"}; - // Try to read the file "classpath.txt" in the user's home - // directory. - - std::string home_dir = "~" + sep + str_filename; - cp_file = file_ops::tilde_expand (home_dir); - cp_exists = file_stat (cp_file); - if (cp_exists) + for (int i=0; i<2; i++) { - // The file "classpath.txt" has been found: add its - // contents to the static classpath. + std::string filename = cp_list[i]; + std::string cp_file = filename; + file_stat cp_exists; + + // Try to find classpath file in the current directory. - std::string theClassPath = read_classpath_txt (cp_file); - retval.append (theClassPath); - } + cp_exists = file_stat (cp_file); + if (cp_exists) + { + // File found. Add its contents to the static classpath. + std::string classpath = read_classpath_txt (cp_file); + retval.append (classpath); + } - // Try to read a file "classpath.txt" in the package directory. + // Try to find classpath file in the user's home directory. - cp_file = java_dir + sep + str_filename; - cp_exists = file_stat (cp_file); - if (cp_exists) - { - // The file "classpath.txt" has been found: add its - // contents to the static classpath. + cp_file = "~" + sep + filename; + cp_file = file_ops::tilde_expand (cp_file); + cp_exists = file_stat (cp_file); + if (cp_exists) + { + // File found. Add its contents to the static classpath. + std::string classpath = read_classpath_txt (cp_file); + retval.append (classpath); + } - std::string theClassPath = read_classpath_txt (cp_file); - retval.append (theClassPath); + // Try to find classpath file in the Octave install directory. + + cp_file = java_dir + sep + filename; + cp_exists = file_stat (cp_file); + if (cp_exists) + { + // File found. Add its contents to the static classpath. + std::string classpath = read_classpath_txt (cp_file); + retval.append (classpath); + } } } else @@ -618,7 +630,7 @@ if (ex) { - if (Vjava_debug) + if (Vdebug_java) jni_env->ExceptionDescribe (); jni_env->ExceptionClear (); @@ -955,7 +967,7 @@ } } - if (retval.is_undefined () && Vjava_convert_matrix) + if (retval.is_undefined () && Vjava_matrix_autoconversion) { cls = find_octave_class (jni_env, "org/octave/Matrix"); @@ -986,7 +998,7 @@ } else if (s == "byte") { - if (Vjava_unsigned_conversion) + if (Vjava_unsigned_autoconversion) { uint8NDArray m (dims); mID = jni_env->GetMethodID (cls, "toByte", "()[B"); @@ -1005,7 +1017,7 @@ } else if (s == "integer") { - if (Vjava_unsigned_conversion) + if (Vjava_unsigned_autoconversion) { uint32NDArray m (dims); mID = jni_env->GetMethodID (cls, "toInt", "()[I"); @@ -1179,7 +1191,7 @@ //jcls = jni_env->FindClass ("java/lang/Object"); jcls = 0; } - else if (!Vjava_convert_matrix + else if (!Vjava_matrix_autoconversion && ((val.is_real_matrix () && (val.rows () == 1 || val.columns () == 1)) || val.is_range ())) @@ -1191,7 +1203,7 @@ jobj = dv; jcls = jni_env->GetObjectClass (jobj); } - else if (Vjava_convert_matrix + else if (Vjava_matrix_autoconversion && (val.is_matrix_type () || val.is_range ()) && val.is_real_type ()) { jclass_ref mcls (jni_env, find_octave_class (jni_env, "org/octave/Matrix")); @@ -2154,50 +2166,71 @@ #endif } -DEFUN (java_convert_matrix, args, nargout, +DEFUN (java_matrix_autoconversion, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} java_convert_matrix ()\n\ -FIXME: Determine what this variable controls and rename function\n\ -Query or set the internal variable that determines FIXME.\n\ -@seealso{java_unsigned_conversion, java_debug}\n\ +@deftypefn {Built-in Function} {@var{val} =} java_matrix_autoconversion ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} java_matrix_autoconversion (@var{new_val})\n\ +@deftypefnx {Built-in Function} {} java_matrix_autoconversion (@var{new_val}, \"local\")\n\ +Query or set the internal variable that controls whether Java arrays are\n\ +automatically converted to Octave matrices. The default value is false.\n\ +\n\ +When called from inside a function with the \"local\" option, the variable is\n\ +changed locally for the function and any subroutines it calls. The original\n\ +variable value is restored when exiting the function.\n\ +@seealso{java_unsigned_autoconversion, debug_java}\n\ @end deftypefn") { #ifdef HAVE_JAVA - return SET_INTERNAL_VARIABLE (java_convert_matrix); + return SET_INTERNAL_VARIABLE (java_matrix_autoconversion); #else - error ("java_convert_matrix: Octave was not compiled with Java interface"); + error ("java_matrix_autoconversion: Octave was not compiled with Java interface"); return octave_value (); #endif } -DEFUN (java_unsigned_conversion, args, nargout, +DEFUN (java_unsigned_autoconversion, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} java_unsigned_conversion ()\n\ -FIXME: Determine what this variable controls and rename function\n\ -Query or set the internal variable that determines FIXME.\n\ -@seealso{java_convert_matrix, java_debug}\n\ +@deftypefn {Built-in Function} {@var{val} =} java_unsigned_autoconversion ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} java_unsigned_autoconversion (@var{new_val})\n\ +@deftypefnx {Built-in Function} {} java_unsigned_autoconversion (@var{new_val}, \"local\")\n\ +Query or set the internal variable that controls how integer classes are\n\ +converted when Java matrix autoconversion is enabled. When enabled, Java\n\ +arrays of class Byte or Integer are converted to matrices of class uint8 or\n\ +uint32 respectively.\n\ +\n\ +When called from inside a function with the \"local\" option, the variable is\n\ +changed locally for the function and any subroutines it calls. The original\n\ +variable value is restored when exiting the function.\n\ +@seealso{java_matrix_autoconversion, debug_java}\n\ @end deftypefn") { #ifdef HAVE_JAVA - return SET_INTERNAL_VARIABLE (java_unsigned_conversion); + return SET_INTERNAL_VARIABLE (java_unsigned_autoconversion); #else - error ("java_unsigned_conversion: Octave was not compiled with Java interface"); + error ("java_unsigned_autoconversion: Octave was not compiled with Java interface"); return octave_value (); #endif } -DEFUN (java_debug, args, nargout, +DEFUN (debug_java, args, nargout, "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} java_debug ()\n\ -FIXME: Determine what this variable controls and rename function\n\ -Query or set the internal variable that determines FIXME.\n\ -@seealso{java_convert_matrix, java_unsigned_conversion}\n\ +@deftypefn {Built-in Function} {@var{val} =} debug_java ()\n\ +@deftypefnx {Built-in Function} {@var{old_val} =} debug_java (@var{new_val})\n\ +@deftypefnx {Built-in Function} {} debug_java (@var{new_val}, \"local\")\n\ +Query or set the internal variable that determines whether extra debugging\n\ +information regarding the initialization of the JVM and any Java exceptions\n\ +is printed.\n\ +\n\ +When called from inside a function with the \"local\" option, the variable is\n\ +changed locally for the function and any subroutines it calls. The original\n\ +variable value is restored when exiting the function.\n\ +@seealso{java_matrix_autoconversion, java_unsigned_autoconversion}\n\ @end deftypefn") { #ifdef HAVE_JAVA - return SET_INTERNAL_VARIABLE (java_debug); + return SET_INTERNAL_VARIABLE (debug_java); #else - error ("java_debug: Octave was not compiled with Java interface"); + error ("debug_java: Octave was not compiled with Java interface"); return octave_value (); #endif }
--- a/libinterp/octave-value/ov-java.h +++ b/libinterp/octave-value/ov-java.h @@ -109,11 +109,11 @@ unbox (JNIEnv* jni_env, const octave_value_list& args, jobjectArray_ref& jobjs, jobjectArray_ref& jclss); -extern JAVAPKG_API bool Vjava_convert_matrix; +extern JAVAPKG_API bool Vjava_matrix_autoconversion; -extern JAVAPKG_API bool Vjava_unsigned_conversion; +extern JAVAPKG_API bool Vjava_unsigned_autoconversion; -extern JAVAPKG_API bool Vjava_debug; +extern JAVAPKG_API bool Vdebug_java; class JAVAPKG_API octave_java : public octave_base_value {
new file mode 100644 --- /dev/null +++ b/scripts/deprecated/java_convert_matrix.m @@ -0,0 +1,48 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {@var{val} =} java_convert_matrix () +## @deftypefnx {Built-in Function} {@var{old_val} =} java_convert_matrix (@var{new_val}) +## @deftypefnx {Built-in Function} {} java_convert_matrix (@var{new_val}, \"local\") +## Query or set the internal variable that controls whether Java arrays are +## automatically converted to Octave matrices. The default value is false. +## +## When called from inside a function with the \"local\" option, the variable is +## changed locally for the function and any subroutines it calls. The original +## variable value is restored when exiting the function. +## @seealso{java_matrix_autoconversion, java_unsigned_conversion, java_debug} +## @end deftypefn + +function old_val = java_convert_matrix (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "java_convert_matrix is obsolete and will be removed from a future version of Octave; use java_matrix_autoconversion instead"); + endif + + if (nargin > 2) + print_usage (); + endif + + old_val = java_matrix_autoconversion (varargin{:}); + +endfunction +
new file mode 100644 --- /dev/null +++ b/scripts/deprecated/java_debug.m @@ -0,0 +1,49 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {@var{val} =} java_debug () +## @deftypefnx {Built-in Function} {@var{old_val} =} java_debug (@var{new_val}) +## @deftypefnx {Built-in Function} {} java_debug (@var{new_val}, \"local\") +## Query or set the internal variable that determines whether extra debugging +## information regarding the initialization of the JVM and any Java exceptions +## is printed. +## +## When called from inside a function with the \"local\" option, the variable is +## changed locally for the function and any subroutines it calls. The original +## variable value is restored when exiting the function. +## @seealso{debug_java, java_convert_matrix, java_unsigned_conversion} +## @end deftypefn + +function old_val = java_debug (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "java_debug is obsolete and will be removed from a future version of Octave; use debug_java instead"); + endif + + if (nargin > 2) + print_usage (); + endif + + old_val = debug_java (varargin{:}); + +endfunction +
--- a/scripts/deprecated/java_invoke.m +++ b/scripts/deprecated/java_invoke.m @@ -51,7 +51,7 @@ print_usage (); endif - retval = javaMethod (methodname, obj, varargin); + retval = javaMethod (methodname, obj, varargin{:}); endfunction
--- a/scripts/deprecated/java_new.m +++ b/scripts/deprecated/java_new.m @@ -45,7 +45,7 @@ print_usage (); endif - retval = javaObject (varargin); + retval = javaObject (varargin{:}); endfunction
new file mode 100644 --- /dev/null +++ b/scripts/deprecated/java_unsigned_conversion.m @@ -0,0 +1,50 @@ +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Built-in Function} {@var{val} =} java_unsigned_conversion () +## @deftypefnx {Built-in Function} {@var{old_val} =} java_unsigned_conversion (@var{new_val}) +## @deftypefnx {Built-in Function} {} java_unsigned_conversion (@var{new_val}, \"local\") +## Query or set the internal variable that controls how integer classes are +## converted when Java matrix autoconversion is enabled. When enabled, Java +## arrays of class Byte or Integer are converted to matrices of class uint8 or +## uint32 respectively. +## +## When called from inside a function with the \"local\" option, the variable is +## changed locally for the function and any subroutines it calls. The original +## variable value is restored when exiting the function. +## @seealso{java_unsigned_autoconversion, java_convert_matrix, debug_java} +## @end deftypefn + +function old_val = java_unsigned_conversion (varargin) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "java_unsigned_conversion is obsolete and will be removed from a future version of Octave; use java_unsigned_autoconversion instead"); + endif + + if (nargin > 2) + print_usage (); + endif + + old_val = java_unsigned_autoconversion (varargin{:}); + +endfunction +
--- a/scripts/deprecated/module.mk +++ b/scripts/deprecated/module.mk @@ -5,11 +5,14 @@ deprecated/cor.m \ deprecated/corrcoef.m \ deprecated/cut.m \ + deprecated/java_debug.m \ deprecated/error_text.m \ deprecated/isstr.m \ + deprecated/java_convert_matrix.m \ deprecated/java_get.m \ deprecated/java_invoke.m \ deprecated/java_new.m \ + deprecated/java_unsigned_conversion.m \ deprecated/java_set.m \ deprecated/javafields.m \ deprecated/javamethods.m \
--- a/scripts/general/logspace.m +++ b/scripts/general/logspace.m @@ -85,10 +85,10 @@ %! x2 = logspace (1, 2, 10.1); %! x3 = logspace (1, -2, 10); %! x4 = logspace (1, pi, 10); -%! assert (size (x1) == [1, 50] && x1(1) == 10 && x1(50) == 100); -%! assert (size (x2) == [1, 10] && x2(1) == 10 && x2(10) == 100); -%! assert (size (x3) == [1, 10] && x3(1) == 10 && x3(10) == 0.01); -%! assert (size (x4) == [1, 10] && x4(1) == 10 && abs (x4(10) - pi) < sqrt (eps)); +%! assert (size (x1) == [1, 50] && abs (x1(1) - 10) < eps && abs (x1(50) - 100) < eps); +%! assert (size (x2) == [1, 10] && abs (x2(1) - 10) < eps && abs (x2(10) - 100) < eps); +%! assert (size (x3) == [1, 10] && abs (x3(1) - 10) < eps && abs (x3(10) - 0.01) < eps); +%! assert (size (x4) == [1, 10] && abs (x4(1) - 10) < eps && abs (x4(10) - pi) < sqrt (eps)); %% Test input validation %!error logspace ()
--- a/scripts/plot/struct2hdl.m +++ b/scripts/plot/struct2hdl.m @@ -92,12 +92,23 @@ p = p(1:2, 1:(tst(end)-1)); endif - ## Place the "*mode" properties as the end to avoid have the updaters - ## change the mode to "manual" when the value is "auto" + ## Place the "*mode" properties as the end to avoid having the updaters + ## change the mode to "manual" when the value is "auto". names = fieldnames (s.properties); n = strncmp (cellfun (@fliplr, names, "uniformoutput", false), "edom", 4); n = (n | strcmp (names, "activepositionproperty")); names = [names(!n); names(n)]; + if (strcmp (s.type, "axes")) + n_pos = find (strcmp (names, "position") | strcmp (names, "outerposition")); + if (strcmp (s.properties.activepositionproperty, "position")) + names{n_pos(1)} = "outerposition"; + names{n_pos(2)} = "position"; + else + names{n_pos(1)} = "position"; + names{n_pos(2)} = "outerposition"; + endif + endif + ## Reorder the properties with the mode properties coming last s.properties = orderfields (s.properties, names); ## create object