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