Mercurial > hg > octave-lyh
annotate src/ops.h @ 9689:34d6f005db4b
eliminate is_string argument from octave_value character array constructors
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2009 00:11:07 -0400 |
parents | a9b37bae1802 |
children | cd96d29c5efa |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 1998, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
7017 | 4 John W. Eaton |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9588
diff
changeset
|
5 Copyright (C) 2009 VZLU Prague, a.s. |
2376 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
2376 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
2376 | 22 |
23 */ | |
24 | |
25 #if !defined (octave_ops_h) | |
26 #define octave_ops_h 1 | |
27 | |
4669 | 28 #include "Array-util.h" |
29 | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
30 // Concatenation macros that enforce argument prescan |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
31 #define CONCAT2X(x,y) x ## y |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
32 #define CONCAT2(x,y) CONCAT2X(x,y) |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
33 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
34 #define CONCAT3X(x,y,z) x ## y ## z |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
35 #define CONCAT3(x,y,z) CONCAT3X(x,y,z) |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
36 |
2376 | 37 extern void install_ops (void); |
38 | |
3203 | 39 #define INSTALL_UNOP(op, t, f) \ |
40 octave_value_typeinfo::register_unary_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
41 (octave_value::op, t::static_type_id (), CONCAT2(oct_unop_, f)); |
3203 | 42 |
43 #define INSTALL_NCUNOP(op, t, f) \ | |
44 octave_value_typeinfo::register_non_const_unary_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
45 (octave_value::op, t::static_type_id (), CONCAT2(oct_unop_, f)); |
3203 | 46 |
2376 | 47 #define INSTALL_BINOP(op, t1, t2, f) \ |
48 octave_value_typeinfo::register_binary_op \ | |
3203 | 49 (octave_value::op, t1::static_type_id (), t2::static_type_id (), \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
50 CONCAT2(oct_binop_, f)); |
2376 | 51 |
4915 | 52 #define INSTALL_CATOP(t1, t2, f) \ |
53 octave_value_typeinfo::register_cat_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
54 (t1::static_type_id (), t2::static_type_id (), CONCAT2(oct_catop_, f)); |
4915 | 55 |
2879 | 56 #define INSTALL_ASSIGNOP(op, t1, t2, f) \ |
2376 | 57 octave_value_typeinfo::register_assign_op \ |
3203 | 58 (octave_value::op, t1::static_type_id (), t2::static_type_id (), \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
59 CONCAT2(oct_assignop_, f)); |
2376 | 60 |
3195 | 61 #define INSTALL_ASSIGNANYOP(op, t1, f) \ |
62 octave_value_typeinfo::register_assignany_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
63 (octave_value::op, t1::static_type_id (), CONCAT2(oct_assignop_, f)); |
3195 | 64 |
2376 | 65 #define INSTALL_ASSIGNCONV(t1, t2, tr) \ |
66 octave_value_typeinfo::register_pref_assign_conv \ | |
67 (t1::static_type_id (), t2::static_type_id (), tr::static_type_id ()); | |
68 | |
4901 | 69 #define INSTALL_CONVOP(t1, t2, f) \ |
70 octave_value_typeinfo::register_type_conv_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
71 (t1::static_type_id (), t2::static_type_id (), CONCAT2(oct_conv_, f)); |
4901 | 72 |
2376 | 73 #define INSTALL_WIDENOP(t1, t2, f) \ |
74 octave_value_typeinfo::register_widening_op \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
75 (t1::static_type_id (), t2::static_type_id (), CONCAT2(oct_conv_, f)); |
2376 | 76 |
3203 | 77 #define CAST_UNOP_ARG(t) \ |
5760 | 78 t v = dynamic_cast<t> (a) |
3203 | 79 |
2376 | 80 #define CAST_BINOP_ARGS(t1, t2) \ |
5760 | 81 t1 v1 = dynamic_cast<t1> (a1); \ |
82 t2 v2 = dynamic_cast<t2> (a2) | |
2376 | 83 |
84 #define CAST_CONV_ARG(t) \ | |
5760 | 85 t v = dynamic_cast<t> (a) |
2376 | 86 |
2914 | 87 #define ASSIGNOPDECL(name) \ |
88 static octave_value \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
89 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \ |
5759 | 90 const octave_value_list& idx, \ |
91 const octave_base_value& a2) | |
92 | |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
93 #define NULLASSIGNOPDECL(name) \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
94 static octave_value \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
95 CONCAT2(oct_assignop_, name) (octave_base_value& a, \ |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
96 const octave_value_list& idx, \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
97 const octave_base_value&) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
98 |
5759 | 99 #define ASSIGNANYOPDECL(name) \ |
100 static octave_value \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
101 CONCAT2(oct_assignop_, name) (octave_base_value& a1, \ |
3203 | 102 const octave_value_list& idx, \ |
103 const octave_value& a2) | |
2914 | 104 |
105 #define DEFASSIGNOP(name, t1, t2) \ | |
106 ASSIGNOPDECL (name) | |
107 | |
108 #define DEFASSIGNOP_FN(name, t1, t2, f) \ | |
109 ASSIGNOPDECL (name) \ | |
110 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
111 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
2914 | 112 \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
113 v1.f (idx, v2.CONCAT2(t1, _value) ()); \ |
2914 | 114 return octave_value (); \ |
115 } | |
116 | |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
117 #define DEFNULLASSIGNOP_FN(name, t, f) \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
118 NULLASSIGNOPDECL (name) \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
119 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
120 CAST_UNOP_ARG (CONCAT2(octave_, t)&); \ |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
121 \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
122 v.f (idx); \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
123 return octave_value (); \ |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
124 } |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7997
diff
changeset
|
125 |
4686 | 126 #define DEFNDASSIGNOP_FN(name, t1, t2, e, f) \ |
127 ASSIGNOPDECL (name) \ | |
128 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
129 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
4686 | 130 \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
131 v1.f (idx, v2.CONCAT2(e, _value) ()); \ |
4686 | 132 return octave_value (); \ |
133 } | |
134 | |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
135 // FIXME: the following currently don't handle index. |
9546
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
136 #define DEFNDASSIGNOP_OP(name, t1, t2, f, op) \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
137 ASSIGNOPDECL (name) \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
138 { \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
139 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
140 \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
141 assert (idx.empty ()); \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
142 v1.matrix_ref () op v2.CONCAT2(f, _value) (); \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
143 \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
144 return octave_value (); \ |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
145 } |
1beb23d2b892
optimize op= in common cases
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
146 |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
147 #define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop) \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
148 ASSIGNOPDECL (name) \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
149 { \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
150 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
151 \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
152 assert (idx.empty ()); \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
153 fnop (v1.matrix_ref (), v2.CONCAT2(f, _value) ()); \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
154 \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
155 return octave_value (); \ |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
156 } |
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
9546
diff
changeset
|
157 |
3195 | 158 #define DEFASSIGNANYOP_FN(name, t1, f) \ |
5759 | 159 ASSIGNANYOPDECL (name) \ |
3195 | 160 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
161 CONCAT2(octave_, t1)& v1 = dynamic_cast<CONCAT2(octave_, t1)&> (a1); \ |
3195 | 162 \ |
163 v1.f (idx, a2); \ | |
164 return octave_value (); \ | |
165 } | |
166 | |
2914 | 167 #define CONVDECL(name) \ |
5759 | 168 static octave_base_value * \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
169 CONCAT2(oct_conv_, name) (const octave_base_value& a) |
3203 | 170 |
171 #define CONVDECLX(name) \ | |
5759 | 172 static octave_base_value * \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
173 CONCAT2(oct_conv_, name) (const octave_base_value&) |
2914 | 174 |
4901 | 175 #define DEFCONV(name, a_dummy, b_dummy) \ |
2914 | 176 CONVDECL (name) |
177 | |
4901 | 178 #define DEFCONVFNX(name, tfrom, ovtto, tto, e) \ |
179 CONVDECL (name) \ | |
180 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
181 CAST_CONV_ARG (const CONCAT2(octave_, tfrom)&); \ |
4901 | 182 \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
183 return new CONCAT2(octave_, ovtto) (CONCAT2(tto, NDArray) (v.CONCAT2(e, array_value) ())); \ |
4901 | 184 } |
185 | |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
186 #define DEFCONVFNX2(name, tfrom, ovtto, e) \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
187 CONVDECL (name) \ |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
188 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
189 CAST_CONV_ARG (const CONCAT2(octave_, tfrom)&); \ |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
190 \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
191 return new CONCAT2(octave_, ovtto) (v.CONCAT2(e, array_value) ()); \ |
7997
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
192 } |
2b8952e133c9
implement checked conversions between integers
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
193 |
4901 | 194 #define DEFDBLCONVFN(name, ovtfrom, e) \ |
195 CONVDECL (name) \ | |
196 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
197 CAST_CONV_ARG (const CONCAT2(octave_, ovtfrom)&); \ |
4901 | 198 \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
199 return new octave_matrix (NDArray (v.CONCAT2(e, _value) ())); \ |
4901 | 200 } |
201 | |
8852 | 202 #define DEFFLTCONVFN(name, ovtfrom, e) \ |
203 CONVDECL (name) \ | |
204 { \ | |
205 CAST_CONV_ARG (const CONCAT2(octave_, ovtfrom)&); \ | |
206 \ | |
207 return new octave_float_matrix (FloatNDArray (v.CONCAT2(e, _value) ())); \ | |
208 } | |
209 | |
5032 | 210 #define DEFSTRINTCONVFN(name, tto) \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
211 DEFCONVFNX(name, char_matrix_str, CONCAT2(tto, _matrix), tto, char_) |
5032 | 212 |
5992 | 213 #define DEFSTRDBLCONVFN(name, tfrom) \ |
214 DEFCONVFNX(name, tfrom, matrix, , char_) | |
5032 | 215 |
8852 | 216 #define DEFSTRFLTCONVFN(name, tfrom) \ |
217 DEFCONVFNX(name, tfrom, float_matrix, Float, char_) | |
218 | |
4901 | 219 #define DEFCONVFN(name, tfrom, tto) \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
220 DEFCONVFNX2 (name, tfrom, CONCAT2(tto, _matrix), CONCAT2(tto, _)) |
4901 | 221 |
222 #define DEFCONVFN2(name, tfrom, sm, tto) \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
223 DEFCONVFNX2 (name, CONCAT3(tfrom, _, sm), CONCAT2(tto, _matrix), CONCAT2(tto, _)) |
4901 | 224 |
3203 | 225 #define UNOPDECL(name, a) \ |
226 static octave_value \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
227 CONCAT2(oct_unop_, name) (const octave_base_value& a) |
3203 | 228 |
229 #define DEFUNOPX(name, t) \ | |
230 UNOPDECL (name, , ) | |
231 | |
232 #define DEFUNOP(name, t) \ | |
233 UNOPDECL (name, a) | |
234 | |
235 #define DEFUNOP_OP(name, t, op) \ | |
236 UNOPDECL (name, a) \ | |
237 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
238 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
239 return octave_value (op v.CONCAT2(t, _value) ()); \ |
3203 | 240 } |
241 | |
4550 | 242 #define DEFNDUNOP_OP(name, t, e, op) \ |
4543 | 243 UNOPDECL (name, a) \ |
244 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
245 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
246 return octave_value (op v.CONCAT2(e, _value) ()); \ |
4543 | 247 } |
248 | |
5775 | 249 // FIXME -- in some cases, the constructor isn't necessary. |
3203 | 250 |
251 #define DEFUNOP_FN(name, t, f) \ | |
252 UNOPDECL (name, a) \ | |
253 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
254 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
255 return octave_value (f (v.CONCAT2(t, _value) ())); \ |
3203 | 256 } |
257 | |
4550 | 258 #define DEFNDUNOP_FN(name, t, e, f) \ |
4543 | 259 UNOPDECL (name, a) \ |
260 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
261 CAST_UNOP_ARG (const CONCAT2(octave_, t)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
262 return octave_value (f (v.CONCAT2(e, _value) ())); \ |
4543 | 263 } |
264 | |
3203 | 265 #define DEFNCUNOP_METHOD(name, t, method) \ |
266 static void \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
267 CONCAT2(oct_unop_, name) (octave_base_value& a) \ |
3203 | 268 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
269 CAST_UNOP_ARG (CONCAT2(octave_, t)&); \ |
3203 | 270 v.method (); \ |
271 } | |
272 | |
2914 | 273 #define BINOPDECL(name, a1, a2) \ |
274 static octave_value \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
275 CONCAT2(oct_binop_, name) (const octave_base_value& a1, const octave_base_value& a2) |
2914 | 276 |
277 #define DEFBINOPX(name, t1, t2) \ | |
278 BINOPDECL (name, , ) | |
279 | |
280 #define DEFBINOP(name, t1, t2) \ | |
281 BINOPDECL (name, a1, a2) | |
282 | |
283 #define DEFBINOP_OP(name, t1, t2, op) \ | |
284 BINOPDECL (name, a1, a2) \ | |
285 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
286 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
2914 | 287 return octave_value \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
288 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ |
2914 | 289 } |
290 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
291 #define DEFCMPLXCMPOP_OP(name, t1, t2, op) \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
292 BINOPDECL (name, a1, a2) \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
293 { \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
294 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
295 gripe_warn_complex_cmp (); \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
296 return octave_value \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
297 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
298 } |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
299 |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
300 #define DEFSCALARBOOLOP_OP(name, t1, t2, op) \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
301 BINOPDECL (name, a1, a2) \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
302 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
303 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
304 if (xisnan (v1.CONCAT2(t1, _value) ()) || xisnan (v2.CONCAT2(t2, _value) ())) \ |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
305 { \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
306 error ("invalid conversion from NaN to logical"); \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
307 return octave_value (); \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
308 } \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
309 else \ |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
310 return octave_value \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
311 (v1.CONCAT2(t1, _value) () op v2.CONCAT2(t2, _value) ()); \ |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
312 } |
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
313 |
4543 | 314 #define DEFNDBINOP_OP(name, t1, t2, e1, e2, op) \ |
315 BINOPDECL (name, a1, a2) \ | |
316 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
317 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
4543 | 318 return octave_value \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
319 (v1.CONCAT2(e1, _value) () op v2.CONCAT2(e2, _value) ()); \ |
4543 | 320 } |
321 | |
5775 | 322 // FIXME -- in some cases, the constructor isn't necessary. |
2914 | 323 |
324 #define DEFBINOP_FN(name, t1, t2, f) \ | |
325 BINOPDECL (name, a1, a2) \ | |
326 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
327 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
328 return octave_value (f (v1.CONCAT2(t1, _value) (), v2.CONCAT2(t2, _value) ())); \ |
2914 | 329 } |
330 | |
4543 | 331 #define DEFNDBINOP_FN(name, t1, t2, e1, e2, f) \ |
332 BINOPDECL (name, a1, a2) \ | |
333 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
334 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
335 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \ |
4543 | 336 } |
337 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
338 #define DEFNDCMPLXCMPOP_FN(name, t1, t2, e1, e2, f) \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
339 BINOPDECL (name, a1, a2) \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
340 { \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
341 CAST_BINOP_ARGS (const CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
342 return octave_value (f (v1.CONCAT2(e1, _value) (), v2.CONCAT2(e2, _value) ())); \ |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
343 } |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9587
diff
changeset
|
344 |
2914 | 345 #define BINOP_NONCONFORMANT(msg) \ |
346 gripe_nonconformant (msg, \ | |
347 a1.rows (), a1.columns (), \ | |
348 a2.rows (), a2.columns ()); \ | |
349 return octave_value () | |
350 | |
4915 | 351 #define CATOPDECL(name, a1, a2) \ |
352 static octave_value \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
353 CONCAT2(oct_catop_, name) (octave_base_value& a1, const octave_base_value& a2, \ |
6871 | 354 const Array<octave_idx_type>& ra_idx) |
4915 | 355 |
356 #define DEFCATOPX(name, t1, t2) \ | |
357 CATOPDECL (name, , ) | |
358 | |
359 #define DEFCATOP(name, t1, t2) \ | |
360 CATOPDECL (name, a1, a2) | |
361 | |
5775 | 362 // FIXME -- in some cases, the constructor isn't necessary. |
4915 | 363 |
364 #define DEFCATOP_FN(name, t1, t2, f) \ | |
5075 | 365 CATOPDECL (name, a1, a2) \ |
4915 | 366 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
367 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
368 return octave_value (v1.CONCAT2(t1, _value) () . f (v2.CONCAT2(t2, _value) (), ra_idx)); \ |
4915 | 369 } |
370 | |
5075 | 371 #define DEFNDCATOP_FN(name, t1, t2, e1, e2, f) \ |
372 CATOPDECL (name, a1, a2) \ | |
4915 | 373 { \ |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
374 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
375 return octave_value (v1.CONCAT2(e1, _value) () . f (v2.CONCAT2(e2, _value) (), ra_idx)); \ |
5533 | 376 } |
377 | |
378 #define DEFNDCHARCATOP_FN(name, t1, t2, f) \ | |
379 CATOPDECL (name, a1, a2) \ | |
380 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
381 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
5533 | 382 \ |
383 return octave_value (v1.char_array_value () . f (v2.char_array_value (), ra_idx), \ | |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9601
diff
changeset
|
384 ((a1.is_sq_string () || a2.is_sq_string ()) \ |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9601
diff
changeset
|
385 ? '\'' : '"')); \ |
4915 | 386 } |
387 | |
5075 | 388 // For compatibility, the second arg is always converted to the type |
389 // of the first. Hmm. | |
390 | |
391 #define DEFNDCATOP_FN2(name, t1, t2, tc1, tc2, e1, e2, f) \ | |
392 CATOPDECL (name, a1, a2) \ | |
393 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
394 CAST_BINOP_ARGS (CONCAT2(octave_, t1)&, const CONCAT2(octave_, t2)&); \ |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8150
diff
changeset
|
395 return octave_value (tc1 (v1.CONCAT2(e1, _value) ()) . f (tc2 (v2.CONCAT2(e2, _value) ()), ra_idx)); \ |
5075 | 396 } |
397 | |
4915 | 398 #define CATOP_NONCONFORMANT(msg) \ |
399 gripe_nonconformant (msg, \ | |
400 a1.rows (), a1.columns (), \ | |
401 a2.rows (), a2.columns ()); \ | |
402 return octave_value () | |
403 | |
2376 | 404 #endif |
405 | |
406 /* | |
407 ;;; Local Variables: *** | |
408 ;;; mode: C++ *** | |
409 ;;; End: *** | |
410 */ |