Mercurial > octave-nkf
comparison liboctave/array/CRowVector.cc @ 20267:a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
* liboctave/array/Array.h (Array::length): deprecate for ::numel.
* liboctave/array/Sparse.h (Sparse::length): deprecate for ::numel.
* libgui/graphics/QtHandlesUtils.cc, libgui/src/octave-qt-link.cc,
libinterp/corefcn/Cell.cc, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/cellfun.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl-render.h, libinterp/corefcn/graphics.cc,
libinterp/corefcn/graphics.in.h, libinterp/corefcn/help.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/load-path.cc, libinterp/corefcn/load-save.cc,
libinterp/corefcn/ls-oct-ascii.h, libinterp/corefcn/lsode.cc,
libinterp/corefcn/matrix_type.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h,
libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-stream.cc,
libinterp/corefcn/oct-stream.h, libinterp/corefcn/pr-output.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/rand.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/strfns.cc,
libinterp/corefcn/sub2ind.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/tsearch.cc,
libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc,
libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xpow.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__magick_read__.cc,
libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/ccolamd.cc,
libinterp/dldfcn/colamd.cc, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov.cc,
libinterp/operators/op-int.h, libinterp/parse-tree/pt-pr-code.cc,
liboctave/array/Array-util.cc, liboctave/array/Array.cc,
liboctave/array/CColVector.cc, liboctave/array/CDiagMatrix.cc,
liboctave/array/CMatrix.cc, liboctave/array/CRowVector.cc,
liboctave/array/DiagArray2.cc, liboctave/array/DiagArray2.h,
liboctave/array/MArray.cc, liboctave/array/PermMatrix.cc,
liboctave/array/PermMatrix.h, liboctave/array/Sparse.cc,
liboctave/array/boolMatrix.cc, liboctave/array/chMatrix.cc,
liboctave/array/chNDArray.cc, liboctave/array/dColVector.cc,
liboctave/array/dDiagMatrix.cc, liboctave/array/dMatrix.cc,
liboctave/array/dRowVector.cc, liboctave/array/fCColVector.cc,
liboctave/array/fCDiagMatrix.cc, liboctave/array/fCMatrix.cc,
liboctave/array/fCRowVector.cc, liboctave/array/fColVector.cc,
liboctave/array/fDiagMatrix.cc, liboctave/array/fMatrix.cc,
liboctave/array/fRowVector.cc, liboctave/array/idx-vector.cc,
liboctave/array/intNDArray.cc, liboctave/numeric/CmplxCHOL.cc,
liboctave/numeric/CmplxLU.cc, liboctave/numeric/CmplxQR.cc,
liboctave/numeric/DASPK.cc, liboctave/numeric/DASRT.cc,
liboctave/numeric/DASSL.cc, liboctave/numeric/LSODE.cc,
liboctave/numeric/ODES.cc, liboctave/numeric/ODES.h,
liboctave/numeric/base-dae.h, liboctave/numeric/base-lu.cc,
liboctave/numeric/dbleCHOL.cc, liboctave/numeric/dbleLU.cc,
liboctave/numeric/dbleQR.cc, liboctave/numeric/eigs-base.cc,
liboctave/numeric/fCmplxCHOL.cc, liboctave/numeric/fCmplxLU.cc,
liboctave/numeric/fCmplxQR.cc, liboctave/numeric/floatCHOL.cc,
liboctave/numeric/floatLU.cc, liboctave/numeric/floatQR.cc,
liboctave/numeric/lo-specfun.cc, liboctave/numeric/oct-rand.cc,
liboctave/numeric/oct-spparms.cc, liboctave/numeric/sparse-base-chol.cc,
liboctave/operators/mx-inlines.cc, liboctave/system/file-ops.cc,
liboctave/util/glob-match.h, liboctave/util/kpse.cc,
liboctave/util/lo-regexp.cc, liboctave/util/oct-glob.cc,
liboctave/util/pathsearch.cc, liboctave/util/str-vec.cc,
liboctave/util/str-vec.h, liboctave/util/url-transfer.cc: replace all usage
of Array::length() and Sparse::length() with ::numel().
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sat, 30 May 2015 03:14:07 +0100 |
parents | 4197fc428c7d |
children | 16b9ec39ff46 |
comparison
equal
deleted
inserted
replaced
20266:83792dd9bcc1 | 20267:a9574e3c6e9e |
---|---|
57 // Complex Row Vector class | 57 // Complex Row Vector class |
58 | 58 |
59 bool | 59 bool |
60 ComplexRowVector::operator == (const ComplexRowVector& a) const | 60 ComplexRowVector::operator == (const ComplexRowVector& a) const |
61 { | 61 { |
62 octave_idx_type len = length (); | 62 octave_idx_type len = numel (); |
63 if (len != a.length ()) | 63 if (len != a.numel ()) |
64 return 0; | 64 return 0; |
65 return mx_inline_equal (len, data (), a.data ()); | 65 return mx_inline_equal (len, data (), a.data ()); |
66 } | 66 } |
67 | 67 |
68 bool | 68 bool |
74 // destructive insert/delete/reorder operations | 74 // destructive insert/delete/reorder operations |
75 | 75 |
76 ComplexRowVector& | 76 ComplexRowVector& |
77 ComplexRowVector::insert (const RowVector& a, octave_idx_type c) | 77 ComplexRowVector::insert (const RowVector& a, octave_idx_type c) |
78 { | 78 { |
79 octave_idx_type a_len = a.length (); | 79 octave_idx_type a_len = a.numel (); |
80 | 80 |
81 if (c < 0 || c + a_len > length ()) | 81 if (c < 0 || c + a_len > numel ()) |
82 { | 82 { |
83 (*current_liboctave_error_handler) ("range error for insert"); | 83 (*current_liboctave_error_handler) ("range error for insert"); |
84 return *this; | 84 return *this; |
85 } | 85 } |
86 | 86 |
96 } | 96 } |
97 | 97 |
98 ComplexRowVector& | 98 ComplexRowVector& |
99 ComplexRowVector::insert (const ComplexRowVector& a, octave_idx_type c) | 99 ComplexRowVector::insert (const ComplexRowVector& a, octave_idx_type c) |
100 { | 100 { |
101 octave_idx_type a_len = a.length (); | 101 octave_idx_type a_len = a.numel (); |
102 | 102 |
103 if (c < 0 || c + a_len > length ()) | 103 if (c < 0 || c + a_len > numel ()) |
104 { | 104 { |
105 (*current_liboctave_error_handler) ("range error for insert"); | 105 (*current_liboctave_error_handler) ("range error for insert"); |
106 return *this; | 106 return *this; |
107 } | 107 } |
108 | 108 |
118 } | 118 } |
119 | 119 |
120 ComplexRowVector& | 120 ComplexRowVector& |
121 ComplexRowVector::fill (double val) | 121 ComplexRowVector::fill (double val) |
122 { | 122 { |
123 octave_idx_type len = length (); | 123 octave_idx_type len = numel (); |
124 | 124 |
125 if (len > 0) | 125 if (len > 0) |
126 { | 126 { |
127 make_unique (); | 127 make_unique (); |
128 | 128 |
134 } | 134 } |
135 | 135 |
136 ComplexRowVector& | 136 ComplexRowVector& |
137 ComplexRowVector::fill (const Complex& val) | 137 ComplexRowVector::fill (const Complex& val) |
138 { | 138 { |
139 octave_idx_type len = length (); | 139 octave_idx_type len = numel (); |
140 | 140 |
141 if (len > 0) | 141 if (len > 0) |
142 { | 142 { |
143 make_unique (); | 143 make_unique (); |
144 | 144 |
150 } | 150 } |
151 | 151 |
152 ComplexRowVector& | 152 ComplexRowVector& |
153 ComplexRowVector::fill (double val, octave_idx_type c1, octave_idx_type c2) | 153 ComplexRowVector::fill (double val, octave_idx_type c1, octave_idx_type c2) |
154 { | 154 { |
155 octave_idx_type len = length (); | 155 octave_idx_type len = numel (); |
156 | 156 |
157 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) | 157 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
158 { | 158 { |
159 (*current_liboctave_error_handler) ("range error for fill"); | 159 (*current_liboctave_error_handler) ("range error for fill"); |
160 return *this; | 160 return *this; |
175 | 175 |
176 ComplexRowVector& | 176 ComplexRowVector& |
177 ComplexRowVector::fill (const Complex& val, | 177 ComplexRowVector::fill (const Complex& val, |
178 octave_idx_type c1, octave_idx_type c2) | 178 octave_idx_type c1, octave_idx_type c2) |
179 { | 179 { |
180 octave_idx_type len = length (); | 180 octave_idx_type len = numel (); |
181 | 181 |
182 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) | 182 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
183 { | 183 { |
184 (*current_liboctave_error_handler) ("range error for fill"); | 184 (*current_liboctave_error_handler) ("range error for fill"); |
185 return *this; | 185 return *this; |
199 } | 199 } |
200 | 200 |
201 ComplexRowVector | 201 ComplexRowVector |
202 ComplexRowVector::append (const RowVector& a) const | 202 ComplexRowVector::append (const RowVector& a) const |
203 { | 203 { |
204 octave_idx_type len = length (); | 204 octave_idx_type len = numel (); |
205 octave_idx_type nc_insert = len; | 205 octave_idx_type nc_insert = len; |
206 ComplexRowVector retval (len + a.length ()); | 206 ComplexRowVector retval (len + a.numel ()); |
207 retval.insert (*this, 0); | 207 retval.insert (*this, 0); |
208 retval.insert (a, nc_insert); | 208 retval.insert (a, nc_insert); |
209 return retval; | 209 return retval; |
210 } | 210 } |
211 | 211 |
212 ComplexRowVector | 212 ComplexRowVector |
213 ComplexRowVector::append (const ComplexRowVector& a) const | 213 ComplexRowVector::append (const ComplexRowVector& a) const |
214 { | 214 { |
215 octave_idx_type len = length (); | 215 octave_idx_type len = numel (); |
216 octave_idx_type nc_insert = len; | 216 octave_idx_type nc_insert = len; |
217 ComplexRowVector retval (len + a.length ()); | 217 ComplexRowVector retval (len + a.numel ()); |
218 retval.insert (*this, 0); | 218 retval.insert (*this, 0); |
219 retval.insert (a, nc_insert); | 219 retval.insert (a, nc_insert); |
220 return retval; | 220 return retval; |
221 } | 221 } |
222 | 222 |
269 // row vector by row vector -> row vector operations | 269 // row vector by row vector -> row vector operations |
270 | 270 |
271 ComplexRowVector& | 271 ComplexRowVector& |
272 ComplexRowVector::operator += (const RowVector& a) | 272 ComplexRowVector::operator += (const RowVector& a) |
273 { | 273 { |
274 octave_idx_type len = length (); | 274 octave_idx_type len = numel (); |
275 | 275 |
276 octave_idx_type a_len = a.length (); | 276 octave_idx_type a_len = a.numel (); |
277 | 277 |
278 if (len != a_len) | 278 if (len != a_len) |
279 { | 279 { |
280 gripe_nonconformant ("operator +=", len, a_len); | 280 gripe_nonconformant ("operator +=", len, a_len); |
281 return *this; | 281 return *this; |
291 } | 291 } |
292 | 292 |
293 ComplexRowVector& | 293 ComplexRowVector& |
294 ComplexRowVector::operator -= (const RowVector& a) | 294 ComplexRowVector::operator -= (const RowVector& a) |
295 { | 295 { |
296 octave_idx_type len = length (); | 296 octave_idx_type len = numel (); |
297 | 297 |
298 octave_idx_type a_len = a.length (); | 298 octave_idx_type a_len = a.numel (); |
299 | 299 |
300 if (len != a_len) | 300 if (len != a_len) |
301 { | 301 { |
302 gripe_nonconformant ("operator -=", len, a_len); | 302 gripe_nonconformant ("operator -=", len, a_len); |
303 return *this; | 303 return *this; |
317 ComplexRowVector | 317 ComplexRowVector |
318 operator * (const ComplexRowVector& v, const ComplexMatrix& a) | 318 operator * (const ComplexRowVector& v, const ComplexMatrix& a) |
319 { | 319 { |
320 ComplexRowVector retval; | 320 ComplexRowVector retval; |
321 | 321 |
322 octave_idx_type len = v.length (); | 322 octave_idx_type len = v.numel (); |
323 | 323 |
324 octave_idx_type a_nr = a.rows (); | 324 octave_idx_type a_nr = a.rows (); |
325 octave_idx_type a_nc = a.cols (); | 325 octave_idx_type a_nc = a.cols (); |
326 | 326 |
327 if (a_nr != len) | 327 if (a_nr != len) |
359 // other operations | 359 // other operations |
360 | 360 |
361 Complex | 361 Complex |
362 ComplexRowVector::min (void) const | 362 ComplexRowVector::min (void) const |
363 { | 363 { |
364 octave_idx_type len = length (); | 364 octave_idx_type len = numel (); |
365 if (len == 0) | 365 if (len == 0) |
366 return Complex (0.0); | 366 return Complex (0.0); |
367 | 367 |
368 Complex res = elem (0); | 368 Complex res = elem (0); |
369 double absres = std::abs (res); | 369 double absres = std::abs (res); |
379 } | 379 } |
380 | 380 |
381 Complex | 381 Complex |
382 ComplexRowVector::max (void) const | 382 ComplexRowVector::max (void) const |
383 { | 383 { |
384 octave_idx_type len = length (); | 384 octave_idx_type len = numel (); |
385 if (len == 0) | 385 if (len == 0) |
386 return Complex (0.0); | 386 return Complex (0.0); |
387 | 387 |
388 Complex res = elem (0); | 388 Complex res = elem (0); |
389 double absres = std::abs (res); | 389 double absres = std::abs (res); |
402 | 402 |
403 std::ostream& | 403 std::ostream& |
404 operator << (std::ostream& os, const ComplexRowVector& a) | 404 operator << (std::ostream& os, const ComplexRowVector& a) |
405 { | 405 { |
406 // int field_width = os.precision () + 7; | 406 // int field_width = os.precision () + 7; |
407 for (octave_idx_type i = 0; i < a.length (); i++) | 407 for (octave_idx_type i = 0; i < a.numel (); i++) |
408 os << " " /* setw (field_width) */ << a.elem (i); | 408 os << " " /* setw (field_width) */ << a.elem (i); |
409 return os; | 409 return os; |
410 } | 410 } |
411 | 411 |
412 std::istream& | 412 std::istream& |
413 operator >> (std::istream& is, ComplexRowVector& a) | 413 operator >> (std::istream& is, ComplexRowVector& a) |
414 { | 414 { |
415 octave_idx_type len = a.length (); | 415 octave_idx_type len = a.numel (); |
416 | 416 |
417 if (len > 0) | 417 if (len > 0) |
418 { | 418 { |
419 Complex tmp; | 419 Complex tmp; |
420 for (octave_idx_type i = 0; i < len; i++) | 420 for (octave_idx_type i = 0; i < len; i++) |
443 Complex | 443 Complex |
444 operator * (const ComplexRowVector& v, const ComplexColumnVector& a) | 444 operator * (const ComplexRowVector& v, const ComplexColumnVector& a) |
445 { | 445 { |
446 Complex retval (0.0, 0.0); | 446 Complex retval (0.0, 0.0); |
447 | 447 |
448 octave_idx_type len = v.length (); | 448 octave_idx_type len = v.numel (); |
449 | 449 |
450 octave_idx_type a_len = a.length (); | 450 octave_idx_type a_len = a.numel (); |
451 | 451 |
452 if (len != a_len) | 452 if (len != a_len) |
453 gripe_nonconformant ("operator *", len, a_len); | 453 gripe_nonconformant ("operator *", len, a_len); |
454 else if (len != 0) | 454 else if (len != 0) |
455 F77_FUNC (xzdotu, XZDOTU) (len, v.data (), 1, a.data (), 1, retval); | 455 F77_FUNC (xzdotu, XZDOTU) (len, v.data (), 1, a.data (), 1, retval); |