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