Mercurial > octave-nkf
comparison liboctave/Array.cc @ 4661:12b6fbd57436
[project @ 2003-11-25 05:41:35 by jwe]
author | jwe |
---|---|
date | Tue, 25 Nov 2003 05:41:36 +0000 |
parents | a585a2dfca6c |
children | 6639c2574023 |
comparison
equal
deleted
inserted
replaced
4660:5df5c9c5c166 | 4661:12b6fbd57436 |
---|---|
38 #include "Array-flags.h" | 38 #include "Array-flags.h" |
39 #include "Array-util.h" | 39 #include "Array-util.h" |
40 #include "Range.h" | 40 #include "Range.h" |
41 #include "idx-vector.h" | 41 #include "idx-vector.h" |
42 #include "lo-error.h" | 42 #include "lo-error.h" |
43 #include "lo-sstream.h" | |
43 | 44 |
44 // One dimensional array class. Handles the reference counting for | 45 // One dimensional array class. Handles the reference counting for |
45 // all the derived classes. | 46 // all the derived classes. |
46 | 47 |
47 template <class T> | 48 template <class T> |
317 | 318 |
318 template <class T> | 319 template <class T> |
319 T | 320 T |
320 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) const | 321 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) const |
321 { | 322 { |
322 // XXX FIXME XXX -- report index values too! | 323 OSSTREAM buf; |
323 | 324 |
324 (*current_liboctave_error_handler) ("range error in Array"); | 325 buf << fcn << " ("; |
326 | |
327 int n = ra_idx.length (); | |
328 | |
329 if (n > 0) | |
330 buf << ra_idx(0); | |
331 | |
332 for (int i = 1; i < n; i++) | |
333 buf << ", " << ra_idx(i); | |
334 | |
335 buf << "): range error"; | |
336 | |
337 buf << OSSTREAM_ENDS; | |
338 | |
339 (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); | |
340 | |
341 OSSTREAM_FREEZE (buf); | |
325 | 342 |
326 return T (); | 343 return T (); |
327 } | 344 } |
328 | 345 |
329 template <class T> | 346 template <class T> |
330 T& | 347 T& |
331 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) | 348 Array<T>::range_error (const char *fcn, const Array<int>& ra_idx) |
332 { | 349 { |
333 // XXX FIXME XXX -- report index values too! | 350 OSSTREAM buf; |
334 | 351 |
335 (*current_liboctave_error_handler) ("range error in Array"); | 352 buf << fcn << " ("; |
353 | |
354 int n = ra_idx.length (); | |
355 | |
356 if (n > 0) | |
357 buf << ra_idx(0); | |
358 | |
359 for (int i = 1; i < n; i++) | |
360 buf << ", " << ra_idx(i); | |
361 | |
362 buf << "): range error"; | |
363 | |
364 buf << OSSTREAM_ENDS; | |
365 | |
366 (*current_liboctave_error_handler) (OSSTREAM_C_STR (buf)); | |
367 | |
368 OSSTREAM_FREEZE (buf); | |
336 | 369 |
337 static T foo; | 370 static T foo; |
338 return foo; | 371 return foo; |
339 } | 372 } |
340 | 373 |
1964 return retval; | 1997 return retval; |
1965 } | 1998 } |
1966 | 1999 |
1967 template <class T> | 2000 template <class T> |
1968 Array<T> | 2001 Array<T> |
1969 Array<T>::index (Array<idx_vector>& ra_idx, int resize_ok, const T& rfv) const | 2002 Array<T>::index (Array<idx_vector>& ra_idx, int resize_ok, const T&) const |
1970 { | 2003 { |
1971 // This function handles all calls with more than one idx. | 2004 // This function handles all calls with more than one idx. |
1972 // For (3x3x3), the call can be A(2,5), A(2,:,:), A(3,2,3) etc. | 2005 // For (3x3x3), the call can be A(2,5), A(2,:,:), A(3,2,3) etc. |
1973 | 2006 |
1974 Array<T> retval; | 2007 Array<T> retval; |