# HG changeset patch # User jwe # Date 1156358139 0 # Node ID 85c7dc4afe6b64db14e67cd97c2ba42070067d9e # Parent 370f785718bea7843ae552bd2f8ebcefa3631388 [project @ 2006-08-23 18:35:38 by jwe] diff -r 370f785718be -r 85c7dc4afe6b liboctave/CMatrix.cc --- a/liboctave/CMatrix.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/liboctave/CMatrix.cc Wed Aug 23 18:35:39 2006 +0000 @@ -3464,82 +3464,6 @@ // i/o -// Used when converting Inf to something that gnuplot can read. - -#ifndef OCT_RBV -#define OCT_RBV DBL_MAX / 100.0 -#endif - -std::ostream& -ComplexMatrix::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) -{ - if (strip_nan_and_inf) - { - octave_idx_type nr = rows (); - octave_idx_type nc = columns (); - - for (octave_idx_type i = 0; i < nr; i++) - { - if (strip_nan_and_inf) - { - for (octave_idx_type j = 0; j < nc; j++) - { - Complex c = elem (i, j); - - if (xisnan (c)) - { - if (strip_nan_and_inf == 1) - goto next_row; - else if (strip_nan_and_inf == 2) - goto next_row_with_newline; - } - } - } - - for (octave_idx_type j = 0; j < nc; j++) - { - Complex c = elem (i, j); - - if (strip_nan_and_inf) - { - double re = std::real (c); - double im = std::imag (c); - - if (xisinf (re)) - re = re > 0 ? OCT_RBV : -OCT_RBV; - - if (xisinf (im)) - im = im > 0 ? OCT_RBV : -OCT_RBV; - - c = Complex (re, im); - } - else if (! infnan_warned && (xisnan (c) || xisinf (c))) - { - (*current_liboctave_warning_handler) - ("save: Inf or NaN values may not be reloadable"); - - infnan_warned = true; - } - - octave_write_complex (os, c); - - os << " "; - } - - next_row_with_newline: - os << "\n"; - - next_row: - continue; - } - } - else - os << *this; - - return os; -} - std::ostream& operator << (std::ostream& os, const ComplexMatrix& a) { diff -r 370f785718be -r 85c7dc4afe6b liboctave/CMatrix.h --- a/liboctave/CMatrix.h Wed Aug 23 14:09:40 2006 +0000 +++ b/liboctave/CMatrix.h Wed Aug 23 18:35:39 2006 +0000 @@ -319,9 +319,6 @@ // i/o - std::ostream& save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); - friend std::ostream& operator << (std::ostream& os, const ComplexMatrix& a); friend std::istream& operator >> (std::istream& is, ComplexMatrix& a); diff -r 370f785718be -r 85c7dc4afe6b liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Aug 23 14:09:40 2006 +0000 +++ b/liboctave/ChangeLog Wed Aug 23 18:35:39 2006 +0000 @@ -1,3 +1,8 @@ +2006-08-23 John W. Eaton + + * dMatrix.cc, dMatrix.h (Matrix::save_ascii): Delete function and decl. + * CMatrix.cc, CMatrix.h (ComplexMatrix::save_ascii): Likewise. + 2006-08-22 John W. Eaton * CMatrix.cc (ComplexMatrix::save_ascii): New function. diff -r 370f785718be -r 85c7dc4afe6b liboctave/dMatrix.cc --- a/liboctave/dMatrix.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/liboctave/dMatrix.cc Wed Aug 23 18:35:39 2006 +0000 @@ -2851,74 +2851,6 @@ return result; } -// Used when converting Inf to something that gnuplot can read. - -#ifndef OCT_RBV -#define OCT_RBV DBL_MAX / 100.0 -#endif - -std::ostream& -Matrix::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) -{ - if (strip_nan_and_inf) - { - octave_idx_type nr = rows (); - octave_idx_type nc = columns (); - - for (octave_idx_type i = 0; i < nr; i++) - { - if (strip_nan_and_inf) - { - for (octave_idx_type j = 0; j < nc; j++) - { - double d = elem (i, j); - - if (xisnan (d)) - { - if (strip_nan_and_inf == 1) - goto next_row; - else if (strip_nan_and_inf == 2) - goto next_row_with_newline; - } - } - } - - for (octave_idx_type j = 0; j < nc; j++) - { - double d = elem (i, j); - - if (strip_nan_and_inf) - { - if (xisinf (d)) - d = d > 0 ? OCT_RBV : -OCT_RBV; - } - else if (! infnan_warned && (xisnan (d) || xisinf (d))) - { - (*current_liboctave_warning_handler) - ("save: Inf or NaN values may not be reloadable"); - - infnan_warned = true; - } - - octave_write_double (os, d); - - os << " "; - } - - next_row_with_newline: - os << "\n"; - - next_row: - continue; - } - } - else - os << *this; - - return os; -} - std::ostream& operator << (std::ostream& os, const Matrix& a) { diff -r 370f785718be -r 85c7dc4afe6b liboctave/dMatrix.h --- a/liboctave/dMatrix.h Wed Aug 23 14:09:40 2006 +0000 +++ b/liboctave/dMatrix.h Wed Aug 23 18:35:39 2006 +0000 @@ -274,9 +274,6 @@ // i/o - std::ostream& save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); - friend std::ostream& operator << (std::ostream& os, const Matrix& a); friend std::istream& operator >> (std::istream& is, Matrix& a); diff -r 370f785718be -r 85c7dc4afe6b scripts/ChangeLog --- a/scripts/ChangeLog Wed Aug 23 14:09:40 2006 +0000 +++ b/scripts/ChangeLog Wed Aug 23 18:35:39 2006 +0000 @@ -1,3 +1,7 @@ +2006-08-23 John W. Eaton + + * plot/__plt__.m: Insert using clauses for all plots. + 2006-08-23 A S Hodel * control/system/sysscale.m: Call tf and zp with correct number of diff -r 370f785718be -r 85c7dc4afe6b scripts/plot/__plt__.m --- a/scripts/plot/__plt__.m Wed Aug 23 14:09:40 2006 +0000 +++ b/scripts/plot/__plt__.m Wed Aug 23 18:35:39 2006 +0000 @@ -93,17 +93,19 @@ if (have_data) if (iscell (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j})) for i = 1:length (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}) + usingstr = make_using_clause (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}{i}); __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ - = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s", + = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s", __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, - __plot_command_sep__, j, i, fmtstr{i}); + __plot_command_sep__, j, i, usingstr, fmtstr{i}); __plot_command_sep__ = ",\\\n"; endfor else + usingstr = make_using_clause (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}); __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ - = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s", + = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s", __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, - __plot_command_sep__, j, fmtstr); + __plot_command_sep__, j, usingstr, fmtstr); __plot_command_sep__ = ",\\\n"; endif j++; @@ -127,4 +129,16 @@ usage (msg); endif -endfunction +## endfunction + +function usingstr = make_using_clause (x) + cols = columns (x); + if (cols > 0) + usingstr = strcat (gnuplot_command_using, " ($1)"); + for k = 2:cols + usingstr = sprintf ("%s:($%d)", usingstr, k); + endfor + else + usingstr = ""; + endif +## endfunction diff -r 370f785718be -r 85c7dc4afe6b src/ChangeLog --- a/src/ChangeLog Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ChangeLog Wed Aug 23 18:35:39 2006 +0000 @@ -1,3 +1,50 @@ +2006-08-23 John W. Eaton + + * ov.h (octave_value::save_ascii): Delete strip_nan_and_inf arg. + * ov-base.h, ov-base.cc (octave_base_value::save_ascii): Likewise. + * ov-base-int.h, ov-base-int.cc (octave_base_int_matrix::save_ascii, + octave_base_int_scalar::save_ascii, ): Likewise. + * ov-base-sparse.cc, ov-base-sparse.h + (octave_base_sparse::save_ascii): Likewise. + * ov-bool-mat.cc, ov-bool-mat.h (octave_bool_matrix::save_ascii): + Likewise. + * ov-bool.cc, ov-bool.h (octave_bool::save_ascii): Likewise. + * ov-cell.cc, ov-cell.h (octave_cell::save_ascii): Likewise. + * ov-complex.cc, ov-complex.h (octave_complex::save_ascii): Likewise. + * ov-fcn-handle.cc, ov-fcn-handle.h (octave_fcn_handle::save_ascii): + Likewise. + * ov-fcn-inline.cc, ov-fcn-inline.h (octave_fcn_inline::save_ascii): + Likewise. + * ov-list.cc, ov-list.h (octave_list::save_ascii): Likewise. + * ov-range.cc, ov-range.h (octave_range::save_ascii): Likewise. + * ov-scalar.cc, ov-scalar.h (octave_scalar::save_ascii): Likewise. + * ov-str-mat.cc, ov-str-mat.h (octave_char_matrix_str::save_ascii): + Likewise. + * ov-struct.cc, ov-struct.h (octave_struct::save_ascii): Likewise. + * ov-re-mat.cc, ov-re-mat.cc (octave_matrix::save_ascii): Likewise. + * ov-cx-mat.cc, ov-cx-mat.cc (octave_complex_matrix::save_ascii): + Likewise. + * ov-cx-mat.cc, ov-cx-mat.cc (octave_complex_matrix::save_ascii): + Likewise. + * ov-re-mat.cc, ov-re-mat.cc (octave_matrix::save_ascii): Likewise. + + * ls-oct-ascii.cc, ls-oct-ascii.h (save_ascii_data): + Delete strip_nan_and_inf arg. + (save_ascii_data_for_plotting): Delete strip_nan_and_inf arg from + call to save_ascii_data. + + * DLD-FUNCTIONS/__gnuplot_raw__.l (handle_using): Accept "(EXPR)" + as components of using clauses. + (enum _toktype): New element DOLLAR. + Accept "$" in lexer. + + * ls-oct-ascii.cc (save_ascii_data): Delete arg strip_nan_and_inf. + Change all uses. + + * ls-oct-ascii.h (save_three_d): Provide decl. + * load-save.h (save_ascii_data_for_plotting, save_three_d): + Delete decls. + 2006-08-22 John W. Eaton * ov.h (octave_value::save_ascii): strip_nan_and_inf is now int, @@ -23,7 +70,8 @@ Likewise. * ov-struct.cc, ov-struct.h (octave_struct::save_ascii): Likewise. * ov-re-mat.cc, ov-re-mat.cc (octave_matrix::save_ascii): Likewise. - * ov-cx-mat.cc, ov-cx-mat.cc (octave_complex_matrix::save_ascii): Likewise. + * ov-cx-mat.cc, ov-cx-mat.cc (octave_complex_matrix::save_ascii): + Likewise. * ov-cx-mat.cc, ov-cx-mat.cc (octave_complex_matrix::save_ascii): Don't strip Inf and NaN here. Call ComplexMatrix::save_ascii to diff -r 370f785718be -r 85c7dc4afe6b src/DLD-FUNCTIONS/__gnuplot_raw__.l --- a/src/DLD-FUNCTIONS/__gnuplot_raw__.l Wed Aug 23 14:09:40 2006 +0000 +++ b/src/DLD-FUNCTIONS/__gnuplot_raw__.l Wed Aug 23 18:35:39 2006 +0000 @@ -57,7 +57,7 @@ #include "defun-dld.h" #include "file-io.h" #include "gripes.h" -#include "load-save.h" +#include "ls-oct-ascii.h" #include "parse.h" #include "procstream.h" #include "sighandlers.h" @@ -76,6 +76,7 @@ SEMICOLON, COMMA, QUOTE, + DOLLAR, IDENT, NUMBER, BINOP, @@ -194,6 +195,12 @@ } } +"$" { + gpt_quote_is_transpose = false; + return DOLLAR; + } + + "\"" { return handle_string ('"'); } @@ -577,13 +584,18 @@ { expr_str = read_until (colon_plottok_or_end_p, tok); - tmp_data = eval_string (expr_str, true, status); - if (status != 0 || ! tmp_data.is_real_scalar ()) - throw gpt_parse_error (); + if (! expr_str.empty () && expr_str[0] == '(') + retstr += expr_str; + else + { + tmp_data = eval_string (expr_str, true, status); + if (status != 0 || ! tmp_data.is_real_scalar ()) + throw gpt_parse_error (); - std::ostringstream tmp_buf; - tmp_data.print_raw (tmp_buf); - retstr += tmp_buf.str (); + std::ostringstream tmp_buf; + tmp_data.print_raw (tmp_buf); + retstr += tmp_buf.str (); + } if (tok == COLON) retstr += ":"; diff -r 370f785718be -r 85c7dc4afe6b src/load-save.cc --- a/src/load-save.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/load-save.cc Wed Aug 23 18:35:39 2006 +0000 @@ -993,7 +993,7 @@ switch (fmt) { case LS_ASCII: - save_ascii_data (os, tc, name, infnan_warned, false, global, 0); + save_ascii_data (os, tc, name, infnan_warned, global, 0); break; case LS_BINARY: diff -r 370f785718be -r 85c7dc4afe6b src/load-save.h --- a/src/load-save.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/load-save.h Wed Aug 23 18:35:39 2006 +0000 @@ -45,14 +45,6 @@ LS_UNKNOWN }; -extern bool -save_ascii_data_for_plotting (std::ostream& os, const octave_value& t, - const std::string& name = std::string ()); - -extern bool -save_three_d (std::ostream& os, const octave_value& t, - bool parametric = false); - extern void dump_octave_core (void); extern int diff -r 370f785718be -r 85c7dc4afe6b src/ls-oct-ascii.cc --- a/src/ls-oct-ascii.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ls-oct-ascii.cc Wed Aug 23 18:35:39 2006 +0000 @@ -307,12 +307,6 @@ // flag MARK_AS_GLOBAL on stream OS in the plain text format described // above for load_ascii_data. If NAME is empty, the name: line is not // generated. PRECISION specifies the number of decimal digits to print. -// If STRIP_NAN_AND_INF is 1, rows containing NaNs are deleted, -// and Infinite values are converted to +/-OCT_RBV (A Real Big Value, -// but not so big that gnuplot can't handle it when trying to compute -// axis ranges, etc.). If STRIP_NAN_AND_INF is 2, rows containing -// NaNs are converted to blank lines in the output file and infinite -// values are converted to +/-OCT_RBV. // // Assumes ranges and strings cannot contain Inf or NaN values. // @@ -323,8 +317,7 @@ bool save_ascii_data (std::ostream& os, const octave_value& val_arg, const std::string& name, bool& infnan_warned, - int strip_nan_and_inf, bool mark_as_global, - int precision) + bool mark_as_global, int precision) { bool success = true; @@ -344,7 +337,7 @@ long old_precision = os.precision (); os.precision (precision); - success = val . save_ascii (os, infnan_warned, strip_nan_and_inf); + success = val . save_ascii (os, infnan_warned); os.precision (old_precision); @@ -357,7 +350,7 @@ { bool infnan_warned = true; - return save_ascii_data (os, t, name, infnan_warned, 2, false, 0); + return save_ascii_data (os, t, name, infnan_warned, false, 0); } // Maybe this should be a static function in tree-plot.cc? diff -r 370f785718be -r 85c7dc4afe6b src/ls-oct-ascii.h --- a/src/ls-oct-ascii.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ls-oct-ascii.h Wed Aug 23 18:35:39 2006 +0000 @@ -51,13 +51,16 @@ extern bool save_ascii_data (std::ostream& os, const octave_value& val_arg, const std::string& name, bool& infnan_warned, - int strip_nan_and_inf, bool mark_as_global, - int precision); + bool mark_as_global, int precision); extern bool save_ascii_data_for_plotting (std::ostream& os, const octave_value& t, const std::string& name); +extern bool +save_three_d (std::ostream& os, const octave_value& t, + bool parametric = false); + // Match KEYWORD on stream IS, placing the associated value in VALUE, // returning TRUE if successful and FALSE otherwise. // diff -r 370f785718be -r 85c7dc4afe6b src/ov-base-int.cc --- a/src/ov-base-int.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base-int.cc Wed Aug 23 18:35:39 2006 +0000 @@ -70,7 +70,7 @@ template bool -octave_base_int_matrix::save_ascii (std::ostream& os, bool&, int) +octave_base_int_matrix::save_ascii (std::ostream& os, bool&) { dim_vector d = this->dims (); @@ -331,7 +331,7 @@ template bool -octave_base_int_scalar::save_ascii (std::ostream& os, bool& , int) +octave_base_int_scalar::save_ascii (std::ostream& os, bool&) { os << this->scalar << "\n"; return true; diff -r 370f785718be -r 85c7dc4afe6b src/ov-base-int.h --- a/src/ov-base-int.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base-int.h Wed Aug 23 18:35:39 2006 +0000 @@ -67,8 +67,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); @@ -109,7 +108,7 @@ // void decrement (void) { scalar -= 1; } - bool save_ascii (std::ostream& os, bool&, int); + bool save_ascii (std::ostream& os, bool&); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-base-sparse.cc --- a/src/ov-base-sparse.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base-sparse.cc Wed Aug 23 18:35:39 2006 +0000 @@ -295,7 +295,7 @@ template bool -octave_base_sparse::save_ascii (std::ostream& os, bool&, int) +octave_base_sparse::save_ascii (std::ostream& os, bool&) { dim_vector dv = this->dims (); diff -r 370f785718be -r 85c7dc4afe6b src/ov-base-sparse.h --- a/src/ov-base-sparse.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base-sparse.h Wed Aug 23 18:35:39 2006 +0000 @@ -141,8 +141,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-base.cc --- a/src/ov-base.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base.cc Wed Aug 23 18:35:39 2006 +0000 @@ -815,7 +815,7 @@ } bool -octave_base_value::save_ascii (std::ostream&, bool&, int) +octave_base_value::save_ascii (std::ostream&, bool&) { gripe_wrong_type_arg ("octave_base_value::save_ascii()", type_name ()); return false; diff -r 370f785718be -r 85c7dc4afe6b src/ov-base.h --- a/src/ov-base.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-base.h Wed Aug 23 18:35:39 2006 +0000 @@ -414,8 +414,7 @@ virtual void print_info (std::ostream& os, const std::string& prefix) const; - virtual bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + virtual bool save_ascii (std::ostream& os, bool& infnan_warned); virtual bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-bool-mat.cc --- a/src/ov-bool-mat.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-bool-mat.cc Wed Aug 23 18:35:39 2006 +0000 @@ -149,8 +149,7 @@ } bool -octave_bool_matrix::save_ascii (std::ostream& os, bool& /* infnan_warned */, - int /* strip_nan_and_inf */) +octave_bool_matrix::save_ascii (std::ostream& os, bool& /* infnan_warned */) { dim_vector d = dims (); if (d.length () > 2) diff -r 370f785718be -r 85c7dc4afe6b src/ov-bool-mat.h --- a/src/ov-bool-mat.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-bool-mat.h Wed Aug 23 18:35:39 2006 +0000 @@ -164,8 +164,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-bool.cc --- a/src/ov-bool.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-bool.cc Wed Aug 23 18:35:39 2006 +0000 @@ -133,8 +133,7 @@ } bool -octave_bool::save_ascii (std::ostream& os, bool& /* infnan_warned */, - int /* strip_nan_and_inf */) +octave_bool::save_ascii (std::ostream& os, bool& /* infnan_warned */) { double d = double_value (); diff -r 370f785718be -r 85c7dc4afe6b src/ov-bool.h --- a/src/ov-bool.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-bool.h Wed Aug 23 18:35:39 2006 +0000 @@ -156,8 +156,7 @@ octave_value convert_to_str_internal (bool pad, bool force, char type) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-cell.cc --- a/src/ov-cell.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-cell.cc Wed Aug 23 18:35:39 2006 +0000 @@ -433,8 +433,7 @@ #define CELL_ELT_TAG "" bool -octave_cell::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_cell::save_ascii (std::ostream& os, bool& infnan_warned) { dim_vector d = dims (); if (d.length () > 2) @@ -453,7 +452,7 @@ // Recurse to print sub-value. bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, infnan_warned, - strip_nan_and_inf, 0, 0); + false, 0); if (! b) return os; @@ -476,8 +475,7 @@ // Recurse to print sub-value. bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, - infnan_warned, - strip_nan_and_inf, 0, 0); + infnan_warned, false, 0); if (! b) return os; diff -r 370f785718be -r 85c7dc4afe6b src/ov-cell.h --- a/src/ov-cell.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-cell.h Wed Aug 23 18:35:39 2006 +0000 @@ -113,8 +113,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-complex.cc --- a/src/ov-complex.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-complex.cc Wed Aug 23 18:35:39 2006 +0000 @@ -176,43 +176,19 @@ } bool -octave_complex::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_complex::save_ascii (std::ostream& os, bool& infnan_warned) { Complex c = complex_value (); - if (strip_nan_and_inf) + if (! infnan_warned && (xisnan (c) || xisinf (c))) { - if (xisnan (c)) - { - error ("only value to plot is NaN"); - return false; - } - else - { - double re = real (c); - double im = imag (c); - - re = xisinf (re) ? (re > 0 ? OCT_RBV : -OCT_RBV) : re; - im = xisinf (im) ? (im > 0 ? OCT_RBV : -OCT_RBV) : im; + warning ("save: Inf or NaN values may not be reloadable"); + infnan_warned = true; + } + + octave_write_complex (os, c); - c = Complex (re, im); - - octave_write_complex (os, c); - os << "\n"; - } - } - else - { - if (! infnan_warned && (xisnan (c) || xisinf (c))) - { - warning ("save: Inf or NaN values may not be reloadable"); - infnan_warned = true; - } - - octave_write_complex (os, c); - os << "\n"; - } + os << "\n"; return true; } diff -r 370f785718be -r 85c7dc4afe6b src/ov-complex.h --- a/src/ov-complex.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-complex.h Wed Aug 23 18:35:39 2006 +0000 @@ -116,8 +116,7 @@ void decrement (void) { scalar -= 1.0; } - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-cx-mat.cc --- a/src/ov-cx-mat.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-cx-mat.cc Wed Aug 23 18:35:39 2006 +0000 @@ -201,21 +201,14 @@ } bool -octave_complex_matrix::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_complex_matrix::save_ascii (std::ostream& os, bool& infnan_warned) { dim_vector d = dims (); if (d.length () > 2) { ComplexNDArray tmp = complex_array_value (); - if (strip_nan_and_inf) - { - warning ("save: Can not strip Inf or NaN values"); - warning ("save: Inf or NaN values may not be reloadable"); - infnan_warned = true; - } - else if (! infnan_warned && tmp.any_element_is_inf_or_nan ()) + if (! infnan_warned && tmp.any_element_is_inf_or_nan ()) { warning ("save: Inf or NaN values may not be reloadable"); infnan_warned = true; @@ -235,9 +228,7 @@ os << "# rows: " << rows () << "\n" << "# columns: " << columns () << "\n"; - ComplexMatrix tmp = complex_matrix_value (); - - tmp.save_ascii (os, infnan_warned, strip_nan_and_inf); + os << complex_matrix_value (); } return true; diff -r 370f785718be -r 85c7dc4afe6b src/ov-cx-mat.h --- a/src/ov-cx-mat.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-cx-mat.h Wed Aug 23 18:35:39 2006 +0000 @@ -120,8 +120,7 @@ void decrement (void) { matrix -= Complex (1.0); } - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-fcn-handle.cc Wed Aug 23 18:35:39 2006 +0000 @@ -144,7 +144,7 @@ } bool -octave_fcn_handle::save_ascii (std::ostream& os, bool&, int) +octave_fcn_handle::save_ascii (std::ostream& os, bool&) { os << nm << "\n"; diff -r 370f785718be -r 85c7dc4afe6b src/ov-fcn-handle.h --- a/src/ov-fcn-handle.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-fcn-handle.h Wed Aug 23 18:35:39 2006 +0000 @@ -84,8 +84,7 @@ std::string fcn_name (void) const { return nm; } - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-fcn-inline.cc --- a/src/ov-fcn-inline.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-fcn-inline.cc Wed Aug 23 18:35:39 2006 +0000 @@ -90,7 +90,7 @@ } bool -octave_fcn_inline::save_ascii (std::ostream& os, bool&, int) +octave_fcn_inline::save_ascii (std::ostream& os, bool&) { os << "# nargs: " << ifargs.length () << "\n"; for (int i = 0; i < ifargs.length (); i++) diff -r 370f785718be -r 85c7dc4afe6b src/ov-fcn-inline.h --- a/src/ov-fcn-inline.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-fcn-inline.h Wed Aug 23 18:35:39 2006 +0000 @@ -65,8 +65,7 @@ octave_value convert_to_str_internal (bool, bool, char) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-list.cc --- a/src/ov-list.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-list.cc Wed Aug 23 18:35:39 2006 +0000 @@ -538,8 +538,7 @@ } bool -octave_list::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_list::save_ascii (std::ostream& os, bool& infnan_warned) { octave_value_list lst = list_value (); os << "# length: " << lst.length () << "\n"; @@ -552,8 +551,8 @@ buf << "_" << i; std::string s = buf.str (); - bool b = save_ascii_data (os, lst (i), s.c_str (), infnan_warned, - strip_nan_and_inf, 0, 0); + bool b = save_ascii_data (os, lst (i), s.c_str (), infnan_warned, + false, 0); if (! b) return false; diff -r 370f785718be -r 85c7dc4afe6b src/ov-list.h --- a/src/ov-list.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-list.h Wed Aug 23 18:35:39 2006 +0000 @@ -99,8 +99,7 @@ bool print_name_tag (std::ostream& os, const std::string& name) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-range.cc --- a/src/ov-range.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-range.cc Wed Aug 23 18:35:39 2006 +0000 @@ -285,8 +285,7 @@ } bool -octave_range::save_ascii (std::ostream& os, bool& /* infnan_warned */, - int /* strip_nan_and_inf */) +octave_range::save_ascii (std::ostream& os, bool& /* infnan_warned */) { Range r = range_value (); double base = r.base (); diff -r 370f785718be -r 85c7dc4afe6b src/ov-range.h --- a/src/ov-range.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-range.h Wed Aug 23 18:35:39 2006 +0000 @@ -186,8 +186,7 @@ bool print_name_tag (std::ostream& os, const std::string& name) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-re-mat.cc --- a/src/ov-re-mat.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-re-mat.cc Wed Aug 23 18:35:39 2006 +0000 @@ -255,21 +255,15 @@ } bool -octave_matrix::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_matrix::save_ascii (std::ostream& os, bool& infnan_warned) { dim_vector d = dims (); + if (d.length () > 2) { NDArray tmp = array_value (); - if (strip_nan_and_inf) - { - warning ("save: Can not strip Inf or NaN values"); - warning ("save: Inf or NaN values may not be reloadable"); - infnan_warned = true; - } - else if (! infnan_warned && tmp.any_element_is_inf_or_nan ()) + if (! infnan_warned && tmp.any_element_is_inf_or_nan ()) { warning ("save: Inf or NaN values may not be reloadable"); infnan_warned = true; @@ -289,9 +283,7 @@ os << "# rows: " << rows () << "\n" << "# columns: " << columns () << "\n"; - Matrix tmp = matrix_value (); - - tmp.save_ascii (os, infnan_warned, strip_nan_and_inf); + os << matrix_value (); } return true; diff -r 370f785718be -r 85c7dc4afe6b src/ov-re-mat.h --- a/src/ov-re-mat.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-re-mat.h Wed Aug 23 18:35:39 2006 +0000 @@ -155,8 +155,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-scalar.cc --- a/src/ov-scalar.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-scalar.cc Wed Aug 23 18:35:39 2006 +0000 @@ -156,36 +156,19 @@ } bool -octave_scalar::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_scalar::save_ascii (std::ostream& os, bool& infnan_warned) { double d = double_value (); - if (strip_nan_and_inf) + if (! infnan_warned && (xisnan (d) || xisinf (d))) { - if (xisnan (d)) - { - error ("only value to plot is NaN"); - return false; - } - else - { - d = xisinf (d) ? (d > 0 ? OCT_RBV : -OCT_RBV) : d; - octave_write_double (os, d); - os << "\n"; - } + warning ("save: Inf or NaN values may not be reloadable"); + infnan_warned = true; } - else - { - if (! infnan_warned && (xisnan (d) || xisinf (d))) - { - warning ("save: Inf or NaN values may not be reloadable"); - infnan_warned = true; - } - octave_write_double (os, d); - os << "\n"; - } + octave_write_double (os, d); + + os << "\n"; return true; } diff -r 370f785718be -r 85c7dc4afe6b src/ov-scalar.h --- a/src/ov-scalar.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-scalar.h Wed Aug 23 18:35:39 2006 +0000 @@ -186,8 +186,7 @@ void decrement (void) { --scalar; } - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-str-mat.cc --- a/src/ov-str-mat.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-str-mat.cc Wed Aug 23 18:35:39 2006 +0000 @@ -269,9 +269,7 @@ } bool -octave_char_matrix_str::save_ascii (std::ostream& os, - bool& /* infnan_warned */, - int /* strip_nan_and_inf */) +octave_char_matrix_str::save_ascii (std::ostream& os, bool& /* infnan_warned */) { dim_vector d = dims (); if (d.length () > 2) diff -r 370f785718be -r 85c7dc4afe6b src/ov-str-mat.h --- a/src/ov-str-mat.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-str-mat.h Wed Aug 23 18:35:39 2006 +0000 @@ -129,8 +129,7 @@ void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov-struct.cc --- a/src/ov-struct.cc Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-struct.cc Wed Aug 23 18:35:39 2006 +0000 @@ -1016,8 +1016,7 @@ } bool -octave_struct::save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) +octave_struct::save_ascii (std::ostream& os, bool& infnan_warned) { Octave_map m = map_value (); os << "# length: " << m.length () << "\n"; @@ -1027,8 +1026,7 @@ { octave_value val = map.contents (i); - bool b = save_ascii_data (os, val, m.key (i), infnan_warned, - strip_nan_and_inf, 0, 0); + bool b = save_ascii_data (os, val, m.key (i), infnan_warned, false, 0); if (! b) return os; diff -r 370f785718be -r 85c7dc4afe6b src/ov-struct.h --- a/src/ov-struct.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov-struct.h Wed Aug 23 18:35:39 2006 +0000 @@ -117,8 +117,7 @@ bool print_name_tag (std::ostream& os, const std::string& name) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf); + bool save_ascii (std::ostream& os, bool& infnan_warned); bool load_ascii (std::istream& is); diff -r 370f785718be -r 85c7dc4afe6b src/ov.h --- a/src/ov.h Wed Aug 23 14:09:40 2006 +0000 +++ b/src/ov.h Wed Aug 23 18:35:39 2006 +0000 @@ -778,9 +778,8 @@ void print_info (std::ostream& os, const std::string& prefix = std::string ()) const; - bool save_ascii (std::ostream& os, bool& infnan_warned, - int strip_nan_and_inf) - { return rep->save_ascii (os, infnan_warned, strip_nan_and_inf); } + bool save_ascii (std::ostream& os, bool& infnan_warned) + { return rep->save_ascii (os, infnan_warned); } bool load_ascii (std::istream& is) { return rep->load_ascii (is); }