comparison src/Cell.cc @ 14621:13cc11418393

improve handling of default resize fill value for arrays * Array.cc (Array<T>::resize_fill_value): Return T, not const T&. * Array.h (Array<T>::resize_fill_value): Now virtual member function instead of static. (Array<T>::resize1 (octave_idx_type)): New function. (Array<T>::resize1 (octave_idx_type, const T&)): Eliminate default value for second arg. (Array<T>::resize (octave_idx_type, octave_idx_type)): New function. (Array<T>::resize (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. (Array<T>::resize (const dim_vector&)): New function. (Array<T>::resize (const dim_vector&, const T&)): New function. (Array<T>::resize2 (octave_idx_type, octave_idx_type)): New function. (Array<T>::resize2 (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. (Array<T>::index (const idx_vector&, bool) const): New function. (Array<T>::index (const idx_vector&, bool, const T&) const): Eliminate default value for third arg. (Array<T>::index (const idx_vector&, const idx_vector&, bool) const): New function. (Array<T>::index (const idx_vector&, const idx_vector&, bool, const T&) const): Eliminate default value for third arg. (Array<T>::index (const Array<idx_vector>&, bool) const): New function. (Array<T>::index (const Array<idx_vector>&, const T&) const): Eliminate default value for third arg. (Array<T>::assign (const idx_vector&, const Array<T>&)): New function. (Array<T>::assign (const idx_vector&, const Array<T>&, const T&)): Eliminate default value for third arg. (Array<T>::assign (const idx_vector&, const idx_vector&, const Array<T>&)): New function. (Array<T>::assign (const idx_vector&, const idx_vector&, const Array<T>&, const T&)): Eliminate default value for third arg. (Array<T>::assign (const Array<idx_vector>&, const Array<T>&)): New function. (Array<T>::assign (const Array<idx_vector>&, const Array<T>&, const T&)): Eliminate default value for third arg. * DiagArray2.h (DiagArray2<T>::resize (octave_idx_type, octave_idx_type)): New function. (DiagArray2<T>::resize (octave_idx_type, octave_idx_type, const T&)): Eliminate default value for third arg. * CColVector.h (ComplexColumnVector::resize): Use Complex (0) as default value instead of Array<Complex>::resize_fill_value (). * CMatrix.h (ComplexMatrix::resize): Use Complex (0) as default value instead of Array<Complex>::resize_fill_value (). (ComplexMatrix::resize_fill_value): Delete. * CNDArray.h (ComplexNDArray::resize_fill_value): Delete. * CRowVector.h (ComplexRowVector::resize): Use Complex (0) as default value instead of Array<Complex>::resize_fill_value (). * boolMatrix.h (boolMatrix::resize): Use false as default value instead of resize_fill_value (). (boolMatrix::resize_fill_value): Delete. * boolNDArray.h (boolNDArray::resize_fill_value): Delete. * chMatrix.h (charMatrix::resize): Use 0 as default value instead of resize_fill_value. (charMatrix::resize_fill_value): Delete. * chNDArray.h (charNDArray::resize_fill_value): Delete. * dColVector.h (ColumnVector::resize): Use 0 as default value instead of Array<double>::resize_fill_value (). * dMatrix.h (Matrix::resize): Use 0 as default value instead of resize_fill_value (). (Matrix::resize_fill_value): Delete. * dNDArray.h (NDArray::resize_fill_value): Delete. * dRowVector.h (RowVector::resize): Use 0 as default value instead of Array<double>::resize_fill_value (). * fCColVector.h (FloatComplexColumnVector::resize): Use FloatComplex (0) as default value instead of Array<FloatComplex>::resize_fill_value (). * fCMatrix.h (FloatComplexMatrix::resize): Use FloatComplex (0) as default value instead of resize_fill_value ()). FloatCmplexMatrix::resize_fill_value): Delete. * fCNDArray.h (FloatComplexNDArray::resize_fill_value): Delete. * fCRowVector.h (FloatComplexRowVector::resize): Use FloatComplex (0) as default value instead of Array<FloatComplex>::resize_fill_value (). * fColVector.h (FloatColumnVector::resize): Use 0 as default value instead of Array<float>::resize_fill_value (). * fMatrix.h (FloatMatrix::resize): Use 0 as default value instead of resize_fill_value (). * fMatrix.h (FloatMatrix::resize_fill_value): Delete. * fNDArray.h (FloatNDArray::resize_fill_value): Delete. * fRowVector.h (FloatRowVector::resize): Use 0 as default value instead of Array<float>::resize_fill_value (). * intNDArray.h (intNDArray<T>::resize_fill_value): Delete. * str-vec.h (string_vector::resize): Use std::string as default value instead of resize_fill_value (). * Cell.cc, Cell.h (Cell::Cell, Cell::assign, Cell::index): Use Matrix () as default value instead of resize_fill_value (). (Cell::resize_fill_value): No longer static. * oct-map.cc (octave_map::resize, octave_map::assign, Octave_map::resize, Octave_map::assign): Use Matrix () as default value instead of Cell::resize_fill_value. * oct-obj.h (octave_value_list::resize): Use octave_value () instead of Array<octave_value>::resize_fill_value (). * ov-complex.cc (octave_complex::resize): Use Complex (0) for fill value instead of ComplexNDArray::resize_fill_value (). * ov-float.cc (octave_float_scalar::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-flt-complex.cc (octave_float_complex_scalar::resize): Use Complex (0) for fill value instead of ComplexNDArray::resize_fill_value (). * ov-range.cc (octave_range::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-scalar.cc (octave_scalar::resize): Use 0 for fill value instead of NDArray::resize_fill_value (). * ov-str-mat.cc (octave_char_matrix_str::resize): Use 0 for fill value instead of charNDArray::resize_fill_value ().
author John W. Eaton <jwe@octave.org>
date Thu, 10 May 2012 16:31:02 -0400
parents e8e86ae3abbc
children
comparison
equal deleted inserted replaced
14620:88e67d58b06b 14621:13cc11418393
95 95
96 // Set size to DV, filling with []. Then fill with as many elements of 96 // Set size to DV, filling with []. Then fill with as many elements of
97 // SV as possible. 97 // SV as possible.
98 98
99 Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim) 99 Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim)
100 : Array<octave_value> (dv, resize_fill_value ()) 100 : Array<octave_value> (dv, Matrix ())
101 { 101 {
102 octave_idx_type n = sv.length (); 102 octave_idx_type n = sv.length ();
103 103
104 if (n > 0) 104 if (n > 0)
105 { 105 {
171 case 1: 171 case 1:
172 { 172 {
173 idx_vector i = idx_arg(0).index_vector (); 173 idx_vector i = idx_arg(0).index_vector ();
174 174
175 if (! error_state) 175 if (! error_state)
176 retval = Array<octave_value>::index (i, resize_ok, 176 retval = Array<octave_value>::index (i, resize_ok, Matrix ());
177 resize_fill_value ());
178 } 177 }
179 break; 178 break;
180 179
181 case 2: 180 case 2:
182 { 181 {
185 if (! error_state) 184 if (! error_state)
186 { 185 {
187 idx_vector j = idx_arg(1).index_vector (); 186 idx_vector j = idx_arg(1).index_vector ();
188 187
189 if (! error_state) 188 if (! error_state)
190 retval = Array<octave_value>::index (i, j, resize_ok, 189 retval = Array<octave_value>::index (i, j, resize_ok, Matrix ());
191 resize_fill_value ());
192 } 190 }
193 } 191 }
194 break; 192 break;
195 193
196 default: 194 default:
204 if (error_state) 202 if (error_state)
205 break; 203 break;
206 } 204 }
207 205
208 if (!error_state) 206 if (!error_state)
209 retval = Array<octave_value>::index (iv, resize_ok, 207 retval = Array<octave_value>::index (iv, resize_ok, Matrix ());
210 resize_fill_value ());
211 } 208 }
212 break; 209 break;
213 } 210 }
214 211
215 return retval; 212 return retval;