Mercurial > hg > octave-nkf
changeset 3105:f936c7f5074f
[project @ 1997-11-19 04:36:17 by jwe]
author | jwe |
---|---|
date | Wed, 19 Nov 1997 04:37:56 +0000 |
parents | b9aea66ecbae |
children | 21208b797332 |
files | ChangeLog NEWS PROJECTS configure.in scripts/polynomial/polyfit.m src/ChangeLog src/lex.l src/octave.cc src/pr-output.cc src/utils.cc test/octave.test/arith/sumsq-1.m test/octave.test/arith/sumsq-2.m |
diffstat | 12 files changed, 262 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Oct 20 01:31:45 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + + * configure.in: Reprint important warning messages at the end of + the run. + Fri Oct 17 04:43:27 1997 John W. Eaton <jwe@bevo.che.wisc.edu> * Include the following change from RMS for octave-mode.el:
--- a/NEWS +++ b/NEWS @@ -151,6 +151,12 @@ * Structure elements completion on the command line actually works now. + * The new built-in variable `fixed_point_format' controls whether + Octave uses a scaled fixed-point format for displaying matrices. + The default value is 0 unless you use --traditional. + + * The function sumsq now computes sum (x .* conj (x)) for complex values. + * New configure option, --enable-readline. * New configure option, --enable-static.
--- a/PROJECTS +++ b/PROJECTS @@ -234,6 +234,8 @@ * Make it possible to tie arbitrary input and output streams together, similar to the way iostreams can be tied together. + * Allow comments in number-only data files. + ----------- Interpreter: -----------
--- a/configure.in +++ b/configure.in @@ -21,7 +21,7 @@ ### Software Foundation, 59 Temple Place - Suite 330, Boston, MA ### 02111-1307, USA. -AC_REVISION($Revision: 1.285 $) +AC_REVISION($Revision: 1.286 $) AC_PREREQ(2.9) AC_INIT(src/octave.cc) AC_CONFIG_HEADER(config.h) @@ -88,15 +88,18 @@ ### specified (multiple "no" or --without-FOO options are ok). OCTAVE_CHECK_EXCLUSIVE_WITH_OPTIONS(f77, g77, - [AC_MSG_WARN([--with-f77 and --with-g77 both specified! Using g77...]) + [warn_f77_and_g77="--with-f77 and --with-g77 both specified! Using g77..." + AC_MSG_WARN($warn_f77_and_g77) use_g77=false]) OCTAVE_CHECK_EXCLUSIVE_WITH_OPTIONS(f77, f2c, - [AC_MSG_WARN([--with-f2c and --with-f77 both specified! Using f77...]) + [warn_f2c_and_f77="--with-f2c and --with-f77 both specified! Using f77..." + AC_MSG_WARN($warn_f2c_and_f77) use_f2c=false]) OCTAVE_CHECK_EXCLUSIVE_WITH_OPTIONS(g77, f2c, - [AC_MSG_WARN([--with-f2c and --with-g77 both specified! Using g77...]) + [warn_f2c_and_g77="--with-f2c and --with-g77 both specified! Using g77..." + AC_MSG_WARN($warn_f2c_and_g77) use_f2c=false]) ### Allow the user disable support for GNU info. @@ -198,7 +201,8 @@ AC_MSG_ERROR([g++ version $gxx_version will not work to compile Octave]) ;; *) - AC_MSG_WARN([Octave has only been tested with g++, and I can't find it]) + warn_gxx_only="Octave has only been tested with g++, and I can't find it" + AC_MSG_WARN($warn_gxx_only) ;; esac @@ -247,10 +251,12 @@ fi ;; 1.*) - AC_MSG_WARN([gcc version $gcc_version is likely to cause problems]) + warn_gcc_version="gcc version $gcc_version is likely to cause problems" + AC_MSG_WARN($warn_gcc_version) ;; *) - AC_MSG_WARN([Octave has only been tested with gcc, and I can't find it]) + warn_gcc_only="Octave has only been tested with gcc, and I can't find it" + AC_MSG_WARN($warn_gcc_only) ;; esac @@ -468,7 +474,8 @@ fi if test -z "$FLIBS"; then - AC_MSG_WARN([I found f2c but not libf2c.a, or libF77.a and libI77.a]) + warn_f2c_no_lib="I found f2c but not libf2c.a, or libF77.a and libI77.a" + AC_MSG_WARN($warn_f2c_no_lib) fi f77_rules_frag=Makefrag.f77 cat << \EOF > $f77_rules_frag @@ -921,7 +928,8 @@ || test "$ac_cv_lib_termlib_tputs" = yes; then true else - AC_MSG_WARN([I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, or -ltermlib!]) + warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, or -ltermlib!" + AC_MSG_WARN($warn_termlibs) fi AC_MSG_CHECKING([for struct exception in math.h]) @@ -1022,8 +1030,8 @@ *) LFLAGS="-t" AC_MSG_RESULT([defining LFLAGS to be $LFLAGS]) - AC_MSG_WARN([I didn't find flex, but that's only a problem]) - AC_MSG_WARN([if you need to reconstruct lex.cc]) + warn_flex="I didn't find flex, but it's only a problem if you need to reconstruct lex.cc" + AC_MSG_WARN($warn_flex) ;; esac AC_SUBST(LFLAGS) @@ -1033,17 +1041,17 @@ bison*) ;; *) - AC_MSG_WARN([I didn't find bison, but that's only a problem]) - AC_MSG_WARN([if you need to reconstruct parse.cc]) + warn_bison="I didn't find bison, but it's only a problem if you need to reconstruct parse.cc" + AC_MSG_WARN($warn_bison) ;; esac AC_PROG_LN_S AC_CHECK_PROG(RUNTEST, runtest, runtest, []) -AC_CHECK_PROG(EXPECT, expect, expect, []) -if test -z "$EXPECT"; then - RUNTEST= +if test -z "$RUNTEST"; then + warn_runtest="I didn't find runtest -- install DejaGNU if you want to run \`make check'" + AC_MSG_WARN($warn_runtest) fi AC_SUBST(RUNTEST) @@ -1077,6 +1085,11 @@ AC_MSG_RESULT([no]) fi else + warn_gnuplot="yes" + + ## If you change this text, be sure to also copy it to the set of + ## warnings at the end of the script + AC_MSG_WARN([I didn't find gnuplot. It isn't necessary to have gnuplot]) AC_MSG_WARN([installed, but you won't be able to use any of Octave's]) AC_MSG_WARN([plotting commands without it.]) @@ -1098,7 +1111,8 @@ AC_CHECK_PROGS(DEFAULT_PAGER, $octave_possible_pagers, []) if test -z "$DEFAULT_PAGER"; then - AC_MSG_WARN([I couldn't find `less', `more', `page', or `pg']) + warn_less="I couldn't find \`less', \`more', \`page', or \`pg'" + AC_MSG_WARN($warn_less) fi ### Even though we include config.h, we need to have the preprocessor @@ -1218,3 +1232,89 @@ Include support for GNU readline: $USE_READLINE Include support for the GNU Info reader: $USE_GNU_INFO ]) + +warn_msg_printed=false + +if test -n "$warn_f77_and_g77"; then + AC_MSG_WARN($warn_f77_and_g77) + warn_msg_printed=true +fi + +if test -n "$warn_f2c_and_f77"; then + AC_MSG_WARN($warn_f2c_and_f77) + warn_msg_printed=true +fi + +if test -n "$warn_f2c_and_g77"; then + AC_MSG_WARN($warn_f2c_and_g77) + warn_msg_printed=true +fi + +if test -n "$gxx_only"; then + AC_MSG_WARN($gxx_only) + warn_msg_printed=true +fi + +if test -n "$warn_gcc_version"; then + AC_MSG_WARN($warn_gcc_version) + warn_msg_printed=true +fi + +if test -n "$warn_gcc_only"; then + AC_MSG_WARN($warn_gcc_only) + warn_msg_printed=true +fi + +if test -n "$warn_f2c_no_lib"; then + AC_MSG_WARN($warn_f2c_no_lib) + warn_msg_printed=true +fi + +if test -n "$warn_termlibs"; then + AC_MSG_WARN($warn_termlibs) + warn_msg_printed=true +fi + +if test -n "$warn_flex"; then + AC_MSG_WARN($warn_flex) + warn_msg_printed=true +fi + +if test -n "$warn_bison"; then + AC_MSG_WARN($warn_bison) + warn_msg_printed=true +fi + +if test -n "$warn_less"; then + AC_MSG_WARN($warn_less) + warn_msg_printed=true +fi + +if test -n "$warn_runtest"; then + AC_MSG_WARN($warn_runtest) + warn_msg_printed=true +fi + +if test -n "$warn_gnuplot"; then + + ## If you change this text, be sure to also change the corresponding + ## set of warnings above. + + AC_MSG_WARN([I didn't find gnuplot. It isn't necessary to have gnuplot]) + AC_MSG_WARN([installed, but you won't be able to use any of Octave's]) + AC_MSG_WARN([plotting commands without it.]) + AC_MSG_WARN([]) + AC_MSG_WARN([If gnuplot is installed but it isn't in your path, you can]) + AC_MSG_WARN([tell Octave where to find it by typing the command]) + AC_MSG_WARN([]) + AC_MSG_WARN([gnuplot_binary = "/full/path/to/gnuplot/binary"]) + AC_MSG_WARN([]) + AC_MSG_WARN([at the Octave prompt.]) + warn_msg_printed=true +fi + +if $warn_msg_printed; then + AC_MSG_RESULT([]) +fi + +### End of configure.
--- a/scripts/polynomial/polyfit.m +++ b/scripts/polynomial/polyfit.m @@ -67,6 +67,10 @@ if (nargout == 2) yf = X * p; + + if (y_is_row_vector) + yf = yf'; + endif endif p = flipud (p); @@ -75,8 +79,4 @@ p = p'; endif - if (y_is_row_vector) - yf = yf'; - endif - endfunction
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,15 +1,29 @@ Tue Nov 18 04:27:55 1997 John W. Eaton <jwe@bevo.che.wisc.edu> + * pr-output.cc (Vfixed_point_format): New variable. + (fixed_point_format): New fucntion. + (symbols_of_pr_output): Add DEFVAR for fixed_point_format. + (set_real_matrix_format): Handle fixed point format + (set_complex_matrix_format): Handle fixed point format + (set_format): New arg, scale in Matrix, ComplexMatrix, Range versions. + (pr_scale_header): New function. + (octave_print_internal): Handle fixed point format in Matrix, + ComplexMatrix, and Range versions. + * octave.cc (maximum_braindamage): Set fixed_point_format to 1.0. + * utils.cc (do_string_escapes): Move here, from lex.l. Arg is now const string& instead of char*. Return new string object instead of modifying arg in place. (Fdo_string_escapes): New function. * lex.l (handle_string): Use new version of do_string_escapes. - * lex.l (Vbackslash_escapes): No longer static. - * oct-stream.cc (octave_base_stream::scanf): If !Vbackslash_escapes, - call do_backslash_escapes on format string here. - * oct-stream.cc (octave_base_stream::oscanf): Likewise. - * oct-stream.cc (octave_base_stream::printf): Likewise. + + * lex.l (Vbackslash_escapes): Delete. + (backslash_escapes): Delete. + (do_string_escapes): Undo previous change. + (eat_whitespace, eat_continuation): Undo previous change. + (handle_string): Undo previous change. + (symbols_of_lex): Undo previous change. + * octave.cc (maximum_braindamage): Undo previous change. Fri Nov 14 01:53:13 1997 John W. Eaton <jwe@bevo.che.wisc.edu>
--- a/src/lex.l +++ b/src/lex.l @@ -159,10 +159,6 @@ static int Vwhitespace_in_literal_matrix; -// Should Octave treat backslashes in strings as escapes that -// introduce special characters like newline (\n), tab (\t), etc.? -static bool Vbackslash_escapes; - // Forward declarations for functions defined at the bottom of this // file. @@ -1296,7 +1292,7 @@ break; else { - if (Vbackslash_escapes && have_continuation ()) + if (have_continuation ()) break; else goto done; @@ -1451,7 +1447,7 @@ int retval = ATE_NOTHING; int c = yyinput (); if ((c == '.' && have_ellipsis_continuation ()) - || (c == '\\' && Vbackslash_escapes && have_continuation ())) + || (c == '\\' && have_continuation ())) retval = eat_whitespace (); else yyunput (c, yytext); @@ -1471,7 +1467,7 @@ { current_input_column++; - if (c == '\\' && Vbackslash_escapes) + if (c == '\\') { if (escape_pending) { @@ -1513,15 +1509,14 @@ { yyunput (c, yytext); buf << ends; - char *tmp = buf.str (); - string tok = Vbackslash_escapes - ? do_string_escapes (tmp) : string (tmp); - delete [] tmp; + char *t = buf.str (); + string s = do_string_escapes (t); + delete [] t; if (text_style && lexer_flags.doing_set) { - if (! tok.empty ()) - tok = string (delim, 1) + tok + string (delim, 1); + if (! s.empty ()) + s = string (delim, 1) + s + string (delim, 1); } else { @@ -1530,7 +1525,7 @@ lexer_flags.convert_spaces_to_comma = true; } - yylval.tok_val = new token (tok); + yylval.tok_val = new token (s); token_stack.push (yylval.tok_val); return TEXT; } @@ -1877,14 +1872,6 @@ } int -backslash_escapes (void) -{ - Vbackslash_escapes = check_preference ("backslash_escapes"); - - return 0; -} - -int whitespace_in_literal_matrix (void) { int pref = 0; @@ -1907,10 +1894,6 @@ void symbols_of_lex (void) { - DEFVAR (backslash_escapes, 1.0, 0, backslash_escapes, - "if nonzero, Octave recognizes backslashes in strings as escapes that\n\ -introduce special characters like newline (\\n), tab (\\t), etc."); - DEFVAR (whitespace_in_literal_matrix, "", 0, whitespace_in_literal_matrix, "control auto-insertion of commas and semicolons in literal matrices"); }
--- a/src/octave.cc +++ b/src/octave.cc @@ -331,6 +331,7 @@ bind_builtin_variable ("define_all_return_values", 1.0); bind_builtin_variable ("do_fortran_indexing", 1.0); bind_builtin_variable ("empty_list_elements_ok", 1.0); + bind_builtin_variable ("fixed_point_format", 1.0); bind_builtin_variable ("implicit_str_to_num_ok", 1.0); bind_builtin_variable ("ok_to_lose_imaginary_part", 1.0); bind_builtin_variable ("page_screen_output", 0.0);
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -54,6 +54,10 @@ #include "utils.h" #include "variables.h" +// TRUE means use a scaled fixed point format for `format long' and +// `format short'. +static bool Vfixed_point_format; + // The maximum field width for a number printed by the default output // routines. static int Voutput_max_field_width; @@ -298,6 +302,14 @@ fw += sign; rd = 0; } + else if (Vfixed_point_format) + { + rd = prec; + fw = rd + 2; + if (inf_or_nan && fw < 3) + fw = 3; + fw += sign; + } else { int ld_max, rd_max; @@ -338,7 +350,8 @@ } if (! (bank_format || hex_format || bit_format) - && (fw > Voutput_max_field_width || print_e)) + && (print_e + || (! Vfixed_point_format && fw > Voutput_max_field_width))) { int exp_field = 4; if (x_max > 100 || x_min > 100) @@ -363,7 +376,7 @@ } static void -set_format (const Matrix& m, int& fw) +set_format (const Matrix& m, int& fw, double& scale) { curr_real_fmt = 0; curr_imag_fmt = 0; @@ -387,6 +400,8 @@ int x_min = min_abs == 0.0 ? 0 : static_cast<int> (floor (log10 (min_abs) + 1.0)); + scale = x_max == 0 ? 1.0 : pow (10.0, x_max - 1); + set_real_matrix_format (sign, x_max, x_min, inf_or_nan, int_or_inf_or_nan, fw); } @@ -395,7 +410,8 @@ set_format (const Matrix& m) { int fw; - set_format (m, fw); + double scale; + set_format (m, fw, scale); } static void @@ -606,6 +622,14 @@ r_fw += sign; rd = 0; } + else if (Vfixed_point_format) + { + rd = prec; + i_fw = r_fw = rd + 2; + if (inf_or_nan && i_fw < 3) + i_fw = r_fw = 3; + r_fw += sign; + } else { int ld_max, rd_max; @@ -646,7 +670,8 @@ } if (! (bank_format || hex_format || bit_format) - && (r_fw > Voutput_max_field_width || print_e)) + && (print_e + || (! Vfixed_point_format && r_fw > Voutput_max_field_width))) { int exp_field = 4; if (x_max > 100 || x_min > 100) @@ -679,7 +704,7 @@ } static void -set_format (const ComplexMatrix& cm, int& r_fw, int& i_fw) +set_format (const ComplexMatrix& cm, int& r_fw, int& i_fw, double& scale) { curr_real_fmt = 0; curr_imag_fmt = 0; @@ -720,6 +745,8 @@ int x_max = r_x_max > i_x_max ? r_x_max : i_x_max; int x_min = r_x_min > i_x_min ? r_x_min : i_x_min; + scale = x_max == 0 ? 1.0 : pow (10.0, x_max - 1); + set_complex_matrix_format (sign, x_max, x_min, r_x_max, r_x_min, inf_or_nan, int_or_inf_or_nan, r_fw, i_fw); } @@ -728,11 +755,13 @@ set_format (const ComplexMatrix& cm) { int r_fw, i_fw; - set_format (cm, r_fw, i_fw); + double scale; + set_format (cm, r_fw, i_fw, scale); } static void -set_range_format (bool sign, int x_max, int x_min, int all_ints, int& fw) +set_range_format (bool sign, int x_max, int x_min, int all_ints, + int& fw) { static char fmt_buf[128]; @@ -762,6 +791,11 @@ fw = sign + digits; rd = 0; } + else if (Vfixed_point_format) + { + rd = prec; + fw = rd + 2 + sign; + } else { int ld_max, rd_max; @@ -799,7 +833,8 @@ } if (! (bank_format || hex_format || bit_format) - && (fw > Voutput_max_field_width || print_e)) + && (print_e + || (! Vfixed_point_format && fw > Voutput_max_field_width))) { int exp_field = 4; if (x_max > 100 || x_min > 100) @@ -821,7 +856,7 @@ } static void -set_format (const Range& r, int& fw) +set_format (const Range& r, int& fw, double& scale) { curr_real_fmt = 0; curr_imag_fmt = 0; @@ -852,6 +887,8 @@ int x_min = min_abs == 0.0 ? 0 : static_cast<int> (floor (log10 (min_abs) + 1.0)); + scale = x_max == 0 ? 1.0 : pow (10.0, x_max - 1); + set_range_format (sign, x_max, x_min, all_ints, fw); } @@ -859,7 +896,8 @@ set_format (const Range& r) { int fw; - set_format (r, fw); + double scale; + set_format (r, fw, scale); } union equiv @@ -1080,6 +1118,18 @@ } static void +pr_scale_header (ostream& os, double scale) +{ + if (Vfixed_point_format && scale != 1.0) + { + os.form (" %-8.1e *\n", scale); + + if (! compact_format) + os << "\n"; + } +} + +static void pr_col_num_header (ostream& os, int total_width, int max_width, int lim, int col, int extra_indent) { @@ -1155,7 +1205,8 @@ else { int fw; - set_format (m, fw); + double scale = 1.0; + set_format (m, fw, scale); int column_width = fw + 2; int total_width = nc * column_width; int max_width = command_editor::terminal_cols (); @@ -1229,6 +1280,8 @@ } else { + pr_scale_header (os, scale); + for (int col = 0; col < nc; col += inc) { int lim = col + inc < nc ? col + inc : nc; @@ -1244,7 +1297,10 @@ { os << " "; - pr_float (os, m (i, j), fw); + double tmp = (Vfixed_point_format && scale != 1.0) + ? m(i,j) / scale : m(i,j); + + pr_float (os, tmp, fw); } if (i < nr - 1) @@ -1307,7 +1363,8 @@ else { int r_fw, i_fw; - set_format (cm, r_fw, i_fw); + double scale = 1.0; + set_format (cm, r_fw, i_fw, scale); int column_width = i_fw + r_fw; column_width += (bank_format || hex_format|| bit_format) ? 2 : 7; int total_width = nc * column_width; @@ -1382,6 +1439,8 @@ } else { + pr_scale_header (os, scale); + for (int col = 0; col < nc; col += inc) { int lim = col + inc < nc ? col + inc : nc; @@ -1397,7 +1456,10 @@ { os << " "; - pr_complex (os, cm (i, j)); + Complex tmp = (Vfixed_point_format && scale != 1.0) + ? cm(i,j) / scale : cm(i,j); + + pr_complex (os, tmp, r_fw, i_fw); } if (i < nr - 1) @@ -1432,7 +1494,8 @@ else { int fw; - set_format (r, fw); + double scale = 1.0; + set_format (r, fw, scale); if (pr_as_read_syntax) { @@ -1480,6 +1543,8 @@ if (max_width < 0) max_width = 0; + pr_scale_header (os, scale); + int col = 0; while (col < num_elem) { @@ -1493,7 +1558,12 @@ for (int i = col; i < lim; i++) { double val = base + i * increment; + os << " "; + + if (Vfixed_point_format && scale != 1.0) + val /= scale; + pr_float (os, val, fw); } @@ -1729,6 +1799,14 @@ } static int +fixed_point_format (void) +{ + Vfixed_point_format = check_preference ("fixed_point_format"); + + return 0; +} + +static int output_max_field_width (void) { double val; @@ -1783,6 +1861,9 @@ void symbols_of_pr_output (void) { + DEFVAR (fixed_point_format, 0.0, 0, fixed_point_format, + "use scaled fixed point format for `format short' and `format long'"); + DEFVAR (output_max_field_width, 10.0, 0, output_max_field_width, "maximum width of an output field for numeric output");
--- a/src/utils.cc +++ b/src/utils.cc @@ -396,7 +396,7 @@ j++; } - retval.resize (j); + retval.resize (i); return retval; }