Mercurial > octave
comparison liboctave/array/Array.cc @ 21100:e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
* libinterp/corefcn/errwarn.h, libinterp/corefcn/errwarn.cc: New header and .cc
file with common errors and warnings for libinterp.
* libinterp/corefcn/module.mk: Add errwarn.h, errwarn.cc to build system.
* liboctave/util/lo-array-errwarn.h, liboctave/util/lo-array-errwarn.cc: New
header and .cc file with common errors and warnings for liboctave.
* liboctave/util/module.mk: Add lo-array-errwarn.h, lo-array-errwarn.cc to
build system.
* lo-array-gripes.h: #include "lo-array-errwarn.h" for access to class
index_exception. Remove const char *error_id_XXX prototypes.
* lo-array-gripes.cc: Remove const char *error_id_XXX initializations.
Remove index_exception method definitions.
* Cell.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, betainc.cc, cellfun.cc,
daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc,
dirfns.cc, eig.cc, fft.cc, fft2.cc, fftn.cc, find.cc, gammainc.cc, gcd.cc,
getgrent.cc, getpwent.cc, graphics.in.h, help.cc, hess.cc, hex2num.cc,
input.cc, inv.cc, jit-typeinfo.cc, load-save.cc, lookup.cc, ls-hdf5.cc,
ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc,
lsode.cc, lu.cc, luinc.cc, max.cc, mgorth.cc, oct-hist.cc, oct-procbuf.cc,
oct-stream.cc, oct.h, pager.cc, pinv.cc, pr-output.cc, quad.cc, qz.cc, rand.cc,
rcond.cc, regexp.cc, schur.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc,
spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, syscalls.cc, typecast.cc, utils.cc, variables.cc, xdiv.cc,
xnorm.cc, xpow.cc, __eigs__.cc, __glpk__.cc, __magick_read__.cc,
__osmesa_print__.cc, audiodevinfo.cc, audioread.cc, chol.cc, dmperm.cc,
fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base-diag.cc, ov-base-int.cc,
ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc,
ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc,
ov-ch-mat.cc, ov-class.cc, ov-complex.cc, ov-complex.h, ov-cs-list.cc,
ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h,
ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-mex-fcn.cc, ov-perm.cc,
ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h,
ov-str-mat.cc, ov-struct.cc, ov-type-conv.h, ov-uint16.cc, ov-uint32.cc,
ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fdm.cc,
op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc,
op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc,
op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc,
op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc,
op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc,
op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc,
op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc,
op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc,
op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc,
op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc,
op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc,
ops.h, lex.ll, pt-assign.cc, pt-eval.cc, pt-idx.cc, pt-loop.cc, pt-mat.cc,
pt-stmt.cc, Array-util.cc, Array-util.h, Array.cc, CColVector.cc,
CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc,
DiagArray2.cc, MDiagArray2.cc, MSparse.cc, PermMatrix.cc, Range.cc, Sparse.cc,
dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc,
dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc,
fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc,
fRowVector.cc, idx-vector.cc, CmplxGEPBAL.cc, dbleGEPBAL.cc, fCmplxGEPBAL.cc,
floatGEPBAL.cc, Sparse-diag-op-defs.h, Sparse-op-defs.h, Sparse-perm-op-defs.h,
mx-inlines.cc, mx-op-defs.h, oct-binmap.h:
Replace 'include "gripes.h"' with 'include "errwarn.h". Change all gripe_XXX
to err_XXX or warn_XXX or errwarn_XXX.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 18 Jan 2016 18:28:06 -0800 |
parents | 99d373870017 |
children | 3ac9f47fb04b |
comparison
equal
deleted
inserted
replaced
21099:52af4092f863 | 21100:e39e05d90788 |
---|---|
188 T& | 188 T& |
189 Array<T>::checkelem (octave_idx_type n) | 189 Array<T>::checkelem (octave_idx_type n) |
190 { | 190 { |
191 // Do checks directly to avoid recomputing slice_len. | 191 // Do checks directly to avoid recomputing slice_len. |
192 if (n < 0) | 192 if (n < 0) |
193 gripe_invalid_index (n); | 193 err_invalid_index (n); |
194 if (n >= slice_len) | 194 if (n >= slice_len) |
195 gripe_index_out_of_range (1, 1, n+1, slice_len, dimensions); | 195 err_index_out_of_range (1, 1, n+1, slice_len, dimensions); |
196 | 196 |
197 return elem (n); | 197 return elem (n); |
198 } | 198 } |
199 | 199 |
200 template <class T> | 200 template <class T> |
222 typename Array<T>::crefT | 222 typename Array<T>::crefT |
223 Array<T>::checkelem (octave_idx_type n) const | 223 Array<T>::checkelem (octave_idx_type n) const |
224 { | 224 { |
225 // Do checks directly to avoid recomputing slice_len. | 225 // Do checks directly to avoid recomputing slice_len. |
226 if (n < 0) | 226 if (n < 0) |
227 gripe_invalid_index (n); | 227 err_invalid_index (n); |
228 if (n >= slice_len) | 228 if (n >= slice_len) |
229 gripe_index_out_of_range (1, 1, n+1, slice_len, dimensions); | 229 err_index_out_of_range (1, 1, n+1, slice_len, dimensions); |
230 | 230 |
231 return elem (n); | 231 return elem (n); |
232 } | 232 } |
233 | 233 |
234 template <class T> | 234 template <class T> |
258 Array<T>::column (octave_idx_type k) const | 258 Array<T>::column (octave_idx_type k) const |
259 { | 259 { |
260 octave_idx_type r = dimensions(0); | 260 octave_idx_type r = dimensions(0); |
261 #ifdef BOUNDS_CHECKING | 261 #ifdef BOUNDS_CHECKING |
262 if (k < 0 || k > dimensions.numel (1)) | 262 if (k < 0 || k > dimensions.numel (1)) |
263 gripe_index_out_of_range (2, 2, k+1, dimensions.numel (1), dimensions); | 263 err_index_out_of_range (2, 2, k+1, dimensions.numel (1), dimensions); |
264 #endif | 264 #endif |
265 | 265 |
266 return Array<T> (*this, dim_vector (r, 1), k*r, k*r + r); | 266 return Array<T> (*this, dim_vector (r, 1), k*r, k*r + r); |
267 } | 267 } |
268 | 268 |
273 octave_idx_type r = dimensions(0); | 273 octave_idx_type r = dimensions(0); |
274 octave_idx_type c = dimensions(1); | 274 octave_idx_type c = dimensions(1); |
275 octave_idx_type p = r*c; | 275 octave_idx_type p = r*c; |
276 #ifdef BOUNDS_CHECKING | 276 #ifdef BOUNDS_CHECKING |
277 if (k < 0 || k > dimensions.numel (2)) | 277 if (k < 0 || k > dimensions.numel (2)) |
278 gripe_index_out_of_range (3, 3, k+1, dimensions.numel (2), dimensions); | 278 err_index_out_of_range (3, 3, k+1, dimensions.numel (2), dimensions); |
279 #endif | 279 #endif |
280 | 280 |
281 return Array<T> (*this, dim_vector (r, c), k*p, k*p + p); | 281 return Array<T> (*this, dim_vector (r, c), k*p, k*p + p); |
282 } | 282 } |
283 | 283 |
285 Array<T> | 285 Array<T> |
286 Array<T>::linear_slice (octave_idx_type lo, octave_idx_type up) const | 286 Array<T>::linear_slice (octave_idx_type lo, octave_idx_type up) const |
287 { | 287 { |
288 #ifdef BOUNDS_CHECKING | 288 #ifdef BOUNDS_CHECKING |
289 if (lo < 0) | 289 if (lo < 0) |
290 gripe_index_out_of_range (1, 1, lo+1, numel (), dimensions); | 290 err_index_out_of_range (1, 1, lo+1, numel (), dimensions); |
291 if (up > numel ()) | 291 if (up > numel ()) |
292 gripe_index_out_of_range (1, 1, up, numel (), dimensions); | 292 err_index_out_of_range (1, 1, up, numel (), dimensions); |
293 #endif | 293 #endif |
294 if (up < lo) up = lo; | 294 if (up < lo) up = lo; |
295 return Array<T> (*this, dim_vector (up - lo, 1), lo, up); | 295 return Array<T> (*this, dim_vector (up - lo, 1), lo, up); |
296 } | 296 } |
297 | 297 |
724 retval = Array<T> (*this, dim_vector (n, 1)); | 724 retval = Array<T> (*this, dim_vector (n, 1)); |
725 } | 725 } |
726 else | 726 else |
727 { | 727 { |
728 if (i.extent (n) != n) | 728 if (i.extent (n) != n) |
729 gripe_index_out_of_range (1, 1, i.extent (n), n, dimensions); // throws | 729 err_index_out_of_range (1, 1, i.extent (n), n, dimensions); // throws |
730 | 730 |
731 // FIXME: this is the only place where orig_dimensions are used. | 731 // FIXME: this is the only place where orig_dimensions are used. |
732 dim_vector rd = i.orig_dimensions (); | 732 dim_vector rd = i.orig_dimensions (); |
733 octave_idx_type il = i.length (n); | 733 octave_idx_type il = i.length (n); |
734 | 734 |
791 retval = Array<T> (*this, dv); | 791 retval = Array<T> (*this, dv); |
792 } | 792 } |
793 else | 793 else |
794 { | 794 { |
795 if (i.extent (r) != r) | 795 if (i.extent (r) != r) |
796 gripe_index_out_of_range (2, 1, i.extent (r), r, dimensions); // throws | 796 err_index_out_of_range (2, 1, i.extent (r), r, dimensions); // throws |
797 if (j.extent (c) != c) | 797 if (j.extent (c) != c) |
798 gripe_index_out_of_range (2, 2, j.extent (c), c, dimensions); // throws | 798 err_index_out_of_range (2, 2, j.extent (c), c, dimensions); // throws |
799 | 799 |
800 octave_idx_type n = numel (); | 800 octave_idx_type n = numel (); |
801 octave_idx_type il = i.length (r); | 801 octave_idx_type il = i.length (r); |
802 octave_idx_type jl = j.length (c); | 802 octave_idx_type jl = j.length (c); |
803 | 803 |
853 // Check for out of bounds conditions. | 853 // Check for out of bounds conditions. |
854 bool all_colons = true; | 854 bool all_colons = true; |
855 for (int i = 0; i < ial; i++) | 855 for (int i = 0; i < ial; i++) |
856 { | 856 { |
857 if (ia(i).extent (dv(i)) != dv(i)) | 857 if (ia(i).extent (dv(i)) != dv(i)) |
858 gripe_index_out_of_range (ial, i+1, ia(i).extent (dv(i)), dv(i), dimensions); // throws | 858 err_index_out_of_range (ial, i+1, ia(i).extent (dv(i)), dv(i), dimensions); // throws |
859 | 859 |
860 all_colons = all_colons && ia(i).is_colon (); | 860 all_colons = all_colons && ia(i).is_colon (); |
861 } | 861 } |
862 | 862 |
863 | 863 |
929 dv = dim_vector (n, 1); | 929 dv = dim_vector (n, 1); |
930 else | 930 else |
931 invalid = true; | 931 invalid = true; |
932 | 932 |
933 if (invalid) | 933 if (invalid) |
934 gripe_invalid_resize (); | 934 err_invalid_resize (); |
935 else | 935 else |
936 { | 936 { |
937 octave_idx_type nx = numel (); | 937 octave_idx_type nx = numel (); |
938 if (n == nx - 1 && n > 0) | 938 if (n == nx - 1 && n > 0) |
939 { | 939 { |
978 *this = tmp; | 978 *this = tmp; |
979 } | 979 } |
980 } | 980 } |
981 } | 981 } |
982 else | 982 else |
983 gripe_invalid_resize (); | 983 err_invalid_resize (); |
984 } | 984 } |
985 | 985 |
986 template <class T> | 986 template <class T> |
987 void | 987 void |
988 Array<T>::resize2 (octave_idx_type r, octave_idx_type c, const T& rfv) | 988 Array<T>::resize2 (octave_idx_type r, octave_idx_type c, const T& rfv) |
1022 | 1022 |
1023 *this = tmp; | 1023 *this = tmp; |
1024 } | 1024 } |
1025 } | 1025 } |
1026 else | 1026 else |
1027 gripe_invalid_resize (); | 1027 err_invalid_resize (); |
1028 | 1028 |
1029 } | 1029 } |
1030 | 1030 |
1031 template<class T> | 1031 template<class T> |
1032 void | 1032 void |
1046 // Do it. | 1046 // Do it. |
1047 rh.resize_fill (data (), tmp.fortran_vec (), rfv); | 1047 rh.resize_fill (data (), tmp.fortran_vec (), rfv); |
1048 *this = tmp; | 1048 *this = tmp; |
1049 } | 1049 } |
1050 else | 1050 else |
1051 gripe_invalid_resize (); | 1051 err_invalid_resize (); |
1052 } | 1052 } |
1053 } | 1053 } |
1054 | 1054 |
1055 template <class T> | 1055 template <class T> |
1056 Array<T> | 1056 Array<T> |
1179 else | 1179 else |
1180 i.assign (rhs.data (), n, fortran_vec ()); | 1180 i.assign (rhs.data (), n, fortran_vec ()); |
1181 } | 1181 } |
1182 } | 1182 } |
1183 else | 1183 else |
1184 gripe_nonconformant ("=", dim_vector(i.length(n),1), rhs.dims()); | 1184 err_nonconformant ("=", dim_vector(i.length(n),1), rhs.dims()); |
1185 } | 1185 } |
1186 | 1186 |
1187 // Assignment to a 2-dimensional array | 1187 // Assignment to a 2-dimensional array |
1188 template <class T> | 1188 template <class T> |
1189 void | 1189 void |
1283 } | 1283 } |
1284 } | 1284 } |
1285 } | 1285 } |
1286 // any empty RHS can be assigned to an empty LHS | 1286 // any empty RHS can be assigned to an empty LHS |
1287 else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0)) | 1287 else if ((il != 0 && jl != 0) || (rhdv(0) != 0 && rhdv(1) != 0)) |
1288 gripe_nonconformant ("=", il, jl, rhs.dim1 (), rhs.dim2 ()); | 1288 err_nonconformant ("=", il, jl, rhs.dim1 (), rhs.dim2 ()); |
1289 } | 1289 } |
1290 | 1290 |
1291 // Assignment to a multi-dimensional array | 1291 // Assignment to a multi-dimensional array |
1292 template <class T> | 1292 template <class T> |
1293 void | 1293 void |
1397 octave_idx_type l = ia(i).length (rdv(i)); | 1397 octave_idx_type l = ia(i).length (rdv(i)); |
1398 lhsempty = lhsempty || (l == 0); | 1398 lhsempty = lhsempty || (l == 0); |
1399 rhsempty = rhsempty || (rhdv(j++) == 0); | 1399 rhsempty = rhsempty || (rhdv(j++) == 0); |
1400 } | 1400 } |
1401 if (! lhsempty || ! rhsempty) | 1401 if (! lhsempty || ! rhsempty) |
1402 gripe_nonconformant ("=", dv, rhdv); | 1402 err_nonconformant ("=", dv, rhdv); |
1403 } | 1403 } |
1404 } | 1404 } |
1405 } | 1405 } |
1406 | 1406 |
1407 /* | 1407 /* |
1422 *this = Array<T> (); | 1422 *this = Array<T> (); |
1423 } | 1423 } |
1424 else if (i.length (n) != 0) | 1424 else if (i.length (n) != 0) |
1425 { | 1425 { |
1426 if (i.extent (n) != n) | 1426 if (i.extent (n) != n) |
1427 gripe_del_index_out_of_range (true, i.extent (n), n); | 1427 err_del_index_out_of_range (true, i.extent (n), n); |
1428 | 1428 |
1429 octave_idx_type l, u; | 1429 octave_idx_type l, u; |
1430 bool col_vec = ndims () == 2 && columns () == 1 && rows () != 1; | 1430 bool col_vec = ndims () == 2 && columns () == 1 && rows () != 1; |
1431 if (i.is_scalar () && i(0) == n-1 && dimensions.is_vector ()) | 1431 if (i.is_scalar () && i(0) == n-1 && dimensions.is_vector ()) |
1432 { | 1432 { |
1469 *this = Array<T> (); | 1469 *this = Array<T> (); |
1470 } | 1470 } |
1471 else if (i.length (n) != 0) | 1471 else if (i.length (n) != 0) |
1472 { | 1472 { |
1473 if (i.extent (n) != n) | 1473 if (i.extent (n) != n) |
1474 gripe_del_index_out_of_range (false, i.extent (n), n); | 1474 err_del_index_out_of_range (false, i.extent (n), n); |
1475 | 1475 |
1476 octave_idx_type l, u; | 1476 octave_idx_type l, u; |
1477 | 1477 |
1478 if (i.is_cont_range (n, l, u)) | 1478 if (i.is_cont_range (n, l, u)) |
1479 { | 1479 { |