Mercurial > hg > octave-avbm
changeset 3836:b8c1cb5b9fd9
[project @ 2001-05-31 19:30:49 by jwe]
author | jwe |
---|---|
date | Thu, 31 May 2001 19:30:52 +0000 |
parents | 47ee5e57a350 |
children | bb3e654d6684 |
files | liboctave/Array-C.cc liboctave/Array-b.cc liboctave/Array-ch.cc liboctave/Array-d.cc liboctave/Array-i.cc liboctave/Array-idx.h liboctave/Array-s.cc liboctave/Array.h liboctave/Array2-idx.h liboctave/Array2.h liboctave/Array3-idx.h liboctave/Array3.h liboctave/ArrayN-idx.h liboctave/ArrayN.h liboctave/ChangeLog liboctave/chMatrix.cc liboctave/chMatrix.h scripts/ChangeLog scripts/image/saveimage.m src/ChangeLog src/load-save.cc src/ov-bool-mat.cc src/ov-cx-mat.cc src/ov-re-mat.cc src/ov-re-nd-array.cc src/ov-str-mat.cc src/pt-mat.cc src/pt-mat.h |
diffstat | 28 files changed, 160 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array-C.cc +++ b/liboctave/Array-C.cc @@ -39,6 +39,12 @@ template int assign (Array<Complex>&, const Array<short>&); template int assign (Array<Complex>&, const Array<char>&); +template int assign (Array<Complex>&, const Array<Complex>&, const Complex&); +template int assign (Array<Complex>&, const Array<double>&, const Complex&); +template int assign (Array<Complex>&, const Array<int>&, const Complex&); +template int assign (Array<Complex>&, const Array<short>&, const Complex&); +template int assign (Array<Complex>&, const Array<char>&, const Complex&); + #include "Array2.h" #include "Array2.cc" @@ -50,6 +56,12 @@ template int assign (Array2<Complex>&, const Array2<short>&); template int assign (Array2<Complex>&, const Array2<char>&); +template int assign (Array2<Complex>&, const Array2<Complex>&, const Complex&); +template int assign (Array2<Complex>&, const Array2<double>&, const Complex&); +template int assign (Array2<Complex>&, const Array2<int>&, const Complex&); +template int assign (Array2<Complex>&, const Array2<short>&, const Complex&); +template int assign (Array2<Complex>&, const Array2<char>&, const Complex&); + #include "DiagArray2.h" #include "DiagArray2.cc"
--- a/liboctave/Array-b.cc +++ b/liboctave/Array-b.cc @@ -33,6 +33,8 @@ template int assign (Array<bool>&, const Array<bool>&); +template int assign (Array<bool>&, const Array<bool>&, const bool&); + #include "Array2.h" #include "Array2.cc" @@ -40,6 +42,8 @@ template int assign (Array2<bool>&, const Array2<bool>&); +template int assign (Array2<bool>&, const Array2<bool>&, const bool&); + #include "DiagArray2.h" #include "DiagArray2.cc"
--- a/liboctave/Array-ch.cc +++ b/liboctave/Array-ch.cc @@ -33,6 +33,8 @@ template int assign (Array<char>&, const Array<char>&); +template int assign (Array<char>&, const Array<char>&, const char&); + #include "Array2.h" #include "Array2.cc" @@ -40,6 +42,8 @@ template int assign (Array2<char>&, const Array2<char>&); +template int assign (Array2<char>&, const Array2<char>&, const char&); + #include "DiagArray2.h" #include "DiagArray2.cc"
--- a/liboctave/Array-d.cc +++ b/liboctave/Array-d.cc @@ -36,6 +36,11 @@ template int assign (Array<double>&, const Array<short>&); template int assign (Array<double>&, const Array<char>&); +template int assign (Array<double>&, const Array<double>&, const double&); +template int assign (Array<double>&, const Array<int>&, const double&); +template int assign (Array<double>&, const Array<short>&, const double&); +template int assign (Array<double>&, const Array<char>&, const double&); + #include "Array2.h" #include "Array2.cc" @@ -46,6 +51,11 @@ template int assign (Array2<double>&, const Array2<short>&); template int assign (Array2<double>&, const Array2<char>&); +template int assign (Array2<double>&, const Array2<double>&, const double&); +template int assign (Array2<double>&, const Array2<int>&, const double&); +template int assign (Array2<double>&, const Array2<short>&, const double&); +template int assign (Array2<double>&, const Array2<char>&, const double&); + #include "ArrayN.h" #include "ArrayN.cc"
--- a/liboctave/Array-i.cc +++ b/liboctave/Array-i.cc @@ -35,6 +35,10 @@ template int assign (Array<int>&, const Array<short>&); template int assign (Array<int>&, const Array<char>&); +template int assign (Array<int>&, const Array<int>&, const int&); +template int assign (Array<int>&, const Array<short>&, const int&); +template int assign (Array<int>&, const Array<char>&, const int&); + #include "Array2.h" #include "Array2.cc" @@ -44,6 +48,10 @@ template int assign (Array2<int>&, const Array2<short>&); template int assign (Array2<int>&, const Array2<char>&); +template int assign (Array2<int>&, const Array2<int>&, const int&); +template int assign (Array2<int>&, const Array2<short>&, const int&); +template int assign (Array2<int>&, const Array2<char>&, const int&); + #include "DiagArray2.h" #include "DiagArray2.cc"
--- a/liboctave/Array-idx.h +++ b/liboctave/Array-idx.h @@ -177,7 +177,7 @@ template <class LT, class RT> int -assign (Array<LT>& lhs, const Array<RT>& rhs) +assign (Array<LT>& lhs, const Array<RT>& 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<LT> (0)); + lhs.resize (max_idx, resize_fill_value); } if (rhs_len == n)
--- a/liboctave/Array-s.cc +++ b/liboctave/Array-s.cc @@ -34,6 +34,9 @@ template int assign (Array<short>&, const Array<short>&); template int assign (Array<short>&, const Array<char>&); +template int assign (Array<short>&, const Array<short>&, const short&); +template int assign (Array<short>&, const Array<char>&, const short&); + #include "Array2.h" #include "Array2.cc" @@ -42,6 +45,9 @@ template int assign (Array2<short>&, const Array2<short>&); template int assign (Array2<short>&, const Array2<char>&); +template int assign (Array2<short>&, const Array2<short>&, const short&); +template int assign (Array2<short>&, const Array2<char>&, const short&); + #include "DiagArray2.h" #include "DiagArray2.cc"
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -252,7 +252,14 @@ template <class LT, class RT> int -assign (Array<LT>& lhs, const Array<RT>& rhs); +assign (Array<LT>& lhs, const Array<RT>& rhs, const LT& resize_fill_value); + +template <class LT, class RT> +int +assign (Array<LT>& lhs, const Array<RT>& rhs) +{ + return assign (lhs, rhs, static_cast<LT> (0)); +} #endif
--- 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<LT> (0)); \ + lhs.resize (new_nr, new_nc, resize_fill_value); \ } \ } \ while (0) template <class LT, class RT> int -assign (Array2<LT>& lhs, const Array2<RT>& rhs) +assign (Array2<LT>& lhs, const Array2<RT>& rhs, const LT& resize_fill_value) { int retval = 1;
--- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -188,7 +188,14 @@ template <class LT, class RT> int -assign (Array2<LT>& lhs, const Array2<RT>& rhs); +assign (Array2<LT>& lhs, const Array2<RT>& rhs, const LT& resize_fill_value); + +template <class LT, class RT> +int +assign (Array2<LT>& lhs, const Array2<RT>& rhs) +{ + return assign (lhs, rhs, static_cast<LT> (0)); +} #endif
--- a/liboctave/Array3-idx.h +++ b/liboctave/Array3-idx.h @@ -43,7 +43,7 @@ template <class LT, class RT> int -assign (Array3<LT>&, const Array3<RT>&) +assign (Array3<LT>&, const Array3<RT>&, const LT&) { assert (0); return 0;
--- a/liboctave/Array3.h +++ b/liboctave/Array3.h @@ -158,7 +158,14 @@ template <class LT, class RT> int -assign (Array3<LT>& lhs, const Array3<RT>& rhs); +assign (Array3<LT>& lhs, const Array3<RT>& rhs, const LT& resize_fill_value); + +template <class LT, class RT> +int +assign (Array3<LT>& lhs, const Array3<RT>& rhs) +{ + return assign (lhs, rhs, static_cast<LT> (0)); +} #endif
--- a/liboctave/ArrayN-idx.h +++ b/liboctave/ArrayN-idx.h @@ -257,7 +257,7 @@ template <class LT, class RT> int -assign (ArrayN<LT>&, const ArrayN<RT>&) +assign (ArrayN<LT>&, const ArrayN<RT>&, const LT&) { assert (0); return 0;
--- a/liboctave/ArrayN.h +++ b/liboctave/ArrayN.h @@ -187,7 +187,14 @@ template <class LT, class RT> int -assign (ArrayN<LT>& lhs, const ArrayN<RT>& rhs); +assign (ArrayN<LT>& lhs, const ArrayN<RT>& rhs, const LT& resize_fill_value); + +template <class LT, class RT> +int +assign (ArrayN<LT>& lhs, const ArrayN<RT>& rhs) +{ + return assign (lhs, rhs, static_cast<LT> (0)); +} template <class T> std::ostream&
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,34 @@ +2001-05-31 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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<LT>&, const ArrayN<RT>&, const LT&)): + New arg, resize_fill_value. + * ArrayN.h: Provide declaration. + (assign (ArrayN<LT>&, const ArrayN<RT>&): Define here by calling + three arg version. + + * Array3.cc (assign (Array3<LT>&, const Array3<RT>&, const LT&)): + New arg, resize_fill_value. + * Array3.h: Provide declaration. + (assign (Array3<LT>&, const Array3<RT>&): Define here by calling + three arg version. + + * Array2.cc (assign (Array2<LT>&, const Array2<RT>&, const LT&)): + New arg, resize_fill_value. + * Array2.h: Provide declaration. + (assign (Array2<LT>&, const Array2<RT>&): Define here by calling + three arg version. + + * Array.cc (assign (Array<LT>&, const Array<RT>&, const LT&)): + New arg, resize_fill_value. + * Array.h: Provide declaration. + (assign (Array<LT>&, const Array<RT>&): Define here by calling + three arg version. + 2001-05-17 John W. Eaton <jwe@bevo.che.wisc.edu> * pathsearch.cc (dir_path::set_program_name): Set the environment
--- 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; }
--- 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
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2001-05-30 Jean-Francois Cardoso <cardoso@tsi.enst.fr> + + * m/image/saveimage.m: fix saving an image to Postscript format. + 2001-04-18 A. Scottedward Hodel <a.s.hodel@eng.auburn.edu> * control/system/is_stabilizable.m: Pass a to sys2ss, not sys.
--- 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)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,17 @@ +2001-05-31 John W. Eaton <jwe@bevo.che.wisc.edu> + + * 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 <jwe@bevo.che.wisc.edu> * octave.cc (initialize_pathsearch): Save initial value of the
--- 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"; }
--- 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<bool>&, const Array2<bool>&); -#endif - void octave_bool_matrix::assign (const octave_value_list& idx, const boolMatrix& rhs)
--- 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<Complex>&, const Array2<Complex>&); -#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<Complex>&, const Array2<double>&); -#endif - void octave_complex_matrix::assign (const octave_value_list& idx, const Matrix& rhs)
--- 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<double>&, const Array2<double>&); -#endif - void octave_matrix::assign (const octave_value_list& idx, const Matrix& rhs) {
--- 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<double>&, const Array2<double>&); -#endif - void octave_matrix::assign (const octave_value_list& idx, const Matrix& rhs) {
--- 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<char>&, const Array2<char>&); -#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;
--- 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