Mercurial > hg > octave-nkf
annotate liboctave/CColVector.cc @ 10751:717ba2c3eef1
rewrite cell2struct, 1 failing test
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 25 Jun 2010 08:45:22 +0200 |
parents | 4d1fc073fbb7 |
children | 141b3fb5cef7 |
rev | line source |
---|---|
1993 | 1 // ColumnVector manipulations. |
458 | 2 /* |
3 | |
7017 | 4 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2004, |
8920 | 5 2005, 2007, 2008 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10363
diff
changeset
|
6 Copyright (C) 2010 VZLU Prague |
458 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
7016 | 12 Free Software Foundation; either version 3 of the License, or (at your |
13 option) any later version. | |
458 | 14 |
15 Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
458 | 23 |
24 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
1192 | 27 #include <config.h> |
458 | 28 #endif |
29 | |
3503 | 30 #include <iostream> |
458 | 31 |
4669 | 32 #include "Array-util.h" |
1847 | 33 #include "f77-fcn.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7482
diff
changeset
|
34 #include "functor.h" |
1368 | 35 #include "lo-error.h" |
458 | 36 #include "mx-base.h" |
37 #include "mx-inlines.cc" | |
1650 | 38 #include "oct-cmplx.h" |
458 | 39 |
40 // Fortran functions we call. | |
41 | |
42 extern "C" | |
43 { | |
4552 | 44 F77_RET_T |
45 F77_FUNC (zgemv, ZGEMV) (F77_CONST_CHAR_ARG_DECL, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
46 const octave_idx_type&, const octave_idx_type&, const Complex&, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
47 const Complex*, const octave_idx_type&, const Complex*, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
48 const octave_idx_type&, const Complex&, Complex*, const octave_idx_type& |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
49 F77_CHAR_ARG_LEN_DECL); |
458 | 50 } |
51 | |
1360 | 52 // Complex Column Vector class |
458 | 53 |
54 ComplexColumnVector::ComplexColumnVector (const ColumnVector& a) | |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
55 : MArray<Complex> (a) |
458 | 56 { |
57 } | |
58 | |
2386 | 59 bool |
458 | 60 ComplexColumnVector::operator == (const ComplexColumnVector& a) const |
61 { | |
5275 | 62 octave_idx_type len = length (); |
458 | 63 if (len != a.length ()) |
64 return 0; | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
65 return mx_inline_equal (len, data (), a.data ()); |
458 | 66 } |
67 | |
2386 | 68 bool |
458 | 69 ComplexColumnVector::operator != (const ComplexColumnVector& a) const |
70 { | |
71 return !(*this == a); | |
72 } | |
73 | |
74 // destructive insert/delete/reorder operations | |
75 | |
76 ComplexColumnVector& | |
5275 | 77 ComplexColumnVector::insert (const ColumnVector& a, octave_idx_type r) |
458 | 78 { |
5275 | 79 octave_idx_type a_len = a.length (); |
4316 | 80 |
1699 | 81 if (r < 0 || r + a_len > length ()) |
458 | 82 { |
83 (*current_liboctave_error_handler) ("range error for insert"); | |
84 return *this; | |
85 } | |
86 | |
4316 | 87 if (a_len > 0) |
88 { | |
89 make_unique (); | |
90 | |
5275 | 91 for (octave_idx_type i = 0; i < a_len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
92 xelem (r+i) = a.elem (i); |
4316 | 93 } |
458 | 94 |
95 return *this; | |
96 } | |
97 | |
98 ComplexColumnVector& | |
5275 | 99 ComplexColumnVector::insert (const ComplexColumnVector& a, octave_idx_type r) |
458 | 100 { |
5275 | 101 octave_idx_type a_len = a.length (); |
4316 | 102 |
1699 | 103 if (r < 0 || r + a_len > length ()) |
458 | 104 { |
105 (*current_liboctave_error_handler) ("range error for insert"); | |
106 return *this; | |
107 } | |
108 | |
4316 | 109 if (a_len > 0) |
110 { | |
111 make_unique (); | |
112 | |
5275 | 113 for (octave_idx_type i = 0; i < a_len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
114 xelem (r+i) = a.elem (i); |
4316 | 115 } |
458 | 116 |
117 return *this; | |
118 } | |
119 | |
120 ComplexColumnVector& | |
121 ComplexColumnVector::fill (double val) | |
122 { | |
5275 | 123 octave_idx_type len = length (); |
4316 | 124 |
458 | 125 if (len > 0) |
4316 | 126 { |
127 make_unique (); | |
128 | |
5275 | 129 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
130 xelem (i) = val; |
4316 | 131 } |
132 | |
458 | 133 return *this; |
134 } | |
135 | |
136 ComplexColumnVector& | |
137 ComplexColumnVector::fill (const Complex& val) | |
138 { | |
5275 | 139 octave_idx_type len = length (); |
4316 | 140 |
458 | 141 if (len > 0) |
4316 | 142 { |
143 make_unique (); | |
144 | |
5275 | 145 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
146 xelem (i) = val; |
4316 | 147 } |
148 | |
149 | |
458 | 150 return *this; |
151 } | |
152 | |
153 ComplexColumnVector& | |
5275 | 154 ComplexColumnVector::fill (double val, octave_idx_type r1, octave_idx_type r2) |
458 | 155 { |
5275 | 156 octave_idx_type len = length (); |
4316 | 157 |
458 | 158 if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) |
159 { | |
160 (*current_liboctave_error_handler) ("range error for fill"); | |
161 return *this; | |
162 } | |
163 | |
5275 | 164 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
458 | 165 |
4316 | 166 if (r2 >= r1) |
167 { | |
168 make_unique (); | |
169 | |
5275 | 170 for (octave_idx_type i = r1; i <= r2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
171 xelem (i) = val; |
4316 | 172 } |
458 | 173 |
174 return *this; | |
175 } | |
176 | |
177 ComplexColumnVector& | |
5275 | 178 ComplexColumnVector::fill (const Complex& val, octave_idx_type r1, octave_idx_type r2) |
458 | 179 { |
5275 | 180 octave_idx_type len = length (); |
4316 | 181 |
458 | 182 if (r1 < 0 || r2 < 0 || r1 >= len || r2 >= len) |
183 { | |
184 (*current_liboctave_error_handler) ("range error for fill"); | |
185 return *this; | |
186 } | |
187 | |
5275 | 188 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
458 | 189 |
4316 | 190 if (r2 >= r1) |
191 { | |
192 make_unique (); | |
193 | |
5275 | 194 for (octave_idx_type i = r1; i <= r2; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
195 xelem (i) = val; |
4316 | 196 } |
458 | 197 |
198 return *this; | |
199 } | |
200 | |
201 ComplexColumnVector | |
202 ComplexColumnVector::stack (const ColumnVector& a) const | |
203 { | |
5275 | 204 octave_idx_type len = length (); |
205 octave_idx_type nr_insert = len; | |
458 | 206 ComplexColumnVector retval (len + a.length ()); |
207 retval.insert (*this, 0); | |
208 retval.insert (a, nr_insert); | |
209 return retval; | |
210 } | |
211 | |
212 ComplexColumnVector | |
213 ComplexColumnVector::stack (const ComplexColumnVector& a) const | |
214 { | |
5275 | 215 octave_idx_type len = length (); |
216 octave_idx_type nr_insert = len; | |
458 | 217 ComplexColumnVector retval (len + a.length ()); |
218 retval.insert (*this, 0); | |
219 retval.insert (a, nr_insert); | |
220 return retval; | |
221 } | |
222 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
223 ComplexRowVector |
458 | 224 ComplexColumnVector::hermitian (void) const |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
225 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
226 return MArray<Complex>::hermitian (std::conj); |
458 | 227 } |
228 | |
229 ComplexRowVector | |
230 ComplexColumnVector::transpose (void) const | |
231 { | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7503
diff
changeset
|
232 return MArray<Complex>::transpose (); |
458 | 233 } |
234 | |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
235 ColumnVector |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
236 ComplexColumnVector::abs (void) const |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
237 { |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
238 return do_mx_unary_map<double, Complex, std::abs> (*this); |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
239 } |
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
240 |
458 | 241 ComplexColumnVector |
242 conj (const ComplexColumnVector& a) | |
243 { | |
10363
a0728e81ed25
improve diag matrix interface & implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
244 return do_mx_unary_map<Complex, Complex, std::conj> (a); |
458 | 245 } |
246 | |
247 // resize is the destructive equivalent for this one | |
248 | |
249 ComplexColumnVector | |
5275 | 250 ComplexColumnVector::extract (octave_idx_type r1, octave_idx_type r2) const |
458 | 251 { |
5275 | 252 if (r1 > r2) { octave_idx_type tmp = r1; r1 = r2; r2 = tmp; } |
458 | 253 |
5275 | 254 octave_idx_type new_r = r2 - r1 + 1; |
458 | 255 |
256 ComplexColumnVector result (new_r); | |
257 | |
5275 | 258 for (octave_idx_type i = 0; i < new_r; i++) |
458 | 259 result.elem (i) = elem (r1+i); |
260 | |
261 return result; | |
262 } | |
263 | |
4316 | 264 ComplexColumnVector |
5275 | 265 ComplexColumnVector::extract_n (octave_idx_type r1, octave_idx_type n) const |
4316 | 266 { |
267 ComplexColumnVector result (n); | |
268 | |
5275 | 269 for (octave_idx_type i = 0; i < n; i++) |
4316 | 270 result.elem (i) = elem (r1+i); |
271 | |
272 return result; | |
273 } | |
274 | |
458 | 275 // column vector by column vector -> column vector operations |
276 | |
277 ComplexColumnVector& | |
278 ComplexColumnVector::operator += (const ColumnVector& a) | |
279 { | |
5275 | 280 octave_idx_type len = length (); |
2386 | 281 |
5275 | 282 octave_idx_type a_len = a.length (); |
2386 | 283 |
284 if (len != a_len) | |
458 | 285 { |
2386 | 286 gripe_nonconformant ("operator +=", len, a_len); |
458 | 287 return *this; |
288 } | |
289 | |
290 if (len == 0) | |
291 return *this; | |
292 | |
293 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
294 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
295 mx_inline_add2 (len, d, a.data ()); |
458 | 296 return *this; |
297 } | |
298 | |
299 ComplexColumnVector& | |
300 ComplexColumnVector::operator -= (const ColumnVector& a) | |
301 { | |
5275 | 302 octave_idx_type len = length (); |
2386 | 303 |
5275 | 304 octave_idx_type a_len = a.length (); |
2386 | 305 |
306 if (len != a_len) | |
458 | 307 { |
2386 | 308 gripe_nonconformant ("operator -=", len, a_len); |
458 | 309 return *this; |
310 } | |
311 | |
312 if (len == 0) | |
313 return *this; | |
314 | |
315 Complex *d = fortran_vec (); // Ensures only one reference to my privates! | |
316 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8999
diff
changeset
|
317 mx_inline_sub2 (len, d, a.data ()); |
458 | 318 return *this; |
319 } | |
320 | |
1205 | 321 // matrix by column vector -> column vector operations |
322 | |
323 ComplexColumnVector | |
324 operator * (const ComplexMatrix& m, const ColumnVector& a) | |
325 { | |
326 ComplexColumnVector tmp (a); | |
327 return m * tmp; | |
328 } | |
329 | |
330 ComplexColumnVector | |
331 operator * (const ComplexMatrix& m, const ComplexColumnVector& a) | |
332 { | |
1947 | 333 ComplexColumnVector retval; |
334 | |
5275 | 335 octave_idx_type nr = m.rows (); |
336 octave_idx_type nc = m.cols (); | |
1947 | 337 |
5275 | 338 octave_idx_type a_len = a.length (); |
2386 | 339 |
340 if (nc != a_len) | |
341 gripe_nonconformant ("operator *", nr, nc, a_len, 1); | |
1947 | 342 else |
458 | 343 { |
9625
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
344 retval.clear (nr); |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
345 |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
346 if (nr != 0) |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
347 { |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
348 Complex *y = retval.fortran_vec (); |
1947 | 349 |
9625
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
350 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 ("N", 1), |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
351 nr, nc, 1.0, m.data (), nr, |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
352 a.data (), 1, 0.0, y, 1 |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
353 F77_CHAR_ARG_LEN (1))); |
cbabf50315ca
optimize Matrix*ColumnVector
Jaroslav Hajek <highegg@gmail.com>
parents:
9550
diff
changeset
|
354 } |
458 | 355 } |
356 | |
1947 | 357 return retval; |
458 | 358 } |
359 | |
1205 | 360 // matrix by column vector -> column vector operations |
361 | |
362 ComplexColumnVector | |
363 operator * (const Matrix& m, const ComplexColumnVector& a) | |
364 { | |
365 ComplexMatrix tmp (m); | |
366 return tmp * a; | |
367 } | |
368 | |
369 // diagonal matrix by column vector -> column vector operations | |
370 | |
371 ComplexColumnVector | |
372 operator * (const DiagMatrix& m, const ComplexColumnVector& a) | |
373 { | |
5275 | 374 octave_idx_type nr = m.rows (); |
375 octave_idx_type nc = m.cols (); | |
2386 | 376 |
5275 | 377 octave_idx_type a_len = a.length (); |
2386 | 378 |
1205 | 379 if (nc != a_len) |
380 { | |
2386 | 381 gripe_nonconformant ("operator *", nr, nc, a_len, 1); |
3585 | 382 return ComplexColumnVector (); |
1205 | 383 } |
384 | |
385 if (nc == 0 || nr == 0) | |
386 return ComplexColumnVector (0); | |
387 | |
388 ComplexColumnVector result (nr); | |
389 | |
5275 | 390 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 391 result.elem (i) = a.elem (i) * m.elem (i, i); |
392 | |
5275 | 393 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 394 result.elem (i) = 0.0; |
395 | |
396 return result; | |
397 } | |
398 | |
399 ComplexColumnVector | |
400 operator * (const ComplexDiagMatrix& m, const ColumnVector& a) | |
401 { | |
5275 | 402 octave_idx_type nr = m.rows (); |
403 octave_idx_type nc = m.cols (); | |
2386 | 404 |
5275 | 405 octave_idx_type a_len = a.length (); |
2386 | 406 |
1205 | 407 if (nc != a_len) |
408 { | |
2386 | 409 gripe_nonconformant ("operator *", nr, nc, a_len, 1); |
1205 | 410 return ComplexColumnVector (); |
411 } | |
412 | |
413 if (nc == 0 || nr == 0) | |
414 return ComplexColumnVector (0); | |
415 | |
416 ComplexColumnVector result (nr); | |
417 | |
5275 | 418 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 419 result.elem (i) = a.elem (i) * m.elem (i, i); |
420 | |
5275 | 421 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 422 result.elem (i) = 0.0; |
423 | |
424 return result; | |
425 } | |
426 | |
427 ComplexColumnVector | |
428 operator * (const ComplexDiagMatrix& m, const ComplexColumnVector& a) | |
429 { | |
5275 | 430 octave_idx_type nr = m.rows (); |
431 octave_idx_type nc = m.cols (); | |
2386 | 432 |
5275 | 433 octave_idx_type a_len = a.length (); |
2386 | 434 |
1205 | 435 if (nc != a_len) |
436 { | |
2386 | 437 gripe_nonconformant ("operator *", nr, nc, a_len, 1); |
1205 | 438 return ComplexColumnVector (); |
439 } | |
440 | |
441 if (nc == 0 || nr == 0) | |
442 return ComplexColumnVector (0); | |
443 | |
444 ComplexColumnVector result (nr); | |
445 | |
5275 | 446 for (octave_idx_type i = 0; i < a_len; i++) |
1205 | 447 result.elem (i) = a.elem (i) * m.elem (i, i); |
448 | |
5275 | 449 for (octave_idx_type i = a_len; i < nr; i++) |
1205 | 450 result.elem (i) = 0.0; |
451 | |
452 return result; | |
453 } | |
454 | |
458 | 455 // other operations |
456 | |
457 Complex | |
458 ComplexColumnVector::min (void) const | |
459 { | |
5275 | 460 octave_idx_type len = length (); |
458 | 461 if (len == 0) |
462 return 0.0; | |
463 | |
464 Complex res = elem (0); | |
5260 | 465 double absres = std::abs (res); |
458 | 466 |
5275 | 467 for (octave_idx_type i = 1; i < len; i++) |
5260 | 468 if (std::abs (elem (i)) < absres) |
458 | 469 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
470 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
471 absres = std::abs (res); |
458 | 472 } |
473 | |
474 return res; | |
475 } | |
476 | |
477 Complex | |
478 ComplexColumnVector::max (void) const | |
479 { | |
5275 | 480 octave_idx_type len = length (); |
458 | 481 if (len == 0) |
482 return 0.0; | |
483 | |
484 Complex res = elem (0); | |
5260 | 485 double absres = std::abs (res); |
458 | 486 |
5275 | 487 for (octave_idx_type i = 1; i < len; i++) |
5260 | 488 if (std::abs (elem (i)) > absres) |
458 | 489 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
490 res = elem (i); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
491 absres = std::abs (res); |
458 | 492 } |
493 | |
494 return res; | |
495 } | |
496 | |
497 // i/o | |
498 | |
3504 | 499 std::ostream& |
500 operator << (std::ostream& os, const ComplexColumnVector& a) | |
458 | 501 { |
502 // int field_width = os.precision () + 7; | |
5275 | 503 for (octave_idx_type i = 0; i < a.length (); i++) |
458 | 504 os << /* setw (field_width) << */ a.elem (i) << "\n"; |
505 return os; | |
506 } | |
507 | |
3504 | 508 std::istream& |
509 operator >> (std::istream& is, ComplexColumnVector& a) | |
458 | 510 { |
5275 | 511 octave_idx_type len = a.length(); |
458 | 512 |
8999
dc07bc4157b8
allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
513 if (len > 0) |
458 | 514 { |
515 double tmp; | |
5275 | 516 for (octave_idx_type i = 0; i < len; i++) |
458 | 517 { |
518 is >> tmp; | |
519 if (is) | |
520 a.elem (i) = tmp; | |
521 else | |
522 break; | |
523 } | |
524 } | |
532 | 525 return is; |
458 | 526 } |