# HG changeset patch # User jwe # Date 991337452 0 # Node ID b8c1cb5b9fd9d2e7e62e2c747b3dee18534caf13 # Parent 47ee5e57a350e2ea5303939ad53d8b18437a620e [project @ 2001-05-31 19:30:49 by jwe] diff --git a/liboctave/Array-C.cc b/liboctave/Array-C.cc --- a/liboctave/Array-C.cc +++ b/liboctave/Array-C.cc @@ -39,6 +39,12 @@ template int assign (Array&, const Array&); template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const Complex&); +template int assign (Array&, const Array&, const Complex&); +template int assign (Array&, const Array&, const Complex&); +template int assign (Array&, const Array&, const Complex&); +template int assign (Array&, const Array&, const Complex&); + #include "Array2.h" #include "Array2.cc" @@ -50,6 +56,12 @@ template int assign (Array2&, const Array2&); template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const Complex&); +template int assign (Array2&, const Array2&, const Complex&); +template int assign (Array2&, const Array2&, const Complex&); +template int assign (Array2&, const Array2&, const Complex&); +template int assign (Array2&, const Array2&, const Complex&); + #include "DiagArray2.h" #include "DiagArray2.cc" diff --git a/liboctave/Array-b.cc b/liboctave/Array-b.cc --- a/liboctave/Array-b.cc +++ b/liboctave/Array-b.cc @@ -33,6 +33,8 @@ template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const bool&); + #include "Array2.h" #include "Array2.cc" @@ -40,6 +42,8 @@ template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const bool&); + #include "DiagArray2.h" #include "DiagArray2.cc" diff --git a/liboctave/Array-ch.cc b/liboctave/Array-ch.cc --- a/liboctave/Array-ch.cc +++ b/liboctave/Array-ch.cc @@ -33,6 +33,8 @@ template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const char&); + #include "Array2.h" #include "Array2.cc" @@ -40,6 +42,8 @@ template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const char&); + #include "DiagArray2.h" #include "DiagArray2.cc" diff --git a/liboctave/Array-d.cc b/liboctave/Array-d.cc --- a/liboctave/Array-d.cc +++ b/liboctave/Array-d.cc @@ -36,6 +36,11 @@ template int assign (Array&, const Array&); template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const double&); +template int assign (Array&, const Array&, const double&); +template int assign (Array&, const Array&, const double&); +template int assign (Array&, const Array&, const double&); + #include "Array2.h" #include "Array2.cc" @@ -46,6 +51,11 @@ template int assign (Array2&, const Array2&); template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const double&); +template int assign (Array2&, const Array2&, const double&); +template int assign (Array2&, const Array2&, const double&); +template int assign (Array2&, const Array2&, const double&); + #include "ArrayN.h" #include "ArrayN.cc" diff --git a/liboctave/Array-i.cc b/liboctave/Array-i.cc --- a/liboctave/Array-i.cc +++ b/liboctave/Array-i.cc @@ -35,6 +35,10 @@ template int assign (Array&, const Array&); template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const int&); +template int assign (Array&, const Array&, const int&); +template int assign (Array&, const Array&, const int&); + #include "Array2.h" #include "Array2.cc" @@ -44,6 +48,10 @@ template int assign (Array2&, const Array2&); template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const int&); +template int assign (Array2&, const Array2&, const int&); +template int assign (Array2&, const Array2&, const int&); + #include "DiagArray2.h" #include "DiagArray2.cc" diff --git a/liboctave/Array-idx.h b/liboctave/Array-idx.h --- a/liboctave/Array-idx.h +++ b/liboctave/Array-idx.h @@ -177,7 +177,7 @@ template int -assign (Array& lhs, const Array& rhs) +assign (Array& lhs, const Array& rhs, const LT& resize_fill_value) { int retval = 1; @@ -196,7 +196,7 @@ { int max_idx = lhs_idx.max () + 1; if (max_idx > lhs_len) - lhs.resize (max_idx, static_cast (0)); + lhs.resize (max_idx, resize_fill_value); } if (rhs_len == n) diff --git a/liboctave/Array-s.cc b/liboctave/Array-s.cc --- a/liboctave/Array-s.cc +++ b/liboctave/Array-s.cc @@ -34,6 +34,9 @@ template int assign (Array&, const Array&); template int assign (Array&, const Array&); +template int assign (Array&, const Array&, const short&); +template int assign (Array&, const Array&, const short&); + #include "Array2.h" #include "Array2.cc" @@ -42,6 +45,9 @@ template int assign (Array2&, const Array2&); template int assign (Array2&, const Array2&); +template int assign (Array2&, const Array2&, const short&); +template int assign (Array2&, const Array2&, const short&); + #include "DiagArray2.h" #include "DiagArray2.cc" diff --git a/liboctave/Array.h b/liboctave/Array.h --- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -252,7 +252,14 @@ template int -assign (Array& lhs, const Array& rhs); +assign (Array& lhs, const Array& rhs, const LT& resize_fill_value); + +template +int +assign (Array& lhs, const Array& rhs) +{ + return assign (lhs, rhs, static_cast (0)); +} #endif diff --git a/liboctave/Array2-idx.h b/liboctave/Array2-idx.h --- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -493,14 +493,14 @@ int new_nr = max_row_idx > lhs_nr ? max_row_idx : lhs_nr; \ int new_nc = max_col_idx > lhs_nc ? max_col_idx : lhs_nc; \ \ - lhs.resize (new_nr, new_nc, static_cast (0)); \ + lhs.resize (new_nr, new_nc, resize_fill_value); \ } \ } \ while (0) template int -assign (Array2& lhs, const Array2& rhs) +assign (Array2& lhs, const Array2& rhs, const LT& resize_fill_value) { int retval = 1; diff --git a/liboctave/Array2.h b/liboctave/Array2.h --- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -188,7 +188,14 @@ template int -assign (Array2& lhs, const Array2& rhs); +assign (Array2& lhs, const Array2& rhs, const LT& resize_fill_value); + +template +int +assign (Array2& lhs, const Array2& rhs) +{ + return assign (lhs, rhs, static_cast (0)); +} #endif diff --git a/liboctave/Array3-idx.h b/liboctave/Array3-idx.h --- a/liboctave/Array3-idx.h +++ b/liboctave/Array3-idx.h @@ -43,7 +43,7 @@ template int -assign (Array3&, const Array3&) +assign (Array3&, const Array3&, const LT&) { assert (0); return 0; diff --git a/liboctave/Array3.h b/liboctave/Array3.h --- a/liboctave/Array3.h +++ b/liboctave/Array3.h @@ -158,7 +158,14 @@ template int -assign (Array3& lhs, const Array3& rhs); +assign (Array3& lhs, const Array3& rhs, const LT& resize_fill_value); + +template +int +assign (Array3& lhs, const Array3& rhs) +{ + return assign (lhs, rhs, static_cast (0)); +} #endif diff --git a/liboctave/ArrayN-idx.h b/liboctave/ArrayN-idx.h --- a/liboctave/ArrayN-idx.h +++ b/liboctave/ArrayN-idx.h @@ -257,7 +257,7 @@ template int -assign (ArrayN&, const ArrayN&) +assign (ArrayN&, const ArrayN&, const LT&) { assert (0); return 0; diff --git a/liboctave/ArrayN.h b/liboctave/ArrayN.h --- a/liboctave/ArrayN.h +++ b/liboctave/ArrayN.h @@ -187,7 +187,14 @@ template int -assign (ArrayN& lhs, const ArrayN& rhs); +assign (ArrayN& lhs, const ArrayN& rhs, const LT& resize_fill_value); + +template +int +assign (ArrayN& lhs, const ArrayN& rhs) +{ + return assign (lhs, rhs, static_cast (0)); +} template std::ostream& diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,34 @@ +2001-05-31 John W. Eaton + + * chMatrix.cc (charMatrix::row_as_string): New parameter, raw. + + * Array-i.cc, Array-s.cc, Array-d.cc, Array-ch.cc, Array-C.cc, + Array-b.cc: Instantiate three arg assign functions. + + * ArrayN.cc (assign (ArrayN&, const ArrayN&, const LT&)): + New arg, resize_fill_value. + * ArrayN.h: Provide declaration. + (assign (ArrayN&, const ArrayN&): Define here by calling + three arg version. + + * Array3.cc (assign (Array3&, const Array3&, const LT&)): + New arg, resize_fill_value. + * Array3.h: Provide declaration. + (assign (Array3&, const Array3&): Define here by calling + three arg version. + + * Array2.cc (assign (Array2&, const Array2&, const LT&)): + New arg, resize_fill_value. + * Array2.h: Provide declaration. + (assign (Array2&, const Array2&): Define here by calling + three arg version. + + * Array.cc (assign (Array&, const Array&, const LT&)): + New arg, resize_fill_value. + * Array.h: Provide declaration. + (assign (Array&, const Array&): Define here by calling + three arg version. + 2001-05-17 John W. Eaton * pathsearch.cc (dir_path::set_program_name): Set the environment diff --git a/liboctave/chMatrix.cc b/liboctave/chMatrix.cc --- a/liboctave/chMatrix.cc +++ b/liboctave/chMatrix.cc @@ -129,7 +129,7 @@ } std::string -charMatrix::row_as_string (int r, bool strip_ws) const +charMatrix::row_as_string (int r, bool strip_ws, bool raw) const { std::string retval; @@ -150,23 +150,26 @@ for (int i = 0; i < nc; i++) retval[i] = elem (r, i); - if (strip_ws) + if (! raw) { - while (--nc >= 0) + if (strip_ws) { - char c = retval[nc]; - if (c && c != ' ') - break; + while (--nc >= 0) + { + char c = retval[nc]; + if (c && c != ' ') + break; + } } + else + { + while (--nc >= 0) + if (retval[nc]) + break; + } + + retval.resize (nc+1); } - else - { - while (--nc >= 0) - if (retval[nc]) - break; - } - - retval.resize (nc+1); return retval; } diff --git a/liboctave/chMatrix.h b/liboctave/chMatrix.h --- a/liboctave/chMatrix.h +++ b/liboctave/chMatrix.h @@ -65,7 +65,7 @@ charMatrix& insert (const char *s, int r, int c); charMatrix& insert (const charMatrix& a, int r, int c); - std::string row_as_string (int, bool = false) const; + std::string row_as_string (int, bool strip_ws = false, bool raw = false) const; // resize is the destructive equivalent for this one diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2001-05-30 Jean-Francois Cardoso + + * m/image/saveimage.m: fix saving an image to Postscript format. + 2001-04-18 A. Scottedward Hodel * control/system/is_stabilizable.m: Pass a to sys2ss, not sys. diff --git a/scripts/image/saveimage.m b/scripts/image/saveimage.m --- a/scripts/image/saveimage.m +++ b/scripts/image/saveimage.m @@ -291,7 +291,7 @@ img = map(img); - fmt = "%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x\n"; + fmt = "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n"; fprintf (fid, fmt, img); if (rem (img_sz, 30) != 0) diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-05-31 John W. Eaton + + * ov-cx-mat.cc: Deleve unnecessary instantiation of assign function. + * ov-re-mat.cc: Likewise. + * ov-re-nd-array.cc: Likewise. + * ov-str-mat.cc: Likewise. + * ov-bool-mat.cc: Likewise. + + * load-save.cc (save_ascii_data): When saving string data, get raw + string value for matrix row since there may be embedded nuls. + + * pt-mat.cc (Vstring_fill_char): No longer static. + * pt-mat.h: Provide declaration. + 2001-05-17 John W. Eaton * octave.cc (initialize_pathsearch): Save initial value of the diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -4475,8 +4475,10 @@ { int len = chm.cols (); os << "# length: " << len << "\n"; - std::string tstr = chm.row_as_string (i); + std::string tstr = chm.row_as_string (i, false, true); const char *tmp = tstr.data (); + if (tstr.length () > len) + panic_impossible (); os.write (X_CAST (char *, tmp), len); os << "\n"; } diff --git a/src/ov-bool-mat.cc b/src/ov-bool-mat.cc --- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -78,10 +78,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_bool_matrix::assign (const octave_value_list& idx, const boolMatrix& rhs) diff --git a/src/ov-cx-mat.cc b/src/ov-cx-mat.cc --- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -76,10 +76,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_complex_matrix::assign (const octave_value_list& idx, const ComplexMatrix& rhs) @@ -117,10 +113,6 @@ } } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_complex_matrix::assign (const octave_value_list& idx, const Matrix& rhs) diff --git a/src/ov-re-mat.cc b/src/ov-re-mat.cc --- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -66,10 +66,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_matrix::assign (const octave_value_list& idx, const Matrix& rhs) { diff --git a/src/ov-re-nd-array.cc b/src/ov-re-nd-array.cc --- a/src/ov-re-nd-array.cc +++ b/src/ov-re-nd-array.cc @@ -67,10 +67,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_matrix::assign (const octave_value_list& idx, const Matrix& rhs) { diff --git a/src/ov-str-mat.cc b/src/ov-str-mat.cc --- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -39,6 +39,7 @@ #include "ov-str-mat.h" #include "gripes.h" #include "pr-output.h" +#include "pt-mat.h" DEFINE_OCTAVE_ALLOCATOR (octave_char_matrix_str); @@ -94,10 +95,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -extern void assign (Array2&, const Array2&); -#endif - void octave_char_matrix_str::assign (const octave_value_list& idx, const charMatrix& rhs) @@ -119,7 +116,7 @@ matrix.set_index (i); matrix.set_index (j); - ::assign (matrix, tmp); + ::assign (matrix, tmp, Vstring_fill_char); } break; @@ -129,7 +126,7 @@ matrix.set_index (i); - ::assign (matrix, tmp); + ::assign (matrix, tmp, Vstring_fill_char); } break; diff --git a/src/pt-mat.cc b/src/pt-mat.cc --- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -53,7 +53,7 @@ static bool Vimplicit_num_to_str_ok; // The character to fill with when creating string arrays. -static char Vstring_fill_char; +char Vstring_fill_char = ' '; // General matrices. This list type is much more work to handle than // constant matrices, but it allows us to construct matrices from diff --git a/src/pt-mat.h b/src/pt-mat.h --- a/src/pt-mat.h +++ b/src/pt-mat.h @@ -76,6 +76,9 @@ tree_matrix& operator = (const tree_matrix&); }; +// The character to fill with when creating string arrays. +extern char Vstring_fill_char; + #endif /*