458
|
1 // RowVector manipulations. -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
458
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
1296
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
458
|
28 #ifdef HAVE_CONFIG_H |
1192
|
29 #include <config.h> |
458
|
30 #endif |
|
31 |
|
32 #include <iostream.h> |
|
33 |
|
34 #include <Complex.h> |
|
35 |
|
36 #include "mx-base.h" |
|
37 #include "mx-inlines.cc" |
|
38 #include "lo-error.h" |
|
39 #include "f77-uscore.h" |
|
40 |
|
41 // Fortran functions we call. |
|
42 |
|
43 extern "C" |
|
44 { |
1253
|
45 int F77_FCN (zgemv, ZGEMV) (const char*, const int&, const int&, |
|
46 const Complex&, const Complex*, |
|
47 const int&, const Complex*, const int&, |
|
48 const Complex&, Complex*, const int&, |
|
49 long); |
458
|
50 } |
|
51 |
|
52 /* |
|
53 * Complex Row Vector class |
|
54 */ |
|
55 |
|
56 ComplexRowVector::ComplexRowVector (const RowVector& a) |
1214
|
57 : MArray<Complex> (a.length ()) |
458
|
58 { |
|
59 for (int i = 0; i < length (); i++) |
|
60 elem (i) = a.elem (i); |
|
61 } |
|
62 |
|
63 int |
|
64 ComplexRowVector::operator == (const ComplexRowVector& a) const |
|
65 { |
|
66 int len = length (); |
|
67 if (len != a.length ()) |
|
68 return 0; |
|
69 return equal (data (), a.data (), len); |
|
70 } |
|
71 |
|
72 int |
|
73 ComplexRowVector::operator != (const ComplexRowVector& a) const |
|
74 { |
|
75 return !(*this == a); |
|
76 } |
|
77 |
|
78 // destructive insert/delete/reorder operations |
|
79 |
|
80 ComplexRowVector& |
|
81 ComplexRowVector::insert (const RowVector& a, int c) |
|
82 { |
|
83 int a_len = a.length (); |
|
84 if (c < 0 || c + a_len - 1 > length ()) |
|
85 { |
|
86 (*current_liboctave_error_handler) ("range error for insert"); |
|
87 return *this; |
|
88 } |
|
89 |
|
90 for (int i = 0; i < a_len; i++) |
|
91 elem (c+i) = a.elem (i); |
|
92 |
|
93 return *this; |
|
94 } |
|
95 |
|
96 ComplexRowVector& |
|
97 ComplexRowVector::insert (const ComplexRowVector& a, int c) |
|
98 { |
|
99 int a_len = a.length (); |
|
100 if (c < 0 || c + a_len - 1 > length ()) |
|
101 { |
|
102 (*current_liboctave_error_handler) ("range error for insert"); |
|
103 return *this; |
|
104 } |
|
105 |
|
106 for (int i = 0; i < a_len; i++) |
|
107 elem (c+i) = a.elem (i); |
|
108 |
|
109 return *this; |
|
110 } |
|
111 |
|
112 ComplexRowVector& |
|
113 ComplexRowVector::fill (double val) |
|
114 { |
|
115 int len = length (); |
|
116 if (len > 0) |
|
117 for (int i = 0; i < len; i++) |
|
118 elem (i) = val; |
|
119 return *this; |
|
120 } |
|
121 |
|
122 ComplexRowVector& |
|
123 ComplexRowVector::fill (const Complex& val) |
|
124 { |
|
125 int len = length (); |
|
126 if (len > 0) |
|
127 for (int i = 0; i < len; i++) |
|
128 elem (i) = val; |
|
129 return *this; |
|
130 } |
|
131 |
|
132 ComplexRowVector& |
|
133 ComplexRowVector::fill (double val, int c1, int c2) |
|
134 { |
|
135 int len = length (); |
|
136 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
|
137 { |
|
138 (*current_liboctave_error_handler) ("range error for fill"); |
|
139 return *this; |
|
140 } |
|
141 |
|
142 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
|
143 |
|
144 for (int i = c1; i <= c2; i++) |
|
145 elem (i) = val; |
|
146 |
|
147 return *this; |
|
148 } |
|
149 |
|
150 ComplexRowVector& |
|
151 ComplexRowVector::fill (const Complex& val, int c1, int c2) |
|
152 { |
|
153 int len = length (); |
|
154 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len) |
|
155 { |
|
156 (*current_liboctave_error_handler) ("range error for fill"); |
|
157 return *this; |
|
158 } |
|
159 |
|
160 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
|
161 |
|
162 for (int i = c1; i <= c2; i++) |
|
163 elem (i) = val; |
|
164 |
|
165 return *this; |
|
166 } |
|
167 |
|
168 ComplexRowVector |
|
169 ComplexRowVector::append (const RowVector& a) const |
|
170 { |
|
171 int len = length (); |
|
172 int nc_insert = len; |
|
173 ComplexRowVector retval (len + a.length ()); |
|
174 retval.insert (*this, 0); |
|
175 retval.insert (a, nc_insert); |
|
176 return retval; |
|
177 } |
|
178 |
|
179 ComplexRowVector |
|
180 ComplexRowVector::append (const ComplexRowVector& a) const |
|
181 { |
|
182 int len = length (); |
|
183 int nc_insert = len; |
|
184 ComplexRowVector retval (len + a.length ()); |
|
185 retval.insert (*this, 0); |
|
186 retval.insert (a, nc_insert); |
|
187 return retval; |
|
188 } |
|
189 |
|
190 ComplexColumnVector |
|
191 ComplexRowVector::hermitian (void) const |
|
192 { |
|
193 int len = length (); |
|
194 return ComplexColumnVector (conj_dup (data (), len), len); |
|
195 } |
|
196 |
|
197 ComplexColumnVector |
|
198 ComplexRowVector::transpose (void) const |
|
199 { |
|
200 int len = length (); |
|
201 return ComplexColumnVector (dup (data (), len), len); |
|
202 } |
|
203 |
|
204 ComplexRowVector |
|
205 conj (const ComplexRowVector& a) |
|
206 { |
|
207 int a_len = a.length (); |
|
208 ComplexRowVector retval; |
|
209 if (a_len > 0) |
|
210 retval = ComplexRowVector (conj_dup (a.data (), a_len), a_len); |
|
211 return retval; |
|
212 } |
|
213 |
|
214 // resize is the destructive equivalent for this one |
|
215 |
|
216 ComplexRowVector |
|
217 ComplexRowVector::extract (int c1, int c2) const |
|
218 { |
|
219 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
|
220 |
|
221 int new_c = c2 - c1 + 1; |
|
222 |
|
223 ComplexRowVector result (new_c); |
|
224 |
|
225 for (int i = 0; i < new_c; i++) |
|
226 result.elem (i) = elem (c1+i); |
|
227 |
|
228 return result; |
|
229 } |
|
230 |
|
231 // row vector by row vector -> row vector operations |
|
232 |
|
233 ComplexRowVector& |
|
234 ComplexRowVector::operator += (const RowVector& a) |
|
235 { |
|
236 int len = length (); |
|
237 if (len != a.length ()) |
|
238 { |
|
239 (*current_liboctave_error_handler) |
|
240 ("nonconformant vector += operation attempted"); |
|
241 return *this; |
|
242 } |
|
243 |
|
244 if (len == 0) |
|
245 return *this; |
|
246 |
|
247 Complex *d = fortran_vec (); // Ensures only one reference to my privates! |
|
248 |
|
249 add2 (d, a.data (), len); |
|
250 return *this; |
|
251 } |
|
252 |
|
253 ComplexRowVector& |
|
254 ComplexRowVector::operator -= (const RowVector& a) |
|
255 { |
|
256 int len = length (); |
|
257 if (len != a.length ()) |
|
258 { |
|
259 (*current_liboctave_error_handler) |
|
260 ("nonconformant vector -= operation attempted"); |
|
261 return *this; |
|
262 } |
|
263 |
|
264 if (len == 0) |
|
265 return *this; |
|
266 |
|
267 Complex *d = fortran_vec (); // Ensures only one reference to my privates! |
|
268 |
|
269 subtract2 (d, a.data (), len); |
|
270 return *this; |
|
271 } |
|
272 |
|
273 ComplexRowVector& |
|
274 ComplexRowVector::operator += (const ComplexRowVector& a) |
|
275 { |
|
276 int len = length (); |
|
277 if (len != a.length ()) |
|
278 { |
|
279 (*current_liboctave_error_handler) |
|
280 ("nonconformant vector += operation attempted"); |
|
281 return *this; |
|
282 } |
|
283 |
|
284 if (len == 0) |
|
285 return *this; |
|
286 |
|
287 Complex *d = fortran_vec (); // Ensures only one reference to my privates! |
|
288 |
|
289 add2 (d, a.data (), len); |
|
290 return *this; |
|
291 } |
|
292 |
|
293 ComplexRowVector& |
|
294 ComplexRowVector::operator -= (const ComplexRowVector& a) |
|
295 { |
|
296 int len = length (); |
|
297 if (len != a.length ()) |
|
298 { |
|
299 (*current_liboctave_error_handler) |
|
300 ("nonconformant vector -= operation attempted"); |
|
301 return *this; |
|
302 } |
|
303 |
|
304 if (len == 0) |
|
305 return *this; |
|
306 |
|
307 Complex *d = fortran_vec (); // Ensures only one reference to my privates! |
|
308 |
|
309 subtract2 (d, a.data (), len); |
|
310 return *this; |
|
311 } |
|
312 |
|
313 // row vector by scalar -> row vector operations |
|
314 |
|
315 ComplexRowVector |
|
316 operator + (const ComplexRowVector& v, double s) |
|
317 { |
|
318 int len = v.length (); |
|
319 return ComplexRowVector (add (v.data (), len, s), len); |
|
320 } |
|
321 |
|
322 ComplexRowVector |
|
323 operator - (const ComplexRowVector& v, double s) |
|
324 { |
|
325 int len = v.length (); |
|
326 return ComplexRowVector (subtract (v.data (), len, s), len); |
|
327 } |
|
328 |
|
329 ComplexRowVector |
|
330 operator * (const ComplexRowVector& v, double s) |
|
331 { |
|
332 int len = v.length (); |
|
333 return ComplexRowVector (multiply (v.data (), len, s), len); |
|
334 } |
|
335 |
|
336 ComplexRowVector |
|
337 operator / (const ComplexRowVector& v, double s) |
|
338 { |
|
339 int len = v.length (); |
|
340 return ComplexRowVector (divide (v.data (), len, s), len); |
|
341 } |
|
342 |
1205
|
343 ComplexRowVector |
|
344 operator + (const RowVector& v, const Complex& s) |
|
345 { |
|
346 int len = v.length (); |
|
347 return ComplexRowVector (add (v.data (), len, s), len); |
|
348 } |
|
349 |
|
350 ComplexRowVector |
|
351 operator - (const RowVector& v, const Complex& s) |
|
352 { |
|
353 int len = v.length (); |
|
354 return ComplexRowVector (subtract (v.data (), len, s), len); |
|
355 } |
|
356 |
|
357 ComplexRowVector |
|
358 operator * (const RowVector& v, const Complex& s) |
|
359 { |
|
360 int len = v.length (); |
|
361 return ComplexRowVector (multiply (v.data (), len, s), len); |
|
362 } |
|
363 |
|
364 ComplexRowVector |
|
365 operator / (const RowVector& v, const Complex& s) |
|
366 { |
|
367 int len = v.length (); |
|
368 return ComplexRowVector (divide (v.data (), len, s), len); |
|
369 } |
|
370 |
458
|
371 // scalar by row vector -> row vector operations |
|
372 |
|
373 ComplexRowVector |
|
374 operator + (double s, const ComplexRowVector& a) |
|
375 { |
|
376 int a_len = a.length (); |
|
377 return ComplexRowVector (add (a.data (), a_len, s), a_len); |
|
378 } |
|
379 |
|
380 ComplexRowVector |
|
381 operator - (double s, const ComplexRowVector& a) |
|
382 { |
|
383 int a_len = a.length (); |
|
384 return ComplexRowVector (subtract (s, a.data (), a_len), a_len); |
|
385 } |
|
386 |
|
387 ComplexRowVector |
|
388 operator * (double s, const ComplexRowVector& a) |
|
389 { |
|
390 int a_len = a.length (); |
|
391 return ComplexRowVector (multiply (a.data (), a_len, s), a_len); |
|
392 } |
|
393 |
|
394 ComplexRowVector |
|
395 operator / (double s, const ComplexRowVector& a) |
|
396 { |
|
397 int a_len = a.length (); |
|
398 return ComplexRowVector (divide (s, a.data (), a_len), a_len); |
|
399 } |
|
400 |
1205
|
401 ComplexRowVector |
|
402 operator + (const Complex& s, const RowVector& a) |
458
|
403 { |
1205
|
404 return ComplexRowVector (); |
458
|
405 } |
|
406 |
1205
|
407 ComplexRowVector |
|
408 operator - (const Complex& s, const RowVector& a) |
458
|
409 { |
1205
|
410 return ComplexRowVector (); |
|
411 } |
458
|
412 |
1205
|
413 ComplexRowVector |
|
414 operator * (const Complex& s, const RowVector& a) |
|
415 { |
|
416 return ComplexRowVector (); |
|
417 } |
458
|
418 |
1205
|
419 ComplexRowVector |
|
420 operator / (const Complex& s, const RowVector& a) |
|
421 { |
|
422 return ComplexRowVector (); |
458
|
423 } |
|
424 |
|
425 // row vector by matrix -> row vector |
|
426 |
|
427 ComplexRowVector |
|
428 operator * (const ComplexRowVector& v, const ComplexMatrix& a) |
|
429 { |
|
430 int len = v.length (); |
|
431 if (a.rows () != len) |
|
432 { |
|
433 (*current_liboctave_error_handler) |
|
434 ("nonconformant vector multiplication attempted"); |
|
435 return ComplexRowVector (); |
|
436 } |
|
437 |
|
438 if (len == 0 || a.cols () == 0) |
|
439 return ComplexRowVector (0); |
|
440 |
|
441 // Transpose A to form A'*x == (x'*A)' |
|
442 |
|
443 int a_nr = a.rows (); |
|
444 int a_nc = a.cols (); |
|
445 |
|
446 int ld = a_nr; |
|
447 |
|
448 Complex *y = new Complex [len]; |
|
449 |
1253
|
450 F77_FCN (zgemv, ZGEMV) ("T", a_nc, a_nr, 1.0, a.data (), ld, |
|
451 v.data (), 1, 0.0, y, 1, 1L); |
458
|
452 |
|
453 return ComplexRowVector (y, len); |
|
454 } |
|
455 |
1205
|
456 ComplexRowVector |
|
457 operator * (const RowVector& v, const ComplexMatrix& a) |
|
458 { |
|
459 ComplexRowVector tmp (v); |
|
460 return tmp * a; |
|
461 } |
|
462 |
458
|
463 // row vector by row vector -> row vector operations |
|
464 |
|
465 ComplexRowVector |
|
466 operator + (const ComplexRowVector& v, const RowVector& a) |
|
467 { |
|
468 int len = v.length (); |
|
469 if (len != a.length ()) |
|
470 { |
|
471 (*current_liboctave_error_handler) |
|
472 ("nonconformant vector addition attempted"); |
|
473 return ComplexRowVector (); |
|
474 } |
|
475 |
|
476 if (len == 0) |
|
477 return ComplexRowVector (0); |
|
478 |
|
479 return ComplexRowVector (add (v.data (), a.data (), len), len); |
|
480 } |
|
481 |
|
482 ComplexRowVector |
|
483 operator - (const ComplexRowVector& v, const RowVector& a) |
|
484 { |
|
485 int len = v.length (); |
|
486 if (len != a.length ()) |
|
487 { |
|
488 (*current_liboctave_error_handler) |
|
489 ("nonconformant vector subtraction attempted"); |
|
490 return ComplexRowVector (); |
|
491 } |
|
492 |
|
493 if (len == 0) |
|
494 return ComplexRowVector (0); |
|
495 |
|
496 return ComplexRowVector (subtract (v.data (), a.data (), len), len); |
|
497 } |
|
498 |
|
499 ComplexRowVector |
1205
|
500 operator + (const RowVector& v, const ComplexRowVector& a) |
|
501 { |
|
502 int len = v.length (); |
|
503 if (len != a.length ()) |
|
504 { |
|
505 (*current_liboctave_error_handler) |
|
506 ("nonconformant vector addition attempted"); |
|
507 return ComplexRowVector (); |
|
508 } |
|
509 |
|
510 if (len == 0) |
|
511 return ComplexRowVector (0); |
|
512 |
|
513 return ComplexRowVector (add (v.data (), a.data (), len), len); |
|
514 } |
|
515 |
|
516 ComplexRowVector |
|
517 operator - (const RowVector& v, const ComplexRowVector& a) |
|
518 { |
|
519 int len = v.length (); |
|
520 if (len != a.length ()) |
|
521 { |
|
522 (*current_liboctave_error_handler) |
|
523 ("nonconformant vector subtraction attempted"); |
|
524 return ComplexRowVector (); |
|
525 } |
|
526 |
|
527 if (len == 0) |
|
528 return ComplexRowVector (0); |
|
529 |
|
530 return ComplexRowVector (subtract (v.data (), a.data (), len), len); |
|
531 } |
|
532 |
|
533 ComplexRowVector |
458
|
534 product (const ComplexRowVector& v, const RowVector& a) |
|
535 { |
|
536 int len = v.length (); |
|
537 if (len != a.length ()) |
|
538 { |
|
539 (*current_liboctave_error_handler) |
|
540 ("nonconformant vector product attempted"); |
|
541 return ComplexRowVector (); |
|
542 } |
|
543 |
|
544 if (len == 0) |
|
545 return ComplexRowVector (0); |
|
546 |
|
547 return ComplexRowVector (multiply (v.data (), a.data (), len), len); |
|
548 } |
|
549 |
|
550 ComplexRowVector |
|
551 quotient (const ComplexRowVector& v, const RowVector& a) |
|
552 { |
|
553 int len = v.length (); |
|
554 if (len != a.length ()) |
|
555 { |
|
556 (*current_liboctave_error_handler) |
|
557 ("nonconformant vector quotient attempted"); |
|
558 return ComplexRowVector (); |
|
559 } |
|
560 |
|
561 if (len == 0) |
|
562 return ComplexRowVector (0); |
|
563 |
|
564 return ComplexRowVector (divide (v.data (), a.data (), len), len); |
|
565 } |
|
566 |
1205
|
567 ComplexRowVector |
|
568 product (const RowVector& v, const ComplexRowVector& a) |
|
569 { |
|
570 int len = v.length (); |
|
571 if (len != a.length ()) |
|
572 { |
|
573 (*current_liboctave_error_handler) |
|
574 ("nonconformant vector product attempted"); |
|
575 return ComplexRowVector (); |
|
576 } |
|
577 |
|
578 if (len == 0) |
|
579 return ComplexRowVector (0); |
|
580 |
|
581 return ComplexRowVector (multiply (v.data (), a.data (), len), len); |
|
582 } |
|
583 |
|
584 ComplexRowVector |
|
585 quotient (const RowVector& v, const ComplexRowVector& a) |
|
586 { |
|
587 int len = v.length (); |
|
588 if (len != a.length ()) |
|
589 { |
|
590 (*current_liboctave_error_handler) |
|
591 ("nonconformant vector quotient attempted"); |
|
592 return ComplexRowVector (); |
|
593 } |
|
594 |
|
595 if (len == 0) |
|
596 return ComplexRowVector (0); |
|
597 |
|
598 return ComplexRowVector (divide (v.data (), a.data (), len), len); |
|
599 } |
|
600 |
458
|
601 // other operations |
|
602 |
|
603 ComplexRowVector |
|
604 map (c_c_Mapper f, const ComplexRowVector& a) |
|
605 { |
|
606 ComplexRowVector b (a); |
|
607 b.map (f); |
|
608 return b; |
|
609 } |
|
610 |
|
611 void |
|
612 ComplexRowVector::map (c_c_Mapper f) |
|
613 { |
|
614 for (int i = 0; i < length (); i++) |
|
615 elem (i) = f (elem (i)); |
|
616 } |
|
617 |
|
618 Complex |
|
619 ComplexRowVector::min (void) const |
|
620 { |
|
621 int len = length (); |
|
622 if (len == 0) |
|
623 return Complex (0.0); |
|
624 |
|
625 Complex res = elem (0); |
|
626 double absres = abs (res); |
|
627 |
|
628 for (int i = 1; i < len; i++) |
|
629 if (abs (elem (i)) < absres) |
|
630 { |
|
631 res = elem (i); |
|
632 absres = abs (res); |
|
633 } |
|
634 |
|
635 return res; |
|
636 } |
|
637 |
|
638 Complex |
|
639 ComplexRowVector::max (void) const |
|
640 { |
|
641 int len = length (); |
|
642 if (len == 0) |
|
643 return Complex (0.0); |
|
644 |
|
645 Complex res = elem (0); |
|
646 double absres = abs (res); |
|
647 |
|
648 for (int i = 1; i < len; i++) |
|
649 if (abs (elem (i)) > absres) |
|
650 { |
|
651 res = elem (i); |
|
652 absres = abs (res); |
|
653 } |
|
654 |
|
655 return res; |
|
656 } |
|
657 |
|
658 // i/o |
|
659 |
|
660 ostream& |
|
661 operator << (ostream& os, const ComplexRowVector& a) |
|
662 { |
|
663 // int field_width = os.precision () + 7; |
|
664 for (int i = 0; i < a.length (); i++) |
|
665 os << " " /* setw (field_width) */ << a.elem (i); |
|
666 return os; |
|
667 } |
|
668 |
|
669 istream& |
|
670 operator >> (istream& is, ComplexRowVector& a) |
|
671 { |
|
672 int len = a.length(); |
|
673 |
|
674 if (len < 1) |
|
675 is.clear (ios::badbit); |
|
676 else |
|
677 { |
|
678 Complex tmp; |
|
679 for (int i = 0; i < len; i++) |
|
680 { |
|
681 is >> tmp; |
|
682 if (is) |
|
683 a.elem (i) = tmp; |
|
684 else |
|
685 break; |
|
686 } |
|
687 } |
532
|
688 return is; |
458
|
689 } |
|
690 |
1205
|
691 // row vector by column vector -> scalar |
|
692 |
|
693 // row vector by column vector -> scalar |
|
694 |
|
695 Complex |
|
696 operator * (const ComplexRowVector& v, const ColumnVector& a) |
|
697 { |
|
698 ComplexColumnVector tmp (a); |
|
699 return v * tmp; |
|
700 } |
|
701 |
|
702 Complex |
|
703 operator * (const ComplexRowVector& v, const ComplexColumnVector& a) |
|
704 { |
|
705 int len = v.length (); |
|
706 if (len != a.length ()) |
|
707 { |
|
708 (*current_liboctave_error_handler) |
|
709 ("nonconformant vector multiplication attempted"); |
|
710 return 0.0; |
|
711 } |
|
712 |
|
713 Complex retval (0.0, 0.0); |
|
714 |
|
715 for (int i = 0; i < len; i++) |
|
716 retval += v.elem (i) * a.elem (i); |
|
717 |
|
718 return retval; |
|
719 } |
|
720 |
|
721 // other operations |
|
722 |
|
723 ComplexRowVector |
|
724 linspace (const Complex& x1, const Complex& x2, int n) |
|
725 { |
|
726 ComplexRowVector retval; |
|
727 |
|
728 if (n > 0) |
|
729 { |
|
730 retval.resize (n); |
|
731 Complex delta = (x2 - x1) / (n - 1); |
|
732 retval.elem (0) = x1; |
|
733 for (int i = 1; i < n-1; i++) |
|
734 retval.elem (i) = x1 + i * delta; |
|
735 retval.elem (n-1) = x2; |
|
736 } |
|
737 |
|
738 return retval; |
|
739 } |
|
740 |
458
|
741 /* |
|
742 ;;; Local Variables: *** |
|
743 ;;; mode: C++ *** |
|
744 ;;; page-delimiter: "^/\\*" *** |
|
745 ;;; End: *** |
|
746 */ |