Mercurial > hg > octave-nkf
changeset 4459:75ee1995d2b4
[project @ 2003-07-11 17:46:41 by jwe]
author | jwe |
---|---|
date | Fri, 11 Jul 2003 17:46:41 +0000 |
parents | 2274f58d9b80 |
children | cef48c4b902d |
files | liboctave/Array.h liboctave/Array2-idx.h liboctave/Array2.h liboctave/ArrayN.h liboctave/ChangeLog src/ChangeLog src/TEMPLATE-INST/Array-tc.cc |
diffstat | 7 files changed, 39 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/Array.h +++ b/liboctave/Array.h @@ -48,6 +48,13 @@ // all the derived classes. template <class T> +T +resize_fill_value (const T& x) +{ + return x; +} + +template <class T> class Array { @@ -253,11 +260,11 @@ Array<T> value (void); Array<T> index (idx_vector& i, int resize_ok = 0, - const T& rfv = Array<T>::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif - static T resize_fill_value (void) { return T (); } + // static T resize_fill_value (void) { return T (); } void print_info (std::ostream& os, const std::string& prefix) const; }; @@ -266,11 +273,13 @@ int 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, Array<LT>::resize_fill_value ()); + // return assign (lhs, rhs, Array<LT>::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } #endif
--- a/liboctave/Array2-idx.h +++ b/liboctave/Array2-idx.h @@ -56,8 +56,7 @@ template <class T> Array2<T> -Array2<T>::index (idx_vector& idx_arg, int resize_ok, - const T& resize_fill_value) const +Array2<T>::index (idx_vector& idx_arg, int resize_ok, const T& rfv) const { Array2<T> retval; @@ -152,7 +151,7 @@ { int ii = idx_arg.elem (k++); if (ii >= orig_len) - retval.elem (i, j) = resize_fill_value; + retval.elem (i, j) = rfv; else { int fr = ii % nr; @@ -171,7 +170,7 @@ template <class T> Array2<T> Array2<T>::index (idx_vector& idx_i, idx_vector& idx_j, int resize_ok, - const T& resize_fill_value) const + const T& rfv) const { Array2<T> retval; @@ -202,7 +201,7 @@ { int ii = idx_i.elem (i); if (ii >= nr || jj >= nc) - retval.elem (i, j) = resize_fill_value; + retval.elem (i, j) = rfv; else retval.elem (i, j) = elem (ii, jj); } @@ -497,14 +496,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, resize_fill_value); \ + lhs.resize (new_nr, new_nc, rfv); \ } \ } \ while (0) template <class LT, class RT> int -assign (Array2<LT>& lhs, const Array2<RT>& rhs, const LT& resize_fill_value) +assign (Array2<LT>& lhs, const Array2<RT>& rhs, const LT& rfv) { int retval = 1;
--- a/liboctave/Array2.h +++ b/liboctave/Array2.h @@ -182,10 +182,10 @@ Array2<T> value (void); Array2<T> index (idx_vector& i, int resize_ok = 0, - const T& rfv = Array<T>::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; Array2<T> index (idx_vector& i, idx_vector& j, int resize_ok = 0, - const T& rfv = Array<T>::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif @@ -200,7 +200,7 @@ int assign (Array2<LT>& lhs, const Array2<RT>& rhs) { - return assign (lhs, rhs, Array<LT>::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } #endif
--- a/liboctave/ArrayN.h +++ b/liboctave/ArrayN.h @@ -181,10 +181,10 @@ ArrayN<T> value (void); ArrayN<T> index (idx_vector& ra_idx, int resize_ok = 0, - const T& rfv = Array<T>::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; ArrayN<T> index (Array<idx_vector>& ra_idx, int resize_ok = 0, - const T& rfv = Array<T>::resize_fill_value ()) const; + const T& rfv = resize_fill_value (T ())) const; #endif }; @@ -197,7 +197,7 @@ int assign (ArrayN<LT>& lhs, const ArrayN<RT>& rhs) { - return assign (lhs, rhs, Array<LT>::resize_fill_value ()); + return assign (lhs, rhs, resize_fill_value (LT ())); } template <class T>
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2003-07-11 Russell Standish <R.Standish@unsw.edu.au> + + * Array.h (resize_fill_value): Now a top-level template function. + Accept object as argument. Change all uses. + 2003-07-09 John W. Eaton <jwe@bevo.che.wisc.edu> * Array-flags.cc, Array-flags.h (liboctave_pcv_flag): Delete.
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2003-07-11 Russell Standish <R.Standish@unsw.edu.au> + + * TEMPLATE-INST/Array-tc.cc (resize_fill_value): Provide + specialization. + 2003-07-10 John W. Eaton <jwe@bevo.che.wisc.edu> * strfns.cc (Fchar): Force string conversions without warnings.
--- a/src/TEMPLATE-INST/Array-tc.cc +++ b/src/TEMPLATE-INST/Array-tc.cc @@ -27,6 +27,8 @@ #endif #include "Array.h" + + #include "Array.cc" #include "Array2.h" @@ -37,9 +39,8 @@ #include "oct-obj.h" -template<> -octave_value -Array<octave_value>::resize_fill_value (void) +octave_value +resize_fill_value (const octave_value& x) { static octave_value retval = octave_value (Matrix ()); return retval; @@ -47,6 +48,7 @@ template class Array<octave_value>; + template int assign (Array<octave_value>&, const Array<octave_value>&); template int assign (Array<octave_value>&,