2928
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "lo-ieee.h" |
|
28 #include "oct-math.h" |
|
29 |
|
30 #include "defun-dld.h" |
|
31 #include "error.h" |
|
32 #include "gripes.h" |
|
33 #include "oct-obj.h" |
|
34 |
|
35 #ifndef MAX |
|
36 #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
|
37 #endif |
|
38 |
|
39 #ifndef MIN |
|
40 #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
|
41 #endif |
|
42 |
|
43 // XXX FIXME XXX -- it would be nice to share code among the min/max |
|
44 // functions below. |
|
45 |
|
46 static Matrix |
|
47 min (double d, const Matrix& m) |
|
48 { |
|
49 int nr = m.rows (); |
|
50 int nc = m.columns (); |
|
51 |
|
52 Matrix result (nr, nc); |
|
53 |
|
54 for (int j = 0; j < nc; j++) |
|
55 for (int i = 0; i < nr; i++) |
|
56 { |
|
57 double m_elem = m (i, j); |
|
58 result (i, j) = MIN (d, m_elem); |
|
59 } |
|
60 |
|
61 return result; |
|
62 } |
|
63 |
|
64 static Matrix |
|
65 min (const Matrix& m, double d) |
|
66 { |
|
67 int nr = m.rows (); |
|
68 int nc = m.columns (); |
|
69 |
|
70 Matrix result (nr, nc); |
|
71 |
|
72 for (int j = 0; j < nc; j++) |
|
73 for (int i = 0; i < nr; i++) |
|
74 { |
|
75 double m_elem = m (i, j); |
|
76 result (i, j) = MIN (m_elem, d); |
|
77 } |
|
78 |
|
79 return result; |
|
80 } |
|
81 |
|
82 static ComplexMatrix |
|
83 min (const Complex& c, const ComplexMatrix& m) |
|
84 { |
|
85 int nr = m.rows (); |
|
86 int nc = m.columns (); |
|
87 |
|
88 ComplexMatrix result (nr, nc); |
|
89 |
|
90 double abs_c = abs (c); |
|
91 |
|
92 for (int j = 0; j < nc; j++) |
|
93 { |
|
94 for (int i = 0; i < nr; i++) |
|
95 { |
|
96 double abs_m_elem = abs (m (i, j)); |
|
97 if (abs_c < abs_m_elem) |
|
98 result (i, j) = c; |
|
99 else |
|
100 result (i, j) = m (i, j); |
|
101 } |
|
102 } |
|
103 |
|
104 return result; |
|
105 } |
|
106 |
|
107 static ComplexMatrix |
|
108 min (const ComplexMatrix& m, const Complex& c) |
|
109 { |
|
110 int nr = m.rows (); |
|
111 int nc = m.columns (); |
|
112 |
|
113 ComplexMatrix result (nr, nc); |
|
114 |
|
115 double abs_c = abs (c); |
|
116 |
|
117 for (int j = 0; j < nc; j++) |
|
118 for (int i = 0; i < nr; i++) |
|
119 { |
|
120 double abs_m_elem = abs (m (i, j)); |
|
121 if (abs_m_elem < abs_c) |
|
122 result (i, j) = m (i, j); |
|
123 else |
|
124 result (i, j) = c; |
|
125 } |
|
126 |
|
127 return result; |
|
128 } |
|
129 |
|
130 static Matrix |
|
131 min (const Matrix& a, const Matrix& b) |
|
132 { |
|
133 int nr = a.rows (); |
|
134 int nc = a.columns (); |
|
135 if (nr != b.rows () || nc != b.columns ()) |
|
136 { |
|
137 error ("two-arg min expecting args of same size"); |
|
138 return Matrix (); |
|
139 } |
|
140 |
|
141 Matrix result (nr, nc); |
|
142 |
|
143 for (int j = 0; j < nc; j++) |
|
144 for (int i = 0; i < nr; i++) |
|
145 { |
|
146 double a_elem = a (i, j); |
|
147 double b_elem = b (i, j); |
|
148 result (i, j) = MIN (a_elem, b_elem); |
|
149 } |
|
150 |
|
151 return result; |
|
152 } |
|
153 |
|
154 static ComplexMatrix |
|
155 min (const ComplexMatrix& a, const ComplexMatrix& b) |
|
156 { |
|
157 int nr = a.rows (); |
|
158 int nc = a.columns (); |
|
159 if (nr != b.rows () || nc != b.columns ()) |
|
160 { |
|
161 error ("two-arg min expecting args of same size"); |
|
162 return ComplexMatrix (); |
|
163 } |
|
164 |
|
165 ComplexMatrix result (nr, nc); |
|
166 |
|
167 for (int j = 0; j < nc; j++) |
|
168 { |
|
169 int columns_are_real_only = 1; |
|
170 for (int i = 0; i < nr; i++) |
|
171 if (imag (a (i, j)) != 0.0 && imag (b (i, j)) != 0.0) |
|
172 { |
|
173 columns_are_real_only = 0; |
|
174 break; |
|
175 } |
|
176 |
|
177 if (columns_are_real_only) |
|
178 { |
|
179 for (int i = 0; i < nr; i++) |
|
180 { |
|
181 double a_elem = real (a (i, j)); |
|
182 double b_elem = real (b (i, j)); |
|
183 if (a_elem < b_elem) |
|
184 result (i, j) = a_elem; |
|
185 else |
|
186 result (i, j) = b_elem; |
|
187 } |
|
188 } |
|
189 else |
|
190 { |
|
191 for (int i = 0; i < nr; i++) |
|
192 { |
|
193 double abs_a_elem = abs (a (i, j)); |
|
194 double abs_b_elem = abs (b (i, j)); |
|
195 if (abs_a_elem < abs_b_elem) |
|
196 result (i, j) = a (i, j); |
|
197 else |
|
198 result (i, j) = b (i, j); |
|
199 } |
|
200 } |
|
201 } |
|
202 |
|
203 return result; |
|
204 } |
|
205 |
|
206 static Matrix |
|
207 max (double d, const Matrix& m) |
|
208 { |
|
209 int nr = m.rows (); |
|
210 int nc = m.columns (); |
|
211 |
|
212 Matrix result (nr, nc); |
|
213 |
|
214 for (int j = 0; j < nc; j++) |
|
215 for (int i = 0; i < nr; i++) |
|
216 { |
|
217 double m_elem = m (i, j); |
|
218 result (i, j) = MAX (d, m_elem); |
|
219 } |
|
220 |
|
221 return result; |
|
222 } |
|
223 |
|
224 static Matrix |
|
225 max (const Matrix& m, double d) |
|
226 { |
|
227 int nr = m.rows (); |
|
228 int nc = m.columns (); |
|
229 |
|
230 Matrix result (nr, nc); |
|
231 |
|
232 for (int j = 0; j < nc; j++) |
|
233 for (int i = 0; i < nr; i++) |
|
234 { |
|
235 double m_elem = m (i, j); |
|
236 result (i, j) = MAX (m_elem, d); |
|
237 } |
|
238 |
|
239 return result; |
|
240 } |
|
241 |
|
242 static ComplexMatrix |
|
243 max (const Complex& c, const ComplexMatrix& m) |
|
244 { |
|
245 int nr = m.rows (); |
|
246 int nc = m.columns (); |
|
247 |
|
248 ComplexMatrix result (nr, nc); |
|
249 |
|
250 double abs_c = abs (c); |
|
251 |
|
252 for (int j = 0; j < nc; j++) |
|
253 for (int i = 0; i < nr; i++) |
|
254 { |
|
255 double abs_m_elem = abs (m (i, j)); |
|
256 if (abs_c > abs_m_elem) |
|
257 result (i, j) = c; |
|
258 else |
|
259 result (i, j) = m (i, j); |
|
260 } |
|
261 |
|
262 return result; |
|
263 } |
|
264 |
|
265 static ComplexMatrix |
|
266 max (const ComplexMatrix& m, const Complex& c) |
|
267 { |
|
268 int nr = m.rows (); |
|
269 int nc = m.columns (); |
|
270 |
|
271 ComplexMatrix result (nr, nc); |
|
272 |
|
273 double abs_c = abs (c); |
|
274 |
|
275 for (int j = 0; j < nc; j++) |
|
276 for (int i = 0; i < nr; i++) |
|
277 { |
|
278 double abs_m_elem = abs (m (i, j)); |
|
279 if (abs_m_elem > abs_c) |
|
280 result (i, j) = m (i, j); |
|
281 else |
|
282 result (i, j) = c; |
|
283 } |
|
284 |
|
285 return result; |
|
286 } |
|
287 |
|
288 static Matrix |
|
289 max (const Matrix& a, const Matrix& b) |
|
290 { |
|
291 int nr = a.rows (); |
|
292 int nc = a.columns (); |
|
293 if (nr != b.rows () || nc != b.columns ()) |
|
294 { |
|
295 error ("two-arg max expecting args of same size"); |
|
296 return Matrix (); |
|
297 } |
|
298 |
|
299 Matrix result (nr, nc); |
|
300 |
|
301 for (int j = 0; j < nc; j++) |
|
302 for (int i = 0; i < nr; i++) |
|
303 { |
|
304 double a_elem = a (i, j); |
|
305 double b_elem = b (i, j); |
|
306 result (i, j) = MAX (a_elem, b_elem); |
|
307 } |
|
308 |
|
309 return result; |
|
310 } |
|
311 |
|
312 static ComplexMatrix |
|
313 max (const ComplexMatrix& a, const ComplexMatrix& b) |
|
314 { |
|
315 int nr = a.rows (); |
|
316 int nc = a.columns (); |
|
317 if (nr != b.rows () || nc != b.columns ()) |
|
318 { |
|
319 error ("two-arg max expecting args of same size"); |
|
320 return ComplexMatrix (); |
|
321 } |
|
322 |
|
323 ComplexMatrix result (nr, nc); |
|
324 |
|
325 for (int j = 0; j < nc; j++) |
|
326 { |
|
327 int columns_are_real_only = 1; |
|
328 for (int i = 0; i < nr; i++) |
|
329 if (imag (a (i, j)) != 0.0 && imag (b (i, j)) != 0.0) |
|
330 { |
|
331 columns_are_real_only = 0; |
|
332 break; |
|
333 } |
|
334 |
|
335 if (columns_are_real_only) |
|
336 { |
|
337 for (int i = 0; i < nr; i++) |
|
338 { |
|
339 double a_elem = real (a (i, j)); |
|
340 double b_elem = real (b (i, j)); |
|
341 if (a_elem > b_elem) |
|
342 result (i, j) = a_elem; |
|
343 else |
|
344 result (i, j) = b_elem; |
|
345 } |
|
346 } |
|
347 else |
|
348 { |
|
349 for (int i = 0; i < nr; i++) |
|
350 { |
|
351 double abs_a_elem = abs (a (i, j)); |
|
352 double abs_b_elem = abs (b (i, j)); |
|
353 if (abs_a_elem > abs_b_elem) |
|
354 result (i, j) = a (i, j); |
|
355 else |
|
356 result (i, j) = b (i, j); |
|
357 } |
|
358 } |
|
359 } |
|
360 |
|
361 return result; |
|
362 } |
|
363 |
|
364 DEFUN_DLD (min, args, nargout, |
|
365 "min (X): minimum value(s) of a vector (matrix)") |
|
366 { |
|
367 octave_value_list retval; |
|
368 |
|
369 int nargin = args.length (); |
|
370 |
|
371 if (nargin < 1 || nargin > 2 || nargout > 2) |
|
372 { |
|
373 print_usage ("min"); |
|
374 return retval; |
|
375 } |
|
376 |
|
377 octave_value arg1; |
|
378 octave_value arg2; |
|
379 |
|
380 switch (nargin) |
|
381 { |
|
382 case 2: |
|
383 arg2 = args(1); |
|
384 // Fall through... |
|
385 |
|
386 case 1: |
|
387 arg1 = args(0); |
|
388 break; |
|
389 |
|
390 default: |
|
391 panic_impossible (); |
|
392 break; |
|
393 } |
|
394 |
|
395 if (nargin == 1 && (nargout == 1 || nargout == 0)) |
|
396 { |
|
397 if (arg1.is_real_type ()) |
|
398 { |
|
399 Matrix m = arg1.matrix_value (); |
|
400 |
|
401 if (! error_state) |
|
402 { |
|
403 if (m.rows () == 1) |
|
404 retval(0) = m.row_min (); |
|
405 else |
|
406 retval(0) = octave_value (m.column_min (), 0); |
|
407 } |
|
408 } |
|
409 else if (arg1.is_complex_type ()) |
|
410 { |
|
411 ComplexMatrix m = arg1.complex_matrix_value (); |
|
412 |
|
413 if (! error_state) |
|
414 { |
|
415 if (m.rows () == 1) |
|
416 retval(0) = m.row_min (); |
|
417 else |
|
418 retval(0) = octave_value (m.column_min (), 0); |
|
419 } |
|
420 } |
|
421 else |
|
422 gripe_wrong_type_arg ("min", arg1); |
|
423 } |
|
424 else if (nargin == 1 && nargout == 2) |
|
425 { |
|
426 Array<int> index; |
|
427 |
|
428 if (arg1.is_real_type ()) |
|
429 { |
|
430 Matrix m = arg1.matrix_value (); |
|
431 |
|
432 if (! error_state) |
|
433 { |
|
434 retval.resize (2); |
|
435 |
|
436 if (m.rows () == 1) |
|
437 retval(0) = m.row_min (index); |
|
438 else |
|
439 retval(0) = octave_value (m.column_min (index), 0); |
|
440 } |
|
441 } |
|
442 else if (arg1.is_complex_type ()) |
|
443 { |
|
444 ComplexMatrix m = arg1.complex_matrix_value (); |
|
445 |
|
446 if (! error_state) |
|
447 { |
|
448 retval.resize (2); |
|
449 |
|
450 if (m.rows () == 1) |
|
451 retval(0) = m.row_min (index); |
|
452 else |
|
453 retval(0) = octave_value (m.column_min (index), 0); |
|
454 } |
|
455 } |
|
456 else |
|
457 gripe_wrong_type_arg ("min", arg1); |
|
458 |
|
459 int len = index.length (); |
|
460 |
|
461 if (len > 0) |
|
462 { |
|
463 RowVector idx (len); |
|
464 |
|
465 for (int i = 0; i < len; i++) |
|
466 { |
|
467 int tmp = index.elem (i) + 1; |
|
468 idx.elem (i) = (tmp <= 0) |
|
469 ? octave_NaN : static_cast<double> (tmp); |
|
470 } |
|
471 |
|
472 retval(1) = octave_value (idx, 0); |
|
473 } |
|
474 } |
|
475 else if (nargin == 2) |
|
476 { |
|
477 int arg1_is_scalar = arg1.is_scalar_type (); |
|
478 int arg2_is_scalar = arg2.is_scalar_type (); |
|
479 |
|
480 int arg1_is_complex = arg1.is_complex_type (); |
|
481 int arg2_is_complex = arg2.is_complex_type (); |
|
482 |
|
483 if (arg1_is_scalar) |
|
484 { |
|
485 if (arg1_is_complex || arg2_is_complex) |
|
486 { |
|
487 Complex c1 = arg1.complex_value (); |
|
488 ComplexMatrix m2 = arg2.complex_matrix_value (); |
|
489 if (! error_state) |
|
490 { |
|
491 ComplexMatrix result = min (c1, m2); |
|
492 if (! error_state) |
|
493 retval(0) = result; |
|
494 } |
|
495 } |
|
496 else |
|
497 { |
|
498 double d1 = arg1.double_value (); |
|
499 Matrix m2 = arg2.matrix_value (); |
|
500 |
|
501 if (! error_state) |
|
502 { |
|
503 Matrix result = min (d1, m2); |
|
504 if (! error_state) |
|
505 retval(0) = result; |
|
506 } |
|
507 } |
|
508 } |
|
509 else if (arg2_is_scalar) |
|
510 { |
|
511 if (arg1_is_complex || arg2_is_complex) |
|
512 { |
|
513 ComplexMatrix m1 = arg1.complex_matrix_value (); |
|
514 |
|
515 if (! error_state) |
|
516 { |
|
517 Complex c2 = arg2.complex_value (); |
|
518 ComplexMatrix result = min (m1, c2); |
|
519 if (! error_state) |
|
520 retval(0) = result; |
|
521 } |
|
522 } |
|
523 else |
|
524 { |
|
525 Matrix m1 = arg1.matrix_value (); |
|
526 |
|
527 if (! error_state) |
|
528 { |
|
529 double d2 = arg2.double_value (); |
|
530 Matrix result = min (m1, d2); |
|
531 if (! error_state) |
|
532 retval(0) = result; |
|
533 } |
|
534 } |
|
535 } |
|
536 else |
|
537 { |
|
538 if (arg1_is_complex || arg2_is_complex) |
|
539 { |
|
540 ComplexMatrix m1 = arg1.complex_matrix_value (); |
|
541 |
|
542 if (! error_state) |
|
543 { |
|
544 ComplexMatrix m2 = arg2.complex_matrix_value (); |
|
545 |
|
546 if (! error_state) |
|
547 { |
|
548 ComplexMatrix result = min (m1, m2); |
|
549 if (! error_state) |
|
550 retval(0) = result; |
|
551 } |
|
552 } |
|
553 } |
|
554 else |
|
555 { |
|
556 Matrix m1 = arg1.matrix_value (); |
|
557 |
|
558 if (! error_state) |
|
559 { |
|
560 Matrix m2 = arg2.matrix_value (); |
|
561 |
|
562 if (! error_state) |
|
563 { |
|
564 Matrix result = min (m1, m2); |
|
565 if (! error_state) |
|
566 retval(0) = result; |
|
567 } |
|
568 } |
|
569 } |
|
570 } |
|
571 } |
|
572 else |
|
573 panic_impossible (); |
|
574 |
|
575 return retval; |
|
576 } |
|
577 |
|
578 DEFUN_DLD (max, args, nargout, |
|
579 "max (X): maximum value(s) of a vector (matrix)") |
|
580 { |
|
581 octave_value_list retval; |
|
582 |
|
583 int nargin = args.length (); |
|
584 |
|
585 if (nargin < 1 || nargin > 2 || nargout > 2) |
|
586 { |
|
587 print_usage ("max"); |
|
588 return retval; |
|
589 } |
|
590 |
|
591 octave_value arg1; |
|
592 octave_value arg2; |
|
593 |
|
594 switch (nargin) |
|
595 { |
|
596 case 2: |
|
597 arg2 = args(1); |
|
598 // Fall through... |
|
599 |
|
600 case 1: |
|
601 arg1 = args(0); |
|
602 break; |
|
603 |
|
604 default: |
|
605 panic_impossible (); |
|
606 break; |
|
607 } |
|
608 |
|
609 if (nargin == 1 && (nargout == 1 || nargout == 0)) |
|
610 { |
|
611 if (arg1.is_real_type ()) |
|
612 { |
|
613 Matrix m = arg1.matrix_value (); |
|
614 |
|
615 if (! error_state) |
|
616 { |
|
617 if (m.rows () == 1) |
|
618 retval(0) = m.row_max (); |
|
619 else |
|
620 retval(0) = octave_value (m.column_max (), 0); |
|
621 } |
|
622 } |
|
623 else if (arg1.is_complex_type ()) |
|
624 { |
|
625 ComplexMatrix m = arg1.complex_matrix_value (); |
|
626 |
|
627 if (! error_state) |
|
628 { |
|
629 if (m.rows () == 1) |
|
630 retval(0) = m.row_max (); |
|
631 else |
|
632 retval(0) = octave_value (m.column_max (), 0); |
|
633 } |
|
634 } |
|
635 else |
|
636 gripe_wrong_type_arg ("max", arg1); |
|
637 } |
|
638 else if (nargin == 1 && nargout == 2) |
|
639 { |
|
640 Array<int> index; |
|
641 |
|
642 if (arg1.is_real_type ()) |
|
643 { |
|
644 Matrix m = arg1.matrix_value (); |
|
645 |
|
646 if (! error_state) |
|
647 { |
|
648 retval.resize (2); |
|
649 |
|
650 if (m.rows () == 1) |
|
651 retval(0) = m.row_max (index); |
|
652 else |
|
653 retval(0) = octave_value (m.column_max (index), 0); |
|
654 } |
|
655 } |
|
656 else if (arg1.is_complex_type ()) |
|
657 { |
|
658 ComplexMatrix m = arg1.complex_matrix_value (); |
|
659 |
|
660 if (! error_state) |
|
661 { |
|
662 retval.resize (2); |
|
663 |
|
664 if (m.rows () == 1) |
|
665 retval(0) = m.row_max (index); |
|
666 else |
|
667 retval(0) = octave_value (m.column_max (index), 0); |
|
668 } |
|
669 } |
|
670 else |
|
671 gripe_wrong_type_arg ("max", arg1); |
|
672 |
|
673 int len = index.length (); |
|
674 |
|
675 if (len > 0) |
|
676 { |
|
677 RowVector idx (len); |
|
678 |
|
679 for (int i = 0; i < len; i++) |
|
680 { |
|
681 int tmp = index.elem (i) + 1; |
|
682 idx.elem (i) = (tmp <= 0) |
|
683 ? octave_NaN : static_cast<double> (tmp); |
|
684 } |
|
685 |
|
686 retval(1) = octave_value (idx, 0); |
|
687 } |
|
688 } |
|
689 else if (nargin == 2) |
|
690 { |
|
691 int arg1_is_scalar = arg1.is_scalar_type (); |
|
692 int arg2_is_scalar = arg2.is_scalar_type (); |
|
693 |
|
694 int arg1_is_complex = arg1.is_complex_type (); |
|
695 int arg2_is_complex = arg2.is_complex_type (); |
|
696 |
|
697 if (arg1_is_scalar) |
|
698 { |
|
699 if (arg1_is_complex || arg2_is_complex) |
|
700 { |
|
701 Complex c1 = arg1.complex_value (); |
|
702 ComplexMatrix m2 = arg2.complex_matrix_value (); |
|
703 if (! error_state) |
|
704 { |
|
705 ComplexMatrix result = max (c1, m2); |
|
706 if (! error_state) |
|
707 retval(0) = result; |
|
708 } |
|
709 } |
|
710 else |
|
711 { |
|
712 double d1 = arg1.double_value (); |
|
713 Matrix m2 = arg2.matrix_value (); |
|
714 |
|
715 if (! error_state) |
|
716 { |
|
717 Matrix result = max (d1, m2); |
|
718 if (! error_state) |
|
719 retval(0) = result; |
|
720 } |
|
721 } |
|
722 } |
|
723 else if (arg2_is_scalar) |
|
724 { |
|
725 if (arg1_is_complex || arg2_is_complex) |
|
726 { |
|
727 ComplexMatrix m1 = arg1.complex_matrix_value (); |
|
728 |
|
729 if (! error_state) |
|
730 { |
|
731 Complex c2 = arg2.complex_value (); |
|
732 ComplexMatrix result = max (m1, c2); |
|
733 if (! error_state) |
|
734 retval(0) = result; |
|
735 } |
|
736 } |
|
737 else |
|
738 { |
|
739 Matrix m1 = arg1.matrix_value (); |
|
740 |
|
741 if (! error_state) |
|
742 { |
|
743 double d2 = arg2.double_value (); |
|
744 Matrix result = max (m1, d2); |
|
745 if (! error_state) |
|
746 retval(0) = result; |
|
747 } |
|
748 } |
|
749 } |
|
750 else |
|
751 { |
|
752 if (arg1_is_complex || arg2_is_complex) |
|
753 { |
|
754 ComplexMatrix m1 = arg1.complex_matrix_value (); |
|
755 |
|
756 if (! error_state) |
|
757 { |
|
758 ComplexMatrix m2 = arg2.complex_matrix_value (); |
|
759 |
|
760 if (! error_state) |
|
761 { |
|
762 ComplexMatrix result = max (m1, m2); |
|
763 if (! error_state) |
|
764 retval(0) = result; |
|
765 } |
|
766 } |
|
767 } |
|
768 else |
|
769 { |
|
770 Matrix m1 = arg1.matrix_value (); |
|
771 |
|
772 if (! error_state) |
|
773 { |
|
774 Matrix m2 = arg2.matrix_value (); |
|
775 |
|
776 if (! error_state) |
|
777 { |
|
778 Matrix result = max (m1, m2); |
|
779 if (! error_state) |
|
780 retval(0) = result; |
|
781 } |
|
782 } |
|
783 } |
|
784 } |
|
785 } |
|
786 else |
|
787 panic_impossible (); |
|
788 |
|
789 return retval; |
|
790 } |
|
791 |
|
792 /* |
|
793 ;;; Local Variables: *** |
|
794 ;;; mode: C++ *** |
|
795 ;;; End: *** |
|
796 */ |