Mercurial > hg > octave-nkf
changeset 4469:53ee020af847
[project @ 2003-07-26 03:45:10 by jwe]
author | jwe |
---|---|
date | Sat, 26 Jul 2003 03:45:11 +0000 |
parents | efb6301dae80 |
children | e606bf485c1c |
files | ChangeLog configure.in liboctave/CMatrix.cc liboctave/ChangeLog liboctave/dMatrix.cc liboctave/lo-cieee.c liboctave/lo-mappers.cc liboctave/lo-mappers.h scripts/ChangeLog scripts/audio/playaudio.m scripts/audio/record.m scripts/image/image.m scripts/miscellaneous/bug_report.m scripts/signal/autocov.m src/ChangeLog src/help.cc src/oct-hist.cc src/pt-plot.cc |
diffstat | 18 files changed, 353 insertions(+), 220 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-07-25 John W. Eaton <jwe@bevo.che.wisc.edu> + + * configure.in: Warn if --enable-dl but not --enable-shared. + 2003-07-15 John W. Eaton <jwe@bevo.che.wisc.edu> * emacs/octave-mod.el (octave-variables): Delete
--- a/configure.in +++ b/configure.in @@ -22,7 +22,7 @@ ### 02111-1307, USA. AC_INIT -AC_REVISION($Revision: 1.430 $) +AC_REVISION($Revision: 1.431 $) AC_PREREQ(2.52) AC_CONFIG_SRCDIR([src/octave.cc]) AC_CONFIG_HEADER(config.h) @@ -1471,6 +1471,16 @@ warn_msg_printed=false +if $ENABLE_DYNAMIC_LINKING; then + if $SHARED_LIBS; then + true + else + AC_MSG_WARN([You used --enable-dl but not --enable-shared.]) + AC_MSG_WARN([Are you sure that is what you want to do?]) + warn_msg_printed=true + fi +fi + if test -n "$warn_f77_and_g77"; then AC_MSG_WARN($warn_f77_and_g77) warn_msg_printed=true
--- a/liboctave/CMatrix.cc +++ b/liboctave/CMatrix.cc @@ -2756,38 +2756,50 @@ for (int i = 0; i < nr; i++) { - int idx_j = 0; - - Complex tmp_min = elem (i, idx_j); - bool real_only = row_is_real_only (i); - double abs_min = real_only ? real (tmp_min) : ::abs (tmp_min); - - if (xisnan (tmp_min)) - idx_j = -1; + int idx_j; + + Complex tmp_min; + + double abs_min = octave_NaN; + + for (idx_j = 0; idx_j < nc; idx_j++) + { + tmp_min = elem (i, idx_j); + + if (! octave_is_NaN_or_NA (tmp_min)) + { + abs_min = real_only ? real (tmp_min) : ::abs (tmp_min); + break; + } + } + + for (int j = idx_j+1; j < nc; j++) + { + Complex tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + + double abs_tmp = real_only ? real (tmp) : ::abs (tmp); + + if (abs_tmp < abs_min) + { + idx_j = j; + tmp_min = tmp; + abs_min = abs_tmp; + } + } + + if (octave_is_NaN_or_NA (tmp_min)) + { + result.elem (i) = Complex_NaN_result; + index.elem (i) = 0; + } else { - for (int j = 1; j < nc; j++) - { - Complex tmp = elem (i, j); - - double abs_tmp = real_only ? real (tmp) : ::abs (tmp); - - if (xisnan (tmp)) - { - idx_j = -1; - break; - } - else if (abs_tmp < abs_min) - { - idx_j = j; - tmp_min = tmp; - abs_min = abs_tmp; - } - } - - result.elem (i) = (idx_j < 0) ? Complex_NaN_result : tmp_min; + result.elem (i) = tmp_min; index.elem (i) = idx_j; } } @@ -2818,38 +2830,50 @@ for (int i = 0; i < nr; i++) { - int idx_j = 0; - - Complex tmp_max = elem (i, idx_j); - bool real_only = row_is_real_only (i); - double abs_max = real_only ? real (tmp_max) : ::abs (tmp_max); - - if (xisnan (tmp_max)) - idx_j = -1; + int idx_j; + + Complex tmp_max; + + double abs_max = octave_NaN; + + for (idx_j = 0; idx_j < nc; idx_j++) + { + tmp_max = elem (i, idx_j); + + if (! octave_is_NaN_or_NA (tmp_max)) + { + abs_max = real_only ? real (tmp_max) : ::abs (tmp_max); + break; + } + } + + for (int j = idx_j+1; j < nc; j++) + { + Complex tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + + double abs_tmp = real_only ? real (tmp) : ::abs (tmp); + + if (abs_tmp > abs_max) + { + idx_j = j; + tmp_max = tmp; + abs_max = abs_tmp; + } + } + + if (octave_is_NaN_or_NA (tmp_max)) + { + result.elem (i) = Complex_NaN_result; + index.elem (i) = 0; + } else { - for (int j = 1; j < nc; j++) - { - Complex tmp = elem (i, j); - - double abs_tmp = real_only ? real (tmp) : ::abs (tmp); - - if (xisnan (tmp)) - { - idx_j = -1; - break; - } - else if (abs_tmp > abs_max) - { - idx_j = j; - tmp_max = tmp; - abs_max = abs_tmp; - } - } - - result.elem (i) = (idx_j < 0) ? Complex_NaN_result : tmp_max; + result.elem (i) = tmp_max; index.elem (i) = idx_j; } } @@ -2880,38 +2904,50 @@ for (int j = 0; j < nc; j++) { - int idx_i = 0; - - Complex tmp_min = elem (idx_i, j); - bool real_only = column_is_real_only (j); - double abs_min = real_only ? real (tmp_min) : ::abs (tmp_min); - - if (xisnan (tmp_min)) - idx_i = -1; + int idx_i; + + Complex tmp_min; + + double abs_min = octave_NaN; + + for (idx_i = 0; idx_i < nr; idx_i++) + { + tmp_min = elem (idx_i, j); + + if (! octave_is_NaN_or_NA (tmp_min)) + { + abs_min = real_only ? real (tmp_min) : ::abs (tmp_min); + break; + } + } + + for (int i = idx_i+1; i < nr; i++) + { + Complex tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + + double abs_tmp = real_only ? real (tmp) : ::abs (tmp); + + if (abs_tmp < abs_min) + { + idx_i = i; + tmp_min = tmp; + abs_min = abs_tmp; + } + } + + if (octave_is_NaN_or_NA (tmp_min)) + { + result.elem (j) = Complex_NaN_result; + index.elem (j) = 0; + } else { - for (int i = 1; i < nr; i++) - { - Complex tmp = elem (i, j); - - double abs_tmp = real_only ? real (tmp) : ::abs (tmp); - - if (xisnan (tmp)) - { - idx_i = -1; - break; - } - else if (abs_tmp < abs_min) - { - idx_i = i; - tmp_min = tmp; - abs_min = abs_tmp; - } - } - - result.elem (j) = (idx_i < 0) ? Complex_NaN_result : tmp_min; + result.elem (j) = tmp_min; index.elem (j) = idx_i; } } @@ -2942,38 +2978,50 @@ for (int j = 0; j < nc; j++) { - int idx_i = 0; - - Complex tmp_max = elem (idx_i, j); - bool real_only = column_is_real_only (j); - double abs_max = real_only ? real (tmp_max) : ::abs (tmp_max); - - if (xisnan (tmp_max)) - idx_i = -1; + int idx_i; + + Complex tmp_max; + + double abs_max = octave_NaN; + + for (idx_i = 0; idx_i < nr; idx_i++) + { + tmp_max = elem (idx_i, j); + + if (! octave_is_NaN_or_NA (tmp_max)) + { + abs_max = real_only ? real (tmp_max) : ::abs (tmp_max); + break; + } + } + + for (int i = idx_i+1; i < nr; i++) + { + Complex tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + + double abs_tmp = real_only ? real (tmp) : ::abs (tmp); + + if (abs_tmp > abs_max) + { + idx_i = i; + tmp_max = tmp; + abs_max = abs_tmp; + } + } + + if (octave_is_NaN_or_NA (tmp_max)) + { + result.elem (j) = Complex_NaN_result; + index.elem (j) = 0; + } else { - for (int i = 1; i < nr; i++) - { - Complex tmp = elem (i, j); - - double abs_tmp = real_only ? real (tmp) : ::abs (tmp); - - if (xisnan (tmp)) - { - idx_i = -1; - break; - } - else if (abs_tmp > abs_max) - { - idx_i = i; - tmp_max = tmp; - abs_max = abs_tmp; - } - } - - result.elem (j) = (idx_i < 0) ? Complex_NaN_result : tmp_max; + result.elem (j) = tmp_max; index.elem (j) = idx_i; } }
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,19 @@ +2003-07-25 John W. Eaton <jwe@bevo.che.wisc.edu> + + * lo-mappers.cc (xmin, xmax): Handle NaN in a Matlab-compatible + way. Handle NA in an R-compatible way. + + * lo-cieee.c (lo_ieee_is_NaN_or_NA): Also check for lo_ieee_is_NA. + (lo_ieee_is_NA): Don't call isnan unless HAVE_ISNAN is defined. + + * lo-mappers.h (octave_is_NA (const Complex&)): Provide decl. + (octave_is_NaN_or_NA (const Complex&)): Likewise. + + * dMatrix.cc (Matrix::row_min, Matrix::row_max, + Matrix::column_min, Matrix::column_max): Ignore NaNs. + * CMatrix.cc (ComplexMatrix::row_min, ComplexMatrix::row_max, + ComplexMatrix::column_min, ComplexMatrix::column_max): Likewise. + 2003-07-11 John W. Eaton <jwe@bevo.che.wisc.edu> * Array2-idx.h (assign (Array2<LT>&, const Array2<RT>&, const LT&)):
--- a/liboctave/dMatrix.cc +++ b/liboctave/dMatrix.cc @@ -2235,33 +2235,33 @@ for (int i = 0; i < nr; i++) { - int idx_j = 0; - - double tmp_min = elem (i, idx_j); - - if (xisnan (tmp_min)) - idx_j = -1; - else + int idx_j; + + double tmp_min = octave_NaN; + + for (idx_j = 0; idx_j < nc; idx_j++) { - for (int j = 1; j < nc; j++) + tmp_min = elem (i, idx_j); + + if (! octave_is_NaN_or_NA (tmp_min)) + break; + } + + for (int j = idx_j+1; j < nc; j++) + { + double tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + else if (tmp < tmp_min) { - double tmp = elem (i, j); - - if (xisnan (tmp)) - { - idx_j = -1; - break; - } - else if (tmp < tmp_min) - { - idx_j = j; - tmp_min = tmp; - } + idx_j = j; + tmp_min = tmp; } } - result.elem (i) = (idx_j < 0) ? octave_NaN : tmp_min; - index.elem (i) = idx_j; + result.elem (i) = tmp_min; + index.elem (i) = octave_is_NaN_or_NA (tmp_min) ? 0 : idx_j; } } @@ -2290,33 +2290,33 @@ for (int i = 0; i < nr; i++) { - int idx_j = 0; - - double tmp_max = elem (i, idx_j); - - if (xisnan (tmp_max)) - idx_j = -1; - else + int idx_j; + + double tmp_max = octave_NaN; + + for (idx_j = 0; idx_j < nc; idx_j++) { - for (int j = 1; j < nc; j++) + tmp_max = elem (i, idx_j); + + if (! octave_is_NaN_or_NA (tmp_max)) + break; + } + + for (int j = idx_j+1; j < nc; j++) + { + double tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + else if (tmp > tmp_max) { - double tmp = elem (i, j); - - if (xisnan (tmp)) - { - idx_j = -1; - break; - } - else if (tmp > tmp_max) - { - idx_j = j; - tmp_max = tmp; - } + idx_j = j; + tmp_max = tmp; } } - result.elem (i) = (idx_j < 0) ? octave_NaN : tmp_max; - index.elem (i) = idx_j; + result.elem (i) = tmp_max; + index.elem (i) = octave_is_NaN_or_NA (tmp_max) ? 0 : idx_j; } } @@ -2345,33 +2345,33 @@ for (int j = 0; j < nc; j++) { - int idx_i = 0; - - double tmp_min = elem (idx_i, j); - - if (xisnan (tmp_min)) - idx_i = -1; - else + int idx_i; + + double tmp_min = octave_NaN; + + for (idx_i = 0; idx_i < nr; idx_i++) { - for (int i = 1; i < nr; i++) + tmp_min = elem (idx_i, j); + + if (! octave_is_NaN_or_NA (tmp_min)) + break; + } + + for (int i = idx_i+1; i < nr; i++) + { + double tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + else if (tmp < tmp_min) { - double tmp = elem (i, j); - - if (xisnan (tmp)) - { - idx_i = -1; - break; - } - else if (tmp < tmp_min) - { - idx_i = i; - tmp_min = tmp; - } + idx_i = i; + tmp_min = tmp; } } - result.elem (j) = (idx_i < 0) ? octave_NaN : tmp_min; - index.elem (j) = idx_i; + result.elem (j) = tmp_min; + index.elem (j) = octave_is_NaN_or_NA (tmp_min) ? 0 : idx_i; } } @@ -2400,33 +2400,33 @@ for (int j = 0; j < nc; j++) { - int idx_i = 0; - - double tmp_max = elem (idx_i, j); - - if (xisnan (tmp_max)) - idx_i = -1; - else + int idx_i; + + double tmp_max = octave_NaN; + + for (idx_i = 0; idx_i < nr; idx_i++) { - for (int i = 1; i < nr; i++) + tmp_max = elem (idx_i, j); + + if (! octave_is_NaN_or_NA (tmp_max)) + break; + } + + for (int i = idx_i+1; i < nr; i++) + { + double tmp = elem (i, j); + + if (octave_is_NaN_or_NA (tmp)) + continue; + else if (tmp > tmp_max) { - double tmp = elem (i, j); - - if (xisnan (tmp)) - { - idx_i = -1; - break; - } - else if (tmp > tmp_max) - { - idx_i = i; - tmp_max = tmp; - } + idx_i = i; + tmp_max = tmp; } } - result.elem (j) = (idx_i < 0) ? octave_NaN : tmp_max; - index.elem (j) = idx_i; + result.elem (j) = tmp_max; + index.elem (j) = octave_is_NaN_or_NA (tmp_max) ? 0 : idx_i; } }
--- a/liboctave/lo-cieee.c +++ b/liboctave/lo-cieee.c @@ -117,15 +117,22 @@ int lo_ieee_is_NA (double x) { +#if defined HAVE_ISNAN lo_ieee_double t; t.value = x; return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; +#else + return 0; +#endif } int lo_ieee_is_NaN_or_NA (double x) { - return lo_ieee_isnan (x); + // Although NA really is an IEEE NaN value, lo_ieee_isnan pretends + // it is not, so we much check both... + + return lo_ieee_isnan (x) || lo_ieee_is_NA (x); } double
--- a/liboctave/lo-mappers.cc +++ b/liboctave/lo-mappers.cc @@ -133,13 +133,39 @@ double xmin (double x, double y) { - return x < y ? x : (xisnan (x) ? x : y); + if (x < y) + return x; + + if (y <= x) + return y; + + if (octave_is_NaN_or_NA (x) && ! octave_is_NaN_or_NA (y)) + return y; + else if (octave_is_NaN_or_NA (y) && ! octave_is_NaN_or_NA (x)) + return x; + else if (octave_is_NA (x) || octave_is_NA (y)) + return octave_NA; + else + return octave_NaN; } double xmax (double x, double y) { - return x > y ? x : (xisnan (x) ? x : y); + if (x > y) + return x; + + if (y >= x) + return y; + + if (octave_is_NaN_or_NA (x) && ! octave_is_NaN_or_NA (y)) + return y; + else if (octave_is_NaN_or_NA (y) && ! octave_is_NaN_or_NA (x)) + return x; + else if (octave_is_NA (x) || octave_is_NA (y)) + return octave_NA; + else + return octave_NaN; } // complex -> complex mappers.
--- a/liboctave/lo-mappers.h +++ b/liboctave/lo-mappers.h @@ -66,6 +66,9 @@ extern bool xfinite (const Complex& x); extern bool xisinf (const Complex& x); +extern bool octave_is_NA (const Complex& x); +extern bool octave_is_NaN_or_NA (const Complex& x); + extern Complex xmin (const Complex& x, const Complex& y); extern Complex xmax (const Complex& x, const Complex& y);
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,12 @@ +2003-07-25 Paul Kienzle <pkienzle@users.sf.net> + + * signal/autocov.m: Transpose result of conj because diag returns + a column vector, not a row vector. + + * audio/playaudio.m, audio/record.m, image/image.m, + miscellaneous/bug_report.m: Protect spaces in filenames + with quotes. + 2003-07-15 John W. Eaton <jwe@bevo.che.wisc.edu> * io/printf.m, io/puts.m: Delete.
--- a/scripts/audio/playaudio.m +++ b/scripts/audio/playaudio.m @@ -50,7 +50,7 @@ num = fopen (file, "wb"); c = fwrite (num, X, "uchar"); fclose (num); - system (sprintf ("cat %s > /dev/dsp", file)); + system (sprintf ("cat \"%s\" > /dev/dsp", file)); unwind_protect_cleanup unlink (file); end_unwind_protect @@ -64,10 +64,10 @@ usage (usage_msg); endif if (strcmp (ext, "lin") || strcmp (ext, "raw")) - system (sprintf ("cat %s > /dev/dsp", name)); + system (sprintf ("cat \"%s\" > /dev/dsp", name)); elseif (strcmp (ext, "mu") || strcmp (ext, "au") || strcmp (ext, "snd") || strcmp (ext, "ul")) - system (sprintf ("cat %s > /dev/audio", name)); + system (sprintf ("cat \"%s\" > /dev/audio", name)); else error ("playaudio does not support given extension"); endif
--- a/scripts/audio/record.m +++ b/scripts/audio/record.m @@ -44,7 +44,7 @@ input ("Please hit ENTER and speak afterwards!\n", 1); - cmd = sprintf ("dd if=/dev/dsp of=%s bs=%d count=%d", + cmd = sprintf ("dd if=/dev/dsp of=\"%s\" bs=%d count=%d", file, sampling_rate, sec) system (cmd);
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -73,14 +73,14 @@ ## Start the viewer. Try display, xv, then xloadimage. - xv = sprintf ("xv -raw -expand %f %s", zoom, ppm_name); + xv = sprintf ("xv -raw -expand %f \"%s\"", zoom, ppm_name); - xloadimage = sprintf ("xloadimage -zoom %f %s", zoom*100, ppm_name); + xloadimage = sprintf ("xloadimage -zoom %f \"%s\"", zoom*100, ppm_name); ## ImageMagick: - im_display = sprintf ("display -geometry %f%% %s", zoom*100, ppm_name); + im_display = sprintf ("display -geometry %f%% \"%s\"", zoom*100, ppm_name); - rm = sprintf ("rm -f %s", ppm_name); + rm = sprintf ("rm -f \"%s\"", ppm_name); ## Need to let the shell clean up the tmp file because we are putting ## the viewer in the background.
--- a/scripts/miscellaneous/bug_report.m +++ b/scripts/miscellaneous/bug_report.m @@ -57,7 +57,7 @@ endif if (! isempty (prefs)) - cmd = sprintf ("%s %s", cmd, prefs); + cmd = sprintf ("%s \"%s\"", cmd, prefs); endif system (cmd);
--- a/scripts/signal/autocov.m +++ b/scripts/signal/autocov.m @@ -47,7 +47,7 @@ retval = zeros (h + 1, c); for i = 0 : h - retval(i+1, :) = diag (X(i+1:n, :).' * conj (X(1:n-i, :))) / n; + retval(i+1, :) = diag (X(i+1:n, :).' * conj (X(1:n-i, :))).' / n; endfor endfunction
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2003-07-25 Paul Kienzle <pkienzle@users.sf.net> + + * help.cc (try_info, display_help_text): + Protect spaces in filenames with quotes. + * oct-hist.cc (do_edit_history): Likewise. + * pt-plot.cc (open_plot_stream): Likewise. + 2003-07-15 John W. Eaton <jwe@bevo.che.wisc.edu> * oct-stream.cc (get_size, octave_base_stream::error,
--- a/src/help.cc +++ b/src/help.cc @@ -508,7 +508,7 @@ OSSTREAM cmd_buf; - cmd_buf << Vinfo_prog << " --file " << Vinfo_file; + cmd_buf << "\"" << Vinfo_prog << "\" --file \"" << Vinfo_file << "\""; std::string directory_name = Vinfo_file; size_t pos = directory_name.rfind ('/'); @@ -516,7 +516,7 @@ if (pos != NPOS) { directory_name.resize (pos + 1); - cmd_buf << " --directory " << directory_name; + cmd_buf << " --directory \"" << directory_name << "\""; } if (nm.length () > 0) @@ -613,7 +613,7 @@ OSSTREAM buf; buf << "sed -e 's/^[#%][#%]* *//' -e 's/^ *@/@/' | " - << Vmakeinfo_prog + << "\"" << Vmakeinfo_prog << "\"" << " -D \"VERSION " << OCTAVE_VERSION << "\"" << " -D \"OCTAVEHOME " << OCTAVE_PREFIX << "\"" << " -D \"TARGETHOSTTYPE " << OCTAVE_CANONICAL_HOST_TYPE << "\""
--- a/src/oct-hist.cc +++ b/src/oct-hist.cc @@ -440,8 +440,9 @@ // Call up our favorite editor on the file of commands. std::string cmd = Veditor; - cmd.append (" "); + cmd.append (" \""); cmd.append (name); + cmd.append ("\""); // Ignore interrupts while we are off editing commands. Should we // maybe avoid using system()?
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -132,10 +132,12 @@ plot_line_count = 0; - std::string plot_prog = Vgnuplot_binary; + std::string plot_prog; - if (plot_prog.empty ()) + if (Vgnuplot_binary.empty ()) plot_prog = "gnuplot"; + else + plot_prog = "\"" + Vgnuplot_binary + "\""; // XXX FIXME XXX -- I'm not sure this is the right thing to do, // but without it, C-c at the octave prompt will kill gnuplot...