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