Mercurial > hg > octave-thorsten
comparison liboctave/dMatrix.cc @ 5956:cdef72fcd206
[project @ 2006-08-22 20:36:56 by jwe]
author | jwe |
---|---|
date | Tue, 22 Aug 2006 20:36:57 +0000 |
parents | c038c2947ee1 |
children | 85c7dc4afe6b |
comparison
equal
deleted
inserted
replaced
5955:fc46f9c99028 | 5956:cdef72fcd206 |
---|---|
2849 } | 2849 } |
2850 | 2850 |
2851 return result; | 2851 return result; |
2852 } | 2852 } |
2853 | 2853 |
2854 // Used when converting Inf to something that gnuplot can read. | |
2855 | |
2856 #ifndef OCT_RBV | |
2857 #define OCT_RBV DBL_MAX / 100.0 | |
2858 #endif | |
2859 | |
2860 std::ostream& | |
2861 Matrix::save_ascii (std::ostream& os, bool& infnan_warned, | |
2862 int strip_nan_and_inf) | |
2863 { | |
2864 if (strip_nan_and_inf) | |
2865 { | |
2866 octave_idx_type nr = rows (); | |
2867 octave_idx_type nc = columns (); | |
2868 | |
2869 for (octave_idx_type i = 0; i < nr; i++) | |
2870 { | |
2871 if (strip_nan_and_inf) | |
2872 { | |
2873 for (octave_idx_type j = 0; j < nc; j++) | |
2874 { | |
2875 double d = elem (i, j); | |
2876 | |
2877 if (xisnan (d)) | |
2878 { | |
2879 if (strip_nan_and_inf == 1) | |
2880 goto next_row; | |
2881 else if (strip_nan_and_inf == 2) | |
2882 goto next_row_with_newline; | |
2883 } | |
2884 } | |
2885 } | |
2886 | |
2887 for (octave_idx_type j = 0; j < nc; j++) | |
2888 { | |
2889 double d = elem (i, j); | |
2890 | |
2891 if (strip_nan_and_inf) | |
2892 { | |
2893 if (xisinf (d)) | |
2894 d = d > 0 ? OCT_RBV : -OCT_RBV; | |
2895 } | |
2896 else if (! infnan_warned && (xisnan (d) || xisinf (d))) | |
2897 { | |
2898 (*current_liboctave_warning_handler) | |
2899 ("save: Inf or NaN values may not be reloadable"); | |
2900 | |
2901 infnan_warned = true; | |
2902 } | |
2903 | |
2904 octave_write_double (os, d); | |
2905 | |
2906 os << " "; | |
2907 } | |
2908 | |
2909 next_row_with_newline: | |
2910 os << "\n"; | |
2911 | |
2912 next_row: | |
2913 continue; | |
2914 } | |
2915 } | |
2916 else | |
2917 os << *this; | |
2918 | |
2919 return os; | |
2920 } | |
2921 | |
2854 std::ostream& | 2922 std::ostream& |
2855 operator << (std::ostream& os, const Matrix& a) | 2923 operator << (std::ostream& os, const Matrix& a) |
2856 { | 2924 { |
2857 for (octave_idx_type i = 0; i < a.rows (); i++) | 2925 for (octave_idx_type i = 0; i < a.rows (); i++) |
2858 { | 2926 { |