comparison src/ls-oct-ascii.cc @ 5958:85c7dc4afe6b

[project @ 2006-08-23 18:35:38 by jwe]
author jwe
date Wed, 23 Aug 2006 18:35:39 +0000
parents cdef72fcd206
children 4508e9d73ea1
comparison
equal deleted inserted replaced
5957:370f785718be 5958:85c7dc4afe6b
305 305
306 // Save the data from TC along with the corresponding NAME, and global 306 // Save the data from TC along with the corresponding NAME, and global
307 // flag MARK_AS_GLOBAL on stream OS in the plain text format described 307 // flag MARK_AS_GLOBAL on stream OS in the plain text format described
308 // above for load_ascii_data. If NAME is empty, the name: line is not 308 // above for load_ascii_data. If NAME is empty, the name: line is not
309 // generated. PRECISION specifies the number of decimal digits to print. 309 // generated. PRECISION specifies the number of decimal digits to print.
310 // If STRIP_NAN_AND_INF is 1, rows containing NaNs are deleted,
311 // and Infinite values are converted to +/-OCT_RBV (A Real Big Value,
312 // but not so big that gnuplot can't handle it when trying to compute
313 // axis ranges, etc.). If STRIP_NAN_AND_INF is 2, rows containing
314 // NaNs are converted to blank lines in the output file and infinite
315 // values are converted to +/-OCT_RBV.
316 // 310 //
317 // Assumes ranges and strings cannot contain Inf or NaN values. 311 // Assumes ranges and strings cannot contain Inf or NaN values.
318 // 312 //
319 // Returns 1 for success and 0 for failure. 313 // Returns 1 for success and 0 for failure.
320 314
321 // FIXME -- should probably write the help string here too. 315 // FIXME -- should probably write the help string here too.
322 316
323 bool 317 bool
324 save_ascii_data (std::ostream& os, const octave_value& val_arg, 318 save_ascii_data (std::ostream& os, const octave_value& val_arg,
325 const std::string& name, bool& infnan_warned, 319 const std::string& name, bool& infnan_warned,
326 int strip_nan_and_inf, bool mark_as_global, 320 bool mark_as_global, int precision)
327 int precision)
328 { 321 {
329 bool success = true; 322 bool success = true;
330 323
331 if (! name.empty ()) 324 if (! name.empty ())
332 os << "# name: " << name << "\n"; 325 os << "# name: " << name << "\n";
342 precision = Vsave_precision; 335 precision = Vsave_precision;
343 336
344 long old_precision = os.precision (); 337 long old_precision = os.precision ();
345 os.precision (precision); 338 os.precision (precision);
346 339
347 success = val . save_ascii (os, infnan_warned, strip_nan_and_inf); 340 success = val . save_ascii (os, infnan_warned);
348 341
349 os.precision (old_precision); 342 os.precision (old_precision);
350 343
351 return (os && success); 344 return (os && success);
352 } 345 }
355 save_ascii_data_for_plotting (std::ostream& os, const octave_value& t, 348 save_ascii_data_for_plotting (std::ostream& os, const octave_value& t,
356 const std::string& name) 349 const std::string& name)
357 { 350 {
358 bool infnan_warned = true; 351 bool infnan_warned = true;
359 352
360 return save_ascii_data (os, t, name, infnan_warned, 2, false, 0); 353 return save_ascii_data (os, t, name, infnan_warned, false, 0);
361 } 354 }
362 355
363 // Maybe this should be a static function in tree-plot.cc? 356 // Maybe this should be a static function in tree-plot.cc?
364 357
365 // If TC is matrix, save it on stream OS in a format useful for 358 // If TC is matrix, save it on stream OS in a format useful for