annotate src/DLD-FUNCTIONS/max.cc @ 8778:09ab0cc57ba6

improve cummin/cummax inline docs
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 17 Feb 2009 11:40:40 +0100
parents 724c0f46d9d4
children ea76466605ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
1 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 2005, 2006, 2007 John W. Eaton
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
5 Copyright (C) 2009 VZLU Prague
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
6
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
8
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6711
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6711
diff changeset
12 option) any later version.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
13
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
17 for more details.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
18
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6711
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6711
diff changeset
21 <http://www.gnu.org/licenses/>.
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
22
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
23 */
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
24
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
27 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29 #include "lo-ieee.h"
3248
68259f410026 [project @ 1999-07-13 03:34:54 by jwe]
jwe
parents: 3243
diff changeset
30 #include "lo-mappers.h"
7231
2eb392d058bb [project @ 2007-11-30 18:53:29 by jwe]
jwe
parents: 7189
diff changeset
31 #include "lo-math.h"
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
32 #include "dNDArray.h"
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
33 #include "CNDArray.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4102
diff changeset
34 #include "quit.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
35
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "defun-dld.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
37 #include "error.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38 #include "gripes.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
39 #include "oct-obj.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
40
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
41 #include "ov-cx-mat.h"
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
42 #include "ov-re-sparse.h"
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
43 #include "ov-cx-sparse.h"
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
44
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
45 #define MINMAX_DOUBLE_SBODY(FCN) \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
46 { \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
47 if (nargout == 1 || nargout == 0) \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
48 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
49 if (arg1.is_real_type ()) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
50 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
51 NDArray m = arg1.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
52 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
53 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
54 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
55 NDArray n = m. FCN (dim); \
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
56 retval(0) = n; \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
57 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
58 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
59 else if (arg1.is_complex_type ()) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
60 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
61 ComplexNDArray m = arg1.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
62 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
63 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
64 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
65 ComplexNDArray n = m. FCN (dim); \
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
66 retval(0) = n; \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
67 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
68 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
69 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
70 gripe_wrong_type_arg (#FCN, arg1); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
71 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
72 else if (nargout == 2) \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
73 { \
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4869
diff changeset
74 ArrayN<octave_idx_type> index; \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
75 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
76 if (arg1.is_real_type ()) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
77 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
78 NDArray m = arg1.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
79 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
80 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
81 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
82 NDArray n = m. FCN (index, dim); \
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
83 retval(0) = n; \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
84 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
85 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
86 else if (arg1.is_complex_type ()) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
87 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
88 ComplexNDArray m = arg1.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
89 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
90 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
91 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
92 ComplexNDArray n = m. FCN (index, dim); \
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
93 retval(0) = n; \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
94 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
95 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
96 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
97 gripe_wrong_type_arg (#FCN, arg1); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
98 \
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 4869
diff changeset
99 octave_idx_type len = index.numel (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
100 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
101 if (len > 0) \
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
102 retval(1) = NDArray (index, true, true); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
103 else \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
104 retval(1) = NDArray (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
105 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
106 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
107
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
108 #define MINMAX_DOUBLE_BODY(FCN) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
109 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
110 bool single_arg = (nargin == 1) || (arg2.is_empty() && nargin == 3); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
111 if (single_arg) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
112 MINMAX_DOUBLE_SBODY (FCN) \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
113 else \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
114 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
115 int arg1_is_scalar = arg1.is_scalar_type (); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
116 int arg2_is_scalar = arg2.is_scalar_type (); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
117 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
118 int arg1_is_complex = arg1.is_complex_type (); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
119 int arg2_is_complex = arg2.is_complex_type (); \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
120 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
121 if (arg1_is_scalar) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
122 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
123 if (arg1_is_complex || arg2_is_complex) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
124 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
125 Complex c1 = arg1.complex_value (); \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
126 ComplexNDArray m2 = arg2.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
127 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
128 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
129 ComplexNDArray result = FCN (c1, m2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
130 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
131 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
132 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
133 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
134 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
135 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
136 double d1 = arg1.double_value (); \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
137 NDArray m2 = arg2.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
138 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
139 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
140 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
141 NDArray result = FCN (d1, m2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
142 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
143 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
144 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
145 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
146 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
147 else if (arg2_is_scalar) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
148 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
149 if (arg1_is_complex || arg2_is_complex) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
150 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
151 ComplexNDArray m1 = arg1.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
152 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
153 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
154 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
155 Complex c2 = arg2.complex_value (); \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
156 ComplexNDArray result = FCN (m1, c2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
157 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
158 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
159 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
160 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
161 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
162 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
163 NDArray m1 = arg1.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
164 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
165 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
166 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
167 double d2 = arg2.double_value (); \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
168 NDArray result = FCN (m1, d2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
169 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
170 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
171 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
172 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
173 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
174 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
175 { \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
176 if (arg1_is_complex || arg2_is_complex) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
177 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
178 ComplexNDArray m1 = arg1.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
179 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
180 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
181 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
182 ComplexNDArray m2 = arg2.complex_array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
183 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
184 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
185 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
186 ComplexNDArray result = FCN (m1, m2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
187 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
188 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
189 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
190 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
191 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
192 else \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
193 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
194 NDArray m1 = arg1.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
195 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
196 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
197 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
198 NDArray m2 = arg2.array_value (); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
199 \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
200 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
201 { \
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
202 NDArray result = FCN (m1, m2); \
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
203 if (! error_state) \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
204 retval(0) = result; \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
205 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
206 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
207 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
208 } \
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
209 } \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
210 }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
211
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
212 #define MINMAX_SINGLE_SBODY(FCN) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
213 { \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
214 if (nargout == 1 || nargout == 0) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
215 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
216 if (arg1.is_real_type ()) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
217 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
218 FloatNDArray m = arg1.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
219 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
220 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
221 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
222 FloatNDArray n = m. FCN (dim); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
223 retval(0) = n; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
224 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
225 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
226 else if (arg1.is_complex_type ()) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
227 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
228 FloatComplexNDArray m = arg1.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
229 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
230 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
231 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
232 FloatComplexNDArray n = m. FCN (dim); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
233 retval(0) = n; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
234 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
235 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
236 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
237 gripe_wrong_type_arg (#FCN, arg1); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
238 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
239 else if (nargout == 2) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
240 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
241 ArrayN<octave_idx_type> index; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
242 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
243 if (arg1.is_real_type ()) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
244 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
245 FloatNDArray m = arg1.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
246 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
247 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
248 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
249 FloatNDArray n = m. FCN (index, dim); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
250 retval(0) = n; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
251 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
252 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
253 else if (arg1.is_complex_type ()) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
254 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
255 FloatComplexNDArray m = arg1.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
256 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
257 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
258 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
259 FloatComplexNDArray n = m. FCN (index, dim); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
260 retval(0) = n; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
261 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
262 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
263 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
264 gripe_wrong_type_arg (#FCN, arg1); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
265 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
266 octave_idx_type len = index.numel (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
267 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
268 if (len > 0) \
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
269 retval(1) = NDArray (index, true, true); \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
270 else \
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
271 retval(1) = NDArray (); \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
272 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
273 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
274
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
275 #define MINMAX_SINGLE_BODY(FCN) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
276 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
277 bool single_arg = (nargin == 1) || (arg2.is_empty() && nargin == 3); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
278 if (single_arg) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
279 MINMAX_SINGLE_SBODY(FCN) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
280 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
281 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
282 int arg1_is_scalar = arg1.is_scalar_type (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
283 int arg2_is_scalar = arg2.is_scalar_type (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
284 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
285 int arg1_is_complex = arg1.is_complex_type (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
286 int arg2_is_complex = arg2.is_complex_type (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
287 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
288 if (arg1_is_scalar) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
289 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
290 if (arg1_is_complex || arg2_is_complex) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
291 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
292 FloatComplex c1 = arg1.float_complex_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
293 FloatComplexNDArray m2 = arg2.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
294 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
295 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
296 FloatComplexNDArray result = FCN (c1, m2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
297 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
298 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
299 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
300 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
301 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
302 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
303 float d1 = arg1.float_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
304 FloatNDArray m2 = arg2.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
305 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
306 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
307 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
308 FloatNDArray result = FCN (d1, m2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
309 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
310 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
311 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
312 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
313 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
314 else if (arg2_is_scalar) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
315 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
316 if (arg1_is_complex || arg2_is_complex) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
317 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
318 FloatComplexNDArray m1 = arg1.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
319 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
320 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
321 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
322 FloatComplex c2 = arg2.float_complex_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
323 FloatComplexNDArray result = FCN (m1, c2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
324 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
325 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
326 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
327 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
328 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
329 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
330 FloatNDArray m1 = arg1.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
331 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
332 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
333 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
334 float d2 = arg2.float_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
335 FloatNDArray result = FCN (m1, d2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
336 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
337 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
338 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
339 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
340 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
341 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
342 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
343 if (arg1_is_complex || arg2_is_complex) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
344 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
345 FloatComplexNDArray m1 = arg1.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
346 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
347 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
348 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
349 FloatComplexNDArray m2 = arg2.float_complex_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
350 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
351 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
352 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
353 FloatComplexNDArray result = FCN (m1, m2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
354 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
355 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
356 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
357 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
358 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
359 else \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
360 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
361 FloatNDArray m1 = arg1.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
362 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
363 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
364 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
365 FloatNDArray m2 = arg2.float_array_value (); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
366 \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
367 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
368 { \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
369 FloatNDArray result = FCN (m1, m2); \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
370 if (! error_state) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
371 retval(0) = result; \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
372 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
373 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
374 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
375 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
376 } \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
377 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
378
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
379 #define MINMAX_INT_SBODY(FCN, TYP) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
380 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
381 if (nargout == 1 || nargout == 0) \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
382 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
383 TYP ## NDArray m = arg1. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
384 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
385 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
386 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
387 TYP ## NDArray n = m. FCN (dim); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
388 retval(0) = n; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
389 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
390 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
391 else if (nargout == 2) \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
392 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
393 ArrayN<octave_idx_type> index; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
394 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
395 TYP ## NDArray m = arg1. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
396 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
397 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
398 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
399 TYP ## NDArray n = m. FCN (index, dim); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
400 retval(0) = n; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
401 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
402 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
403 octave_idx_type len = index.numel (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
404 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
405 if (len > 0) \
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
406 retval(1) = NDArray (index, true, true); \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
407 else \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
408 retval(1) = NDArray (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
409 } \
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
410 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
411
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
412 #define MINMAX_INT_BODY(FCN, TYP) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
413 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
414 bool single_arg = (nargin == 1) || (arg2.is_empty() && nargin == 3); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
415 if (single_arg) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
416 MINMAX_INT_SBODY (FCN, TYP) \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
417 else \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
418 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
419 int arg1_is_scalar = arg1.is_scalar_type (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
420 int arg2_is_scalar = arg2.is_scalar_type (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
421 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
422 if (arg1_is_scalar) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
423 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
424 octave_ ## TYP d1 = arg1. TYP ## _scalar_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
425 TYP ## NDArray m2 = arg2. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
426 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
427 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
428 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
429 TYP ## NDArray result = FCN (d1, m2); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
430 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
431 retval(0) = result; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
432 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
433 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
434 else if (arg2_is_scalar) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
435 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
436 TYP ## NDArray m1 = arg1. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
437 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
438 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
439 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
440 octave_ ## TYP d2 = arg2. TYP ## _scalar_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
441 TYP ## NDArray result = FCN (m1, d2); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
442 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
443 retval(0) = result; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
444 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
445 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
446 else \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
447 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
448 TYP ## NDArray m1 = arg1. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
449 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
450 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
451 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
452 TYP ## NDArray m2 = arg2. TYP ## _array_value (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
453 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
454 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
455 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
456 TYP ## NDArray result = FCN (m1, m2); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
457 if (! error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
458 retval(0) = result; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
459 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
460 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
461 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
462 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
463 }
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
464
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
465 #define MINMAX_SPARSE_BODY(FCN) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
466 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
467 bool single_arg = (nargin == 1) || arg2.is_empty(); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
468 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
469 if (single_arg && (nargout == 1 || nargout == 0)) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
470 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
471 if (arg1.type_id () == octave_sparse_matrix::static_type_id ()) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
472 retval(0) = arg1.sparse_matrix_value () .FCN (dim); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
473 else if (arg1.type_id () == \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
474 octave_sparse_complex_matrix::static_type_id ()) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
475 retval(0) = arg1.sparse_complex_matrix_value () .FCN (dim); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
476 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
477 gripe_wrong_type_arg (#FCN, arg1); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
478 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
479 else if (single_arg && nargout == 2) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
480 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
481 Array2<octave_idx_type> index; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
482 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
483 if (arg1.type_id () == octave_sparse_matrix::static_type_id ()) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
484 retval(0) = arg1.sparse_matrix_value () .FCN (index, dim); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
485 else if (arg1.type_id () == \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
486 octave_sparse_complex_matrix::static_type_id ()) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
487 retval(0) = arg1.sparse_complex_matrix_value () .FCN (index, dim); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
488 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
489 gripe_wrong_type_arg (#FCN, arg1); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
490 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
491 octave_idx_type len = index.numel (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
492 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
493 if (len > 0) \
7919
9d080df0c843 new NDArray constructor for ArrayN<octave_idx_type>
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
494 retval(1) = NDArray (index, true, true); \
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
495 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
496 retval(1) = NDArray (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
497 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
498 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
499 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
500 int arg1_is_scalar = arg1.is_scalar_type (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
501 int arg2_is_scalar = arg2.is_scalar_type (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
502 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
503 int arg1_is_complex = arg1.is_complex_type (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
504 int arg2_is_complex = arg2.is_complex_type (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
505 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
506 if (arg1_is_scalar) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
507 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
508 if (arg1_is_complex || arg2_is_complex) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
509 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
510 Complex c1 = arg1.complex_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
511 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
512 SparseComplexMatrix m2 = arg2.sparse_complex_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
513 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
514 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
515 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
516 SparseComplexMatrix result = FCN (c1, m2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
517 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
518 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
519 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
520 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
521 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
522 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
523 double d1 = arg1.double_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
524 SparseMatrix m2 = arg2.sparse_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
525 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
526 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
527 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
528 SparseMatrix result = FCN (d1, m2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
529 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
530 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
531 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
532 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
533 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
534 else if (arg2_is_scalar) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
535 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
536 if (arg1_is_complex || arg2_is_complex) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
537 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
538 SparseComplexMatrix m1 = arg1.sparse_complex_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
539 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
540 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
541 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
542 Complex c2 = arg2.complex_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
543 SparseComplexMatrix result = FCN (m1, c2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
544 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
545 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
546 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
547 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
548 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
549 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
550 SparseMatrix m1 = arg1.sparse_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
551 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
552 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
553 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
554 double d2 = arg2.double_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
555 SparseMatrix result = FCN (m1, d2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
556 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
557 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
558 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
559 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
560 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
561 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
562 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
563 if (arg1_is_complex || arg2_is_complex) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
564 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
565 SparseComplexMatrix m1 = arg1.sparse_complex_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
566 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
567 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
568 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
569 SparseComplexMatrix m2 = arg2.sparse_complex_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
570 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
571 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
572 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
573 SparseComplexMatrix result = FCN (m1, m2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
574 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
575 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
576 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
577 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
578 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
579 else \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
580 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
581 SparseMatrix m1 = arg1.sparse_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
582 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
583 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
584 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
585 SparseMatrix m2 = arg2.sparse_matrix_value (); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
586 \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
587 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
588 { \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
589 SparseMatrix result = FCN (m1, m2); \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
590 if (! error_state) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
591 retval(0) = result; \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
592 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
593 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
594 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
595 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
596 } \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
597 }
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
598
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
599
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
600 #define MINMAX_BODY(FCN) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
601 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
602 octave_value_list retval; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
603 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
604 int nargin = args.length (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
605 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
606 if (nargin < 1 || nargin > 3 || nargout > 2) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
607 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
608 print_usage (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
609 return retval; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
610 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
611 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
612 octave_value arg1; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
613 octave_value arg2; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
614 octave_value arg3; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
615 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
616 switch (nargin) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
617 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
618 case 3: \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
619 arg3 = args(2); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
620 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
621 case 2: \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
622 arg2 = args(1); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
623 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
624 case 1: \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
625 arg1 = args(0); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
626 break; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
627 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
628 default: \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
629 panic_impossible (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
630 break; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
631 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
632 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
633 int dim; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
634 dim_vector dv = arg1.dims (); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
635 if (error_state) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
636 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
637 gripe_wrong_type_arg (#FCN, arg1); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
638 return retval; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
639 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
640 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
641 if (nargin == 3) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
642 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
643 dim = arg3.nint_value () - 1; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
644 if (dim < 0 || dim >= dv.length ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
645 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
646 error ("%s: invalid dimension", #FCN); \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
647 return retval; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
648 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
649 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
650 else \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
651 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
652 dim = 0; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
653 while ((dim < dv.length ()) && (dv (dim) <= 1)) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
654 dim++; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
655 if (dim == dv.length ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
656 dim = 0; \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
657 } \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
658 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
659 if (arg1.is_integer_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
660 { \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
661 if (arg1.is_uint8_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
662 MINMAX_INT_BODY (FCN, uint8) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
663 else if (arg1.is_uint16_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
664 MINMAX_INT_BODY (FCN, uint16) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
665 else if (arg1.is_uint32_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
666 MINMAX_INT_BODY (FCN, uint32) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
667 else if (arg1.is_uint64_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
668 MINMAX_INT_BODY (FCN, uint64) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
669 else if (arg1.is_int8_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
670 MINMAX_INT_BODY (FCN, int8) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
671 else if (arg1.is_int16_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
672 MINMAX_INT_BODY (FCN, int16) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
673 else if (arg1.is_int32_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
674 MINMAX_INT_BODY (FCN, int32) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
675 else if (arg1.is_int64_type ()) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
676 MINMAX_INT_BODY (FCN, int64) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
677 } \
7505
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
678 else if (arg1.is_sparse_type ()) \
f5005d9510f4 Remove dispatched sparse functions and treat in the generic versions of the functions
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
679 MINMAX_SPARSE_BODY (FCN) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
680 else if (arg1.is_single_type ()) \
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7662
diff changeset
681 MINMAX_SINGLE_BODY (FCN) \
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
682 else \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
683 MINMAX_DOUBLE_BODY (FCN) \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
684 \
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7017
diff changeset
685 return retval;
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
686
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
687 DEFUN_DLD (min, args, nargout,
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
688 "-*- texinfo -*-\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
689 @deftypefn {Mapping Function} {} min (@var{x}, @var{y}, @var{dim})\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
690 @deftypefnx {Mapping Function} {[@var{w}, @var{iw}] =} min (@var{x})\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
691 @cindex Utility Functions\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
692 For a vector argument, return the minimum value. For a matrix\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
693 argument, return the minimum value from each column, as a row\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
694 vector, or over the dimension @var{dim} if defined. For two matrices\n\
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
695 (or a matrix and scalar), return the pair-wise minimum.\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
696 Thus,\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
697 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
698 @example\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
699 min (min (@var{x}))\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
700 @end example\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
701 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
702 @noindent\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
703 returns the smallest element of @var{x}, and\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
704 \n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
705 @example\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
706 @group\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
707 min (2:5, pi)\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
708 @result{} 2.0000 3.0000 3.1416 3.1416\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
709 @end group\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
710 @end example\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
711 @noindent\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
712 compares each element of the range @code{2:5} with @code{pi}, and\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
713 returns a row vector of the minimum values.\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
714 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
715 For complex arguments, the magnitude of the elements are used for\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
716 comparison.\n\
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
717 \n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
718 If called with one input and two output arguments,\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
719 @code{min} also returns the first index of the\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
720 minimum value(s). Thus,\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
721 \n\
3775
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3747
diff changeset
722 @example\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
723 @group\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
724 [x, ix] = min ([1, 3, 0, 2, 5])\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
725 @result{} x = 0\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
726 ix = 3\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
727 @end group\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
728 @end example\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
729 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
730 {
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
731 MINMAX_BODY (min);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
732 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
733
7600
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
734 /*
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
735
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
736 %% test/octave.test/arith/min-1.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
737 %!assert (min ([1, 4, 2, 3]) == 1);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
738 %!assert (min ([1; -10; 5; -2]) == -10);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
739
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
740 %% test/octave.test/arith/min-2.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
741 %!assert(all (min ([4, i; -2, 2]) == [-2, i]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
742
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
743 %% test/octave.test/arith/min-3.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
744 %!error <Invalid call to min.*> min ();
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
745
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
746 %% test/octave.test/arith/min-4.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
747 %!error <Invalid call to min.*> min (1, 2, 3, 4);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
748
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
749 %!test
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
750 %! x = reshape (1:8,[2,2,2]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
751 %! assert (max (x,[],1), reshape ([2, 4, 6, 8], [1,2,2]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
752 %! assert (max (x,[],2), reshape ([3, 4, 7, 8], [2,1,2]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
753 %! [y, i ] = max (x, [], 3);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
754 %! assert (y, [5, 7; 6, 8]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
755 %! assert (ndims(y), 2);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
756 %! assert (i, [2, 2; 2, 2]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
757 %! assert (ndims(i), 2);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
758
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
759 */
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
760
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
761 DEFUN_DLD (max, args, nargout,
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
762 "-*- texinfo -*-\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
763 @deftypefn {Mapping Function} {} max (@var{x}, @var{y}, @var{dim})\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
764 @deftypefnx {Mapping Function} {[@var{w}, @var{iw}] =} max (@var{x})\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
765 @cindex Utility Functions\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
766 For a vector argument, return the maximum value. For a matrix\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
767 argument, return the maximum value from each column, as a row\n\
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
768 vector, or over the dimension @var{dim} if defined. For two matrices\n\
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4522
diff changeset
769 (or a matrix and scalar), return the pair-wise maximum.\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
770 Thus,\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
771 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
772 @example\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
773 max (max (@var{x}))\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
774 @end example\n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
775 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
776 @noindent\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
777 returns the largest element of @var{x}, and\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
778 \n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
779 @example\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
780 @group\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
781 max (2:5, pi)\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
782 @result{} 3.1416 3.1416 4.0000 5.0000\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
783 @end group\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
784 @end example\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
785 @noindent\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
786 compares each element of the range @code{2:5} with @code{pi}, and\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
787 returns a row vector of the maximum values.\n\
3443
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
788 \n\
bf22deaf04ed [project @ 2000-01-17 08:28:27 by jwe]
jwe
parents: 3418
diff changeset
789 For complex arguments, the magnitude of the elements are used for\n\
3775
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3747
diff changeset
790 comparison.\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
791 \n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
792 If called with one input and two output arguments,\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
793 @code{max} also returns the first index of the\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
794 maximum value(s). Thus,\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
795 \n\
3775
13905c3a24af [project @ 2001-02-06 01:56:59 by jwe]
jwe
parents: 3747
diff changeset
796 @example\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
797 @group\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
798 [x, ix] = max ([1, 3, 5, 2, 5])\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
799 @result{} x = 5\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
800 ix = 3\n\
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
801 @end group\n\
3657
a908150a3a32 [project @ 2000-04-11 19:02:03 by jwe]
jwe
parents: 3443
diff changeset
802 @end example\n\
4522
abdcb14e598d [project @ 2003-09-28 22:04:01 by jwe]
jwe
parents: 4309
diff changeset
803 @end deftypefn")
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
804 {
3747
50f30e40abca [project @ 2000-12-07 05:47:06 by jwe]
jwe
parents: 3657
diff changeset
805 MINMAX_BODY (max);
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
806 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
807
7600
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
808 /*
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
809
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
810 %% test/octave.test/arith/max-1.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
811 %!assert (max ([1, 4, 2, 3]) == 4);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
812 %!assert (max ([1; -10; 5; -2]) == 5);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
813
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
814 %% test/octave.test/arith/max-2.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
815 %!assert(all (max ([4, i 4.999; -2, 2, 3+4i]) == [4, 2, 3+4i]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
816
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
817 %% test/octave.test/arith/max-3.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
818 %!error <Invalid call to max.*> max ();
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
819
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
820 %% test/octave.test/arith/max-4.m
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
821 %!error <Invalid call to max.*> max (1, 2, 3, 4);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
822
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
823 %!test
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
824 %! x = reshape (1:8,[2,2,2]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
825 %! assert (min (x,[],1), reshape ([1, 3, 5, 7], [1,2,2]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
826 %! assert (min (x,[],2), reshape ([1, 2, 5, 6], [2,1,2]));
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
827 %! [y, i ] = min (x, [], 3);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
828 %! assert (y, [1, 3; 2, 4]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
829 %! assert (ndims(y), 2);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
830 %! assert (i, [1, 1; 1, 1]);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
831 %! assert (ndims(i), 2);
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
832
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
833
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
834 */
24abf5a702d9 Chop trailing singletons in min/max functions
David Bateman <dbateman@free.fr>
parents: 7505
diff changeset
835
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
836 #define CUMMINMAX_BODY(FCN) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
837 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
838 octave_value_list retval; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
839 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
840 int nargin = args.length (); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
841 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
842 if (nargin < 1 || nargin > 2 || nargout > 2) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
843 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
844 print_usage (); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
845 return retval; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
846 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
847 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
848 octave_value arg1; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
849 octave_value arg2; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
850 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
851 switch (nargin) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
852 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
853 case 2: \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
854 arg2 = args(1); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
855 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
856 case 1: \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
857 arg1 = args(0); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
858 break; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
859 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
860 default: \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
861 panic_impossible (); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
862 break; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
863 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
864 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
865 dim_vector dv = arg1.dims (); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
866 if (error_state) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
867 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
868 gripe_wrong_type_arg (#FCN, arg1); \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
869 return retval; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
870 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
871 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
872 int dim = 0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
873 while ((dim < dv.length ()) && (dv (dim) <= 1)) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
874 dim++; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
875 if (dim == dv.length ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
876 dim = 0; \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
877 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
878 if (arg1.is_integer_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
879 { \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
880 if (arg1.is_uint8_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
881 MINMAX_INT_SBODY (FCN, uint8) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
882 else if (arg1.is_uint16_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
883 MINMAX_INT_SBODY (FCN, uint16) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
884 else if (arg1.is_uint32_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
885 MINMAX_INT_SBODY (FCN, uint32) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
886 else if (arg1.is_uint64_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
887 MINMAX_INT_SBODY (FCN, uint64) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
888 else if (arg1.is_int8_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
889 MINMAX_INT_SBODY (FCN, int8) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
890 else if (arg1.is_int16_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
891 MINMAX_INT_SBODY (FCN, int16) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
892 else if (arg1.is_int32_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
893 MINMAX_INT_SBODY (FCN, int32) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
894 else if (arg1.is_int64_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
895 MINMAX_INT_SBODY (FCN, int64) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
896 } \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
897 else if (arg1.is_single_type ()) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
898 MINMAX_SINGLE_SBODY (FCN) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
899 else \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
900 MINMAX_DOUBLE_SBODY (FCN) \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
901 \
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
902 return retval;
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
903
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
904 DEFUN_DLD (cummin, args, nargout,
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
905 "-*- texinfo -*-\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
906 @deftypefn {Mapping Function} {} cummin (@var{x}, @var{dim})\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
907 @deftypefnx {Mapping Function} {[@var{w}, @var{iw}] =} cummin (@var{x})\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
908 @cindex Utility Functions\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
909 Return the cumulative minimum values. That means, the call\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
910 @example\n\
8778
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
911 [@var{w}, @var{iw}] = cummin (@var{x}, @var{dim})\n\
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
912 @end example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
913 \n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
914 @noindent\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
915 is equivalent to the following code:\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
916 @example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
917 for i = 1:size (x, dim)\n\
8778
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
918 [@var{w}(:,@dots{},i:,@dots{},), @var{iw}(:,@dots{},i:,@dots{},)] =\
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
919 min(@var{x}(:,@dots{},i,:,@dots{}), @var{dim});\n\
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
920 endfor\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
921 @end example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
922 \n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
923 @noindent\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
924 but computed in a much faster manner.\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
925 The behaviour if @var{dim} or @var{iw} is unspecified is analogous\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
926 to @code{min}.\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
927 @end deftypefn")
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
928 {
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
929 CUMMINMAX_BODY (cummin);
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
930 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
931
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
932 DEFUN_DLD (cummax, args, nargout,
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
933 "-*- texinfo -*-\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
934 @deftypefn {Mapping Function} {} cummax (@var{x}, @var{dim})\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
935 @deftypefnx {Mapping Function} {[@var{w}, @var{iw}] =} cummax (@var{x})\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
936 @cindex Utility Functions\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
937 Return the cumulative maximum values. That means, the call\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
938 @example\n\
8778
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
939 [@var{w}, @var{iw}] = cummax (@var{x}, @var{dim})\n\
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
940 @end example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
941 \n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
942 @noindent\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
943 is equivalent to the following code:\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
944 @example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
945 for i = 1:size (x, dim)\n\
8778
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
946 [@var{w}(:,@dots{},i:,@dots{},), @var{iw}(:,@dots{},i:,@dots{},)] =\
09ab0cc57ba6 improve cummin/cummax inline docs
Jaroslav Hajek <highegg@gmail.com>
parents: 8777
diff changeset
947 max(@var{x}(:,@dots{},i,:,@dots{}), @var{dim});\n\
8777
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
948 endfor\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
949 @end example\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
950 \n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
951 @noindent\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
952 but computed in a much faster manner.\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
953 The behaviour if @var{dim} or @var{iw} is unspecified is analogous\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
954 to @code{max}.\n\
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
955 @end deftypefn")
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
956 {
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
957 CUMMINMAX_BODY (cummax);
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
958 }
724c0f46d9d4 implement cummin/cummax functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7919
diff changeset
959
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
960 /*
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
961 ;;; Local Variables: ***
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
962 ;;; mode: C++ ***
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
963 ;;; End: ***
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
964 */