Mercurial > hg > octave-lyh
annotate liboctave/mx-op-defs.h @ 10362:b47ab50a6aa8
simplify appliers in mx-inlines.cc
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 26 Feb 2010 09:47:54 +0100 |
parents | 83fa590b8a09 |
children | e8811e5dd699 |
rev | line source |
---|---|
2829 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2008, 2009 Jaroslav Hajek |
7017 | 4 Copyright (C) 1996, 1997, 1998, 2000, 2001, 2003, 2004, 2005, 2006, |
5 2007 John W. Eaton | |
9601
a9b37bae1802
add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents:
9578
diff
changeset
|
6 Copyright (C) 2009 VZLU Prague, a.s. |
2829 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
7016 | 12 Free Software Foundation; either version 3 of the License, or (at your |
13 option) any later version. | |
2829 | 14 |
15 Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
2829 | 23 |
24 */ | |
25 | |
26 #if !defined (octave_mx_op_defs_h) | |
27 #define octave_mx_op_defs_h 1 | |
28 | |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8397
diff
changeset
|
29 #include "mx-op-decl.h" |
2829 | 30 #include "mx-inlines.cc" |
31 | |
2870 | 32 // vector by scalar operations. |
33 | |
34 #define VS_BIN_OP(R, F, OP, V, S) \ | |
35 R \ | |
36 F (const V& v, const S& s) \ | |
37 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
38 return do_ms_binary_op<R::element_type, V::element_type, S> (v, s, OP); \ |
2870 | 39 } |
40 | |
41 #define VS_BIN_OPS(R, V, S) \ | |
9660
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
42 VS_BIN_OP (R, operator +, mx_inline_add, V, S) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
43 VS_BIN_OP (R, operator -, mx_inline_sub, V, S) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
44 VS_BIN_OP (R, operator *, mx_inline_mul, V, S) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
45 VS_BIN_OP (R, operator /, mx_inline_div, V, S) |
2870 | 46 |
47 // scalar by vector by operations. | |
48 | |
49 #define SV_BIN_OP(R, F, OP, S, V) \ | |
50 R \ | |
51 F (const S& s, const V& v) \ | |
52 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
53 return do_sm_binary_op<R::element_type, S, V::element_type> (s, v, OP); \ |
2870 | 54 } |
55 | |
56 #define SV_BIN_OPS(R, S, V) \ | |
9660
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
57 SV_BIN_OP (R, operator +, mx_inline_add, S, V) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
58 SV_BIN_OP (R, operator -, mx_inline_sub, S, V) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
59 SV_BIN_OP (R, operator *, mx_inline_mul, S, V) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
60 SV_BIN_OP (R, operator /, mx_inline_div, S, V) |
2870 | 61 |
62 // vector by vector operations. | |
63 | |
64 #define VV_BIN_OP(R, F, OP, V1, V2) \ | |
65 R \ | |
66 F (const V1& v1, const V2& v2) \ | |
67 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
68 return do_mm_binary_op<R::element_type, V1::element_type, V2::element_type> (v1, v2, OP, #F); \ |
2870 | 69 } |
70 | |
71 #define VV_BIN_OPS(R, V1, V2) \ | |
9660
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
72 VV_BIN_OP (R, operator +, mx_inline_add, V1, V2) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
73 VV_BIN_OP (R, operator -, mx_inline_sub, V1, V2) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
74 VV_BIN_OP (R, product, mx_inline_mul, V1, V2) \ |
0256e187d13b
get rid of VS|SV|VV_BIN_OP macros in mx-op-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
9601
diff
changeset
|
75 VV_BIN_OP (R, quotient, mx_inline_div, V1, V2) |
2870 | 76 |
77 // matrix by scalar operations. | |
78 | |
79 #define MS_BIN_OP(R, OP, M, S, F) \ | |
2829 | 80 R \ |
81 OP (const M& m, const S& s) \ | |
82 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
83 return do_ms_binary_op<R::element_type, M::element_type, S> (m, s, F); \ |
2829 | 84 } |
85 | |
2870 | 86 #define MS_BIN_OPS(R, M, S) \ |
3769 | 87 MS_BIN_OP (R, operator +, M, S, mx_inline_add) \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
88 MS_BIN_OP (R, operator -, M, S, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
89 MS_BIN_OP (R, operator *, M, S, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
90 MS_BIN_OP (R, operator /, M, S, mx_inline_div) |
2870 | 91 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
92 #define MS_CMP_OP(F, OP, M, S) \ |
2870 | 93 boolMatrix \ |
94 F (const M& m, const S& s) \ | |
95 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
96 return do_ms_binary_op<bool, M::element_type, S> (m, s, OP); \ |
2870 | 97 } |
2829 | 98 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
99 #define MS_CMP_OPS(M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
100 MS_CMP_OP (mx_el_lt, mx_inline_lt, M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
101 MS_CMP_OP (mx_el_le, mx_inline_le, M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
102 MS_CMP_OP (mx_el_ge, mx_inline_ge, M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
103 MS_CMP_OP (mx_el_gt, mx_inline_gt, M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
104 MS_CMP_OP (mx_el_eq, mx_inline_eq, M, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
105 MS_CMP_OP (mx_el_ne, mx_inline_ne, M, S) |
2870 | 106 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
107 #define MS_BOOL_OP(F, OP, M, S) \ |
2870 | 108 boolMatrix \ |
109 F (const M& m, const S& s) \ | |
110 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
111 return do_ms_binary_op<bool, M::element_type, S> (m, s, OP); \ |
2870 | 112 } |
113 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
114 #define MS_BOOL_OPS(M, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
115 MS_BOOL_OP (mx_el_and, mx_inline_and, M, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
116 MS_BOOL_OP (mx_el_or, mx_inline_or, M, S) |
2870 | 117 |
118 // scalar by matrix operations. | |
119 | |
120 #define SM_BIN_OP(R, OP, S, M, F) \ | |
2829 | 121 R \ |
122 OP (const S& s, const M& m) \ | |
123 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
124 return do_sm_binary_op<R::element_type, S, M::element_type> (s, m, F); \ |
2829 | 125 } |
126 | |
2870 | 127 #define SM_BIN_OPS(R, S, M) \ |
3769 | 128 SM_BIN_OP (R, operator +, S, M, mx_inline_add) \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
129 SM_BIN_OP (R, operator -, S, M, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
130 SM_BIN_OP (R, operator *, S, M, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
131 SM_BIN_OP (R, operator /, S, M, mx_inline_div) |
2870 | 132 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
133 #define SM_CMP_OP(F, OP, S, M) \ |
2870 | 134 boolMatrix \ |
135 F (const S& s, const M& m) \ | |
136 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
137 return do_sm_binary_op<bool, S, M::element_type> (s, m, OP); \ |
2870 | 138 } |
2829 | 139 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
140 #define SM_CMP_OPS(S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
141 SM_CMP_OP (mx_el_lt, mx_inline_lt, S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
142 SM_CMP_OP (mx_el_le, mx_inline_le, S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
143 SM_CMP_OP (mx_el_ge, mx_inline_ge, S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
144 SM_CMP_OP (mx_el_gt, mx_inline_gt, S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
145 SM_CMP_OP (mx_el_eq, mx_inline_eq, S, M) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
146 SM_CMP_OP (mx_el_ne, mx_inline_ne, S, M) |
2870 | 147 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
148 #define SM_BOOL_OP(F, OP, S, M) \ |
2870 | 149 boolMatrix \ |
150 F (const S& s, const M& m) \ | |
151 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
152 return do_sm_binary_op<bool, S, M::element_type> (s, m, OP); \ |
2870 | 153 } |
154 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
155 #define SM_BOOL_OPS(S, M) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
156 SM_BOOL_OP (mx_el_and, mx_inline_and, S, M) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
157 SM_BOOL_OP (mx_el_or, mx_inline_or, S, M) |
2870 | 158 |
159 // matrix by matrix operations. | |
160 | |
161 #define MM_BIN_OP(R, OP, M1, M2, F) \ | |
2829 | 162 R \ |
163 OP (const M1& m1, const M2& m2) \ | |
164 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
165 return do_mm_binary_op<R::element_type, M1::element_type, M2::element_type> (m1, m2, F, #OP); \ |
2829 | 166 } |
167 | |
2870 | 168 #define MM_BIN_OPS(R, M1, M2) \ |
3769 | 169 MM_BIN_OP (R, operator +, M1, M2, mx_inline_add) \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
170 MM_BIN_OP (R, operator -, M1, M2, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
171 MM_BIN_OP (R, product, M1, M2, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
172 MM_BIN_OP (R, quotient, M1, M2, mx_inline_div) |
2870 | 173 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
174 #define MM_CMP_OP(F, OP, M1, M2) \ |
2870 | 175 boolMatrix \ |
176 F (const M1& m1, const M2& m2) \ | |
177 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
178 return do_mm_binary_op<bool, M1::element_type, M2::element_type> (m1, m2, OP, #F); \ |
2870 | 179 } |
2829 | 180 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
181 #define MM_CMP_OPS(M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
182 MM_CMP_OP (mx_el_lt, mx_inline_lt, M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
183 MM_CMP_OP (mx_el_le, mx_inline_le, M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
184 MM_CMP_OP (mx_el_ge, mx_inline_ge, M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
185 MM_CMP_OP (mx_el_gt, mx_inline_gt, M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
186 MM_CMP_OP (mx_el_eq, mx_inline_eq, M1, M2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
187 MM_CMP_OP (mx_el_ne, mx_inline_ne, M1, M2) |
2870 | 188 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
189 #define MM_BOOL_OP(F, OP, M1, M2) \ |
2870 | 190 boolMatrix \ |
191 F (const M1& m1, const M2& m2) \ | |
192 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
193 return do_mm_binary_op<bool, M1::element_type, M2::element_type> (m1, m2, OP, #F); \ |
2870 | 194 } |
195 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
196 #define MM_BOOL_OPS(M1, M2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
197 MM_BOOL_OP (mx_el_and, mx_inline_and, M1, M2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
198 MM_BOOL_OP (mx_el_or, mx_inline_or, M1, M2) |
2870 | 199 |
4543 | 200 // N-d matrix by scalar operations. |
201 | |
202 #define NDS_BIN_OP(R, OP, ND, S, F) \ | |
203 R \ | |
204 OP (const ND& m, const S& s) \ | |
205 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
206 return do_ms_binary_op<R::element_type, ND::element_type, S> (m, s, F); \ |
4543 | 207 } |
208 | |
209 #define NDS_BIN_OPS(R, ND, S) \ | |
210 NDS_BIN_OP (R, operator +, ND, S, mx_inline_add) \ | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
211 NDS_BIN_OP (R, operator -, ND, S, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
212 NDS_BIN_OP (R, operator *, ND, S, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
213 NDS_BIN_OP (R, operator /, ND, S, mx_inline_div) |
4543 | 214 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
215 #define NDS_CMP_OP(F, OP, ND, S) \ |
6119 | 216 boolNDArray \ |
217 F (const ND& m, const S& s) \ | |
218 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
219 return do_ms_binary_op<bool, ND::element_type, S> (m, s, OP); \ |
6119 | 220 } |
221 | |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
222 #define NDS_CMP_OPS(ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
223 NDS_CMP_OP (mx_el_lt, mx_inline_lt, ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
224 NDS_CMP_OP (mx_el_le, mx_inline_le, ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
225 NDS_CMP_OP (mx_el_ge, mx_inline_ge, ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
226 NDS_CMP_OP (mx_el_gt, mx_inline_gt, ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
227 NDS_CMP_OP (mx_el_eq, mx_inline_eq, ND, S) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
228 NDS_CMP_OP (mx_el_ne, mx_inline_ne, ND, S) |
6119 | 229 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
230 #define NDS_BOOL_OP(F, OP, ND, S) \ |
4543 | 231 boolNDArray \ |
232 F (const ND& m, const S& s) \ | |
233 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
234 return do_ms_binary_op<bool, ND::element_type, S> (m, s, OP); \ |
4543 | 235 } |
236 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
237 #define NDS_BOOL_OPS(ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
238 NDS_BOOL_OP (mx_el_and, mx_inline_and, ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
239 NDS_BOOL_OP (mx_el_or, mx_inline_or, ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
240 NDS_BOOL_OP (mx_el_not_and, mx_inline_not_and, ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
241 NDS_BOOL_OP (mx_el_not_or, mx_inline_not_or, ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
242 NDS_BOOL_OP (mx_el_and_not, mx_inline_and_not, ND, S) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
243 NDS_BOOL_OP (mx_el_or_not, mx_inline_or_not, ND, S) |
4543 | 244 |
245 // scalar by N-d matrix operations. | |
246 | |
247 #define SND_BIN_OP(R, OP, S, ND, F) \ | |
248 R \ | |
249 OP (const S& s, const ND& m) \ | |
250 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
251 return do_sm_binary_op<R::element_type, S, ND::element_type> (s, m, F); \ |
4543 | 252 } |
253 | |
254 #define SND_BIN_OPS(R, S, ND) \ | |
255 SND_BIN_OP (R, operator +, S, ND, mx_inline_add) \ | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
256 SND_BIN_OP (R, operator -, S, ND, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
257 SND_BIN_OP (R, operator *, S, ND, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
258 SND_BIN_OP (R, operator /, S, ND, mx_inline_div) |
4543 | 259 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
260 #define SND_CMP_OP(F, OP, S, ND) \ |
6119 | 261 boolNDArray \ |
262 F (const S& s, const ND& m) \ | |
263 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
264 return do_sm_binary_op<bool, S, ND::element_type> (s, m, OP); \ |
6119 | 265 } |
266 | |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
267 #define SND_CMP_OPS(S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
268 SND_CMP_OP (mx_el_lt, mx_inline_lt, S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
269 SND_CMP_OP (mx_el_le, mx_inline_le, S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
270 SND_CMP_OP (mx_el_ge, mx_inline_ge, S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
271 SND_CMP_OP (mx_el_gt, mx_inline_gt, S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
272 SND_CMP_OP (mx_el_eq, mx_inline_eq, S, ND) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
273 SND_CMP_OP (mx_el_ne, mx_inline_ne, S, ND) |
6119 | 274 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
275 #define SND_BOOL_OP(F, OP, S, ND) \ |
4543 | 276 boolNDArray \ |
277 F (const S& s, const ND& m) \ | |
278 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
279 return do_sm_binary_op<bool, S, ND::element_type> (s, m, OP); \ |
4543 | 280 } |
281 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
282 #define SND_BOOL_OPS(S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
283 SND_BOOL_OP (mx_el_and, mx_inline_and, S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
284 SND_BOOL_OP (mx_el_or, mx_inline_or, S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
285 SND_BOOL_OP (mx_el_not_and, mx_inline_not_and, S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
286 SND_BOOL_OP (mx_el_not_or, mx_inline_not_or, S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
287 SND_BOOL_OP (mx_el_and_not, mx_inline_and_not, S, ND) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
288 SND_BOOL_OP (mx_el_or_not, mx_inline_or_not, S, ND) |
4543 | 289 |
290 // N-d matrix by N-d matrix operations. | |
291 | |
292 #define NDND_BIN_OP(R, OP, ND1, ND2, F) \ | |
293 R \ | |
294 OP (const ND1& m1, const ND2& m2) \ | |
295 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
296 return do_mm_binary_op<R::element_type, ND1::element_type, ND2::element_type> (m1, m2, F, #OP); \ |
4543 | 297 } |
298 | |
299 #define NDND_BIN_OPS(R, ND1, ND2) \ | |
300 NDND_BIN_OP (R, operator +, ND1, ND2, mx_inline_add) \ | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
301 NDND_BIN_OP (R, operator -, ND1, ND2, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
302 NDND_BIN_OP (R, product, ND1, ND2, mx_inline_mul) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
303 NDND_BIN_OP (R, quotient, ND1, ND2, mx_inline_div) |
4543 | 304 |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
305 #define NDND_CMP_OP(F, OP, ND1, ND2) \ |
4543 | 306 boolNDArray \ |
307 F (const ND1& m1, const ND2& m2) \ | |
308 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
309 return do_mm_binary_op<bool, ND1::element_type, ND2::element_type> (m1, m2, OP, #F); \ |
4543 | 310 } |
311 | |
9578
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
312 #define NDND_CMP_OPS(ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
313 NDND_CMP_OP (mx_el_lt, mx_inline_lt, ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
314 NDND_CMP_OP (mx_el_le, mx_inline_le, ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
315 NDND_CMP_OP (mx_el_ge, mx_inline_ge, ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
316 NDND_CMP_OP (mx_el_gt, mx_inline_gt, ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
317 NDND_CMP_OP (mx_el_eq, mx_inline_eq, ND1, ND2) \ |
7dafdb8b062f
refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents:
9553
diff
changeset
|
318 NDND_CMP_OP (mx_el_ne, mx_inline_ne, ND1, ND2) |
4543 | 319 |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
320 #define NDND_BOOL_OP(F, OP, ND1, ND2) \ |
4543 | 321 boolNDArray \ |
322 F (const ND1& m1, const ND2& m2) \ | |
323 { \ | |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
324 return do_mm_binary_op<bool, ND1::element_type, ND2::element_type> (m1, m2, OP, #F); \ |
4543 | 325 } |
326 | |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
327 #define NDND_BOOL_OPS(ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
328 NDND_BOOL_OP (mx_el_and, mx_inline_and, ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
329 NDND_BOOL_OP (mx_el_or, mx_inline_or, ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
330 NDND_BOOL_OP (mx_el_not_and, mx_inline_not_and, ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
331 NDND_BOOL_OP (mx_el_not_or, mx_inline_not_or, ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
332 NDND_BOOL_OP (mx_el_and_not, mx_inline_and_not, ND1, ND2) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
333 NDND_BOOL_OP (mx_el_or_not, mx_inline_or_not, ND1, ND2) |
4543 | 334 |
2870 | 335 // scalar by diagonal matrix operations. |
336 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
337 #define SDM_BIN_OP(R, OP, S, DM) \ |
2829 | 338 R \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
339 operator OP (const S& s, const DM& dm) \ |
2829 | 340 { \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
341 R r (dm.rows (), dm.cols ()); \ |
2829 | 342 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
343 for (octave_idx_type i = 0; i < dm.length (); i++) \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
344 r.dgxelem (i) = s OP dm.dgelem (i); \ |
2829 | 345 \ |
346 return r; \ | |
347 } | |
348 | |
2870 | 349 #define SDM_BIN_OPS(R, S, DM) \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
350 SDM_BIN_OP (R, *, S, DM) |
2870 | 351 |
352 // diagonal matrix by scalar operations. | |
353 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
354 #define DMS_BIN_OP(R, OP, DM, S) \ |
2829 | 355 R \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
356 operator OP (const DM& dm, const S& s) \ |
2829 | 357 { \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
358 R r (dm.rows (), dm.cols ()); \ |
2829 | 359 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
360 for (octave_idx_type i = 0; i < dm.length (); i++) \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
361 r.dgxelem (i) = dm.dgelem (i) OP s; \ |
2829 | 362 \ |
363 return r; \ | |
364 } | |
365 | |
2870 | 366 #define DMS_BIN_OPS(R, DM, S) \ |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
367 DMS_BIN_OP (R, *, DM, S) \ |
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9660
diff
changeset
|
368 DMS_BIN_OP (R, /, DM, S) |
2870 | 369 |
370 // matrix by diagonal matrix operations. | |
371 | |
372 #define MDM_BIN_OP(R, OP, M, DM, OPEQ) \ | |
2829 | 373 R \ |
374 OP (const M& m, const DM& dm) \ | |
375 { \ | |
376 R r; \ | |
377 \ | |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
378 octave_idx_type m_nr = m.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
379 octave_idx_type m_nc = m.cols (); \ |
2829 | 380 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
381 octave_idx_type dm_nr = dm.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
382 octave_idx_type dm_nc = dm.cols (); \ |
2829 | 383 \ |
384 if (m_nr != dm_nr || m_nc != dm_nc) \ | |
385 gripe_nonconformant (#OP, m_nr, m_nc, dm_nr, dm_nc); \ | |
386 else \ | |
387 { \ | |
388 r.resize (m_nr, m_nc); \ | |
389 \ | |
390 if (m_nr > 0 && m_nc > 0) \ | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
391 { \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
392 r = R (m); \ |
2829 | 393 \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
394 octave_idx_type len = dm.length (); \ |
2829 | 395 \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
396 for (octave_idx_type i = 0; i < len; i++) \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
397 r.elem(i, i) OPEQ dm.elem(i, i); \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
398 } \ |
2829 | 399 } \ |
400 \ | |
401 return r; \ | |
402 } | |
403 | |
5030 | 404 #define MDM_MULTIPLY_OP(R, M, DM, R_ZERO) \ |
2829 | 405 R \ |
406 operator * (const M& m, const DM& dm) \ | |
407 { \ | |
408 R r; \ | |
409 \ | |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
410 octave_idx_type m_nr = m.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
411 octave_idx_type m_nc = m.cols (); \ |
2829 | 412 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
413 octave_idx_type dm_nr = dm.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
414 octave_idx_type dm_nc = dm.cols (); \ |
2829 | 415 \ |
416 if (m_nc != dm_nr) \ | |
417 gripe_nonconformant ("operator *", m_nr, m_nc, dm_nr, dm_nc); \ | |
418 else \ | |
419 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
420 r = R (m_nr, dm_nc); \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
421 R::element_type *rd = r.fortran_vec (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
422 const M::element_type *md = m.data (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
423 const DM::element_type *dd = dm.data (); \ |
4543 | 424 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
425 octave_idx_type len = dm.length (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
426 for (octave_idx_type i = 0; i < len; i++) \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
427 { \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
428 mx_inline_mul (m_nr, rd, md, dd[i]); \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
429 rd += m_nr; md += m_nr; \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
430 } \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
431 mx_inline_fill (m_nr * (dm_nc - len), rd, R_ZERO); \ |
2829 | 432 } \ |
433 \ | |
434 return r; \ | |
435 } | |
436 | |
5030 | 437 #define MDM_BIN_OPS(R, M, DM, R_ZERO) \ |
2870 | 438 MDM_BIN_OP (R, operator +, M, DM, +=) \ |
439 MDM_BIN_OP (R, operator -, M, DM, -=) \ | |
5030 | 440 MDM_MULTIPLY_OP (R, M, DM, R_ZERO) |
2829 | 441 |
2870 | 442 // diagonal matrix by matrix operations. |
443 | |
3585 | 444 #define DMM_BIN_OP(R, OP, DM, M, OPEQ, PREOP) \ |
2829 | 445 R \ |
446 OP (const DM& dm, const M& m) \ | |
447 { \ | |
448 R r; \ | |
449 \ | |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
450 octave_idx_type dm_nr = dm.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
451 octave_idx_type dm_nc = dm.cols (); \ |
2829 | 452 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
453 octave_idx_type m_nr = m.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
454 octave_idx_type m_nc = m.cols (); \ |
2829 | 455 \ |
456 if (dm_nr != m_nr || dm_nc != m_nc) \ | |
457 gripe_nonconformant (#OP, dm_nr, dm_nc, m_nr, m_nc); \ | |
458 else \ | |
459 { \ | |
460 if (m_nr > 0 && m_nc > 0) \ | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
461 { \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
462 r = R (PREOP m); \ |
2829 | 463 \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
464 octave_idx_type len = dm.length (); \ |
2829 | 465 \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
466 for (octave_idx_type i = 0; i < len; i++) \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
467 r.elem(i, i) OPEQ dm.elem(i, i); \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
468 } \ |
2829 | 469 else \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
470 r.resize (m_nr, m_nc); \ |
2829 | 471 } \ |
472 \ | |
473 return r; \ | |
474 } | |
475 | |
5030 | 476 #define DMM_MULTIPLY_OP(R, DM, M, R_ZERO) \ |
2829 | 477 R \ |
478 operator * (const DM& dm, const M& m) \ | |
479 { \ | |
480 R r; \ | |
481 \ | |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
482 octave_idx_type dm_nr = dm.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
483 octave_idx_type dm_nc = dm.cols (); \ |
2829 | 484 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
485 octave_idx_type m_nr = m.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
486 octave_idx_type m_nc = m.cols (); \ |
2829 | 487 \ |
488 if (dm_nc != m_nr) \ | |
489 gripe_nonconformant ("operator *", dm_nr, dm_nc, m_nr, m_nc); \ | |
490 else \ | |
491 { \ | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
492 r = R (dm_nr, m_nc); \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
493 R::element_type *rd = r.fortran_vec (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
494 const M::element_type *md = m.data (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
495 const DM::element_type *dd = dm.data (); \ |
4543 | 496 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
497 octave_idx_type len = dm.length (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
498 for (octave_idx_type i = 0; i < m_nc; i++) \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
499 { \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
500 mx_inline_mul (len, rd, md, dd); \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
501 rd += len; md += m_nr; \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
502 mx_inline_fill (dm_nr - len, rd, R_ZERO); \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
503 rd += dm_nr - len; \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
504 } \ |
2829 | 505 } \ |
506 \ | |
507 return r; \ | |
508 } | |
509 | |
5030 | 510 #define DMM_BIN_OPS(R, DM, M, R_ZERO) \ |
3585 | 511 DMM_BIN_OP (R, operator +, DM, M, +=, ) \ |
512 DMM_BIN_OP (R, operator -, DM, M, +=, -) \ | |
5030 | 513 DMM_MULTIPLY_OP (R, DM, M, R_ZERO) |
2829 | 514 |
2870 | 515 // diagonal matrix by diagonal matrix operations. |
2829 | 516 |
2870 | 517 #define DMDM_BIN_OP(R, OP, DM1, DM2, F) \ |
2829 | 518 R \ |
519 OP (const DM1& dm1, const DM2& dm2) \ | |
520 { \ | |
521 R r; \ | |
522 \ | |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
523 octave_idx_type dm1_nr = dm1.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
524 octave_idx_type dm1_nc = dm1.cols (); \ |
2829 | 525 \ |
8380
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
526 octave_idx_type dm2_nr = dm2.rows (); \ |
dbe67764e628
fix & improve speed of diagonal matrix multiplication
Jaroslav Hajek <highegg@gmail.com>
parents:
8375
diff
changeset
|
527 octave_idx_type dm2_nc = dm2.cols (); \ |
2829 | 528 \ |
529 if (dm1_nr != dm2_nr || dm1_nc != dm2_nc) \ | |
530 gripe_nonconformant (#OP, dm1_nr, dm1_nc, dm2_nr, dm2_nc); \ | |
531 else \ | |
532 { \ | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
533 r.resize (dm1_nr, dm1_nc); \ |
2829 | 534 \ |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
535 if (dm1_nr > 0 && dm1_nc > 0) \ |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
536 F (dm1.length (), r.fortran_vec (), dm1.data (), dm2.data ()); \ |
2829 | 537 } \ |
538 \ | |
539 return r; \ | |
540 } | |
541 | |
2870 | 542 #define DMDM_BIN_OPS(R, DM1, DM2) \ |
3769 | 543 DMDM_BIN_OP (R, operator +, DM1, DM2, mx_inline_add) \ |
9550
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
544 DMDM_BIN_OP (R, operator -, DM1, DM2, mx_inline_sub) \ |
3d6a9aea2aea
refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8998
diff
changeset
|
545 DMDM_BIN_OP (R, product, DM1, DM2, mx_inline_mul) |
2870 | 546 |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8397
diff
changeset
|
547 // scalar by N-d array min/max ops |
3582 | 548 |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
549 #define SND_MINMAX_FCN(FCN, OP, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
550 T \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
551 FCN (S d, const T& m) \ |
7189 | 552 { \ |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
553 return do_sm_binary_op<T::element_type, S, T::element_type> (d, m, mx_inline_x##FCN); \ |
7189 | 554 } |
555 | |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
556 #define NDS_MINMAX_FCN(FCN, OP, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
557 T \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
558 FCN (const T& m, S d) \ |
7189 | 559 { \ |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
560 return do_ms_binary_op<T::element_type, T::element_type, S> (m, d, mx_inline_x##FCN); \ |
7189 | 561 } |
562 | |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
563 #define NDND_MINMAX_FCN(FCN, OP, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
564 T \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
565 FCN (const T& a, const T& b) \ |
7189 | 566 { \ |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10329
diff
changeset
|
567 return do_mm_binary_op<T::element_type, T::element_type, T::element_type> (a, b, mx_inline_x##FCN, #FCN); \ |
7189 | 568 } |
569 | |
10329
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
570 #define MINMAX_FCNS(T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
571 SND_MINMAX_FCN (min, <, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
572 NDS_MINMAX_FCN (min, <, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
573 NDND_MINMAX_FCN (min, <, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
574 SND_MINMAX_FCN (max, >, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
575 NDS_MINMAX_FCN (max, >, T, S) \ |
83fa590b8a09
simplify min/max definitions in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10312
diff
changeset
|
576 NDND_MINMAX_FCN (max, >, T, S) |
7189 | 577 |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8397
diff
changeset
|
578 // permutation matrix by matrix ops and vice versa |
7189 | 579 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
580 #define PMM_MULTIPLY_OP(PM, M) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
581 M operator * (const PM& p, const M& x) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
582 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
583 octave_idx_type nr = x.rows (), nc = x.columns (); \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
584 M result; \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
585 if (p.columns () != nr) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
586 gripe_nonconformant ("operator *", p.rows (), p.columns (), nr, nc); \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
587 else \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
588 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
589 if (p.is_col_perm ()) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
590 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
591 result = M (nr, nc); \ |
8375
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
592 result.assign (p.pvec (), idx_vector::colon, x); \ |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
593 } \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
594 else \ |
8375
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
595 result = x.index (p.pvec (), idx_vector::colon); \ |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
596 } \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
597 \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
598 return result; \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
599 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
600 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
601 #define MPM_MULTIPLY_OP(M, PM) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
602 M operator * (const M& x, const PM& p) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
603 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
604 octave_idx_type nr = x.rows (), nc = x.columns (); \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
605 M result; \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
606 if (p.rows () != nc) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
607 gripe_nonconformant ("operator *", nr, nc, p.rows (), p.columns ()); \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
608 else \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
609 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
610 if (p.is_col_perm ()) \ |
8375
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
611 result = x.index (idx_vector::colon, p.pvec ()); \ |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
612 else \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
613 { \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
614 result = M (nr, nc); \ |
8375
e3c9102431a9
fix design problems of diag & perm matrix classes
Jaroslav Hajek <highegg@gmail.com>
parents:
8367
diff
changeset
|
615 result.assign (idx_vector::colon, p.pvec (), x); \ |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
616 } \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
617 } \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
618 \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
619 return result; \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
620 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
621 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
622 #define PMM_BIN_OPS(R, PM, M) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
623 PMM_MULTIPLY_OP(PM, M); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
624 |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
625 #define MPM_BIN_OPS(R, M, PM) \ |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
626 MPM_MULTIPLY_OP(M, PM); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
627 |
8998
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
628 #define NDND_MAPPER_BODY(R, NAME) \ |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
629 R retval (dims ()); \ |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
630 octave_idx_type n = numel (); \ |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
631 for (octave_idx_type i = 0; i < n; i++) \ |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
632 retval.xelem (i) = NAME (elem (i)); \ |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
633 return retval; |
a48fba01e4ac
optimize isnan/isinf/isfinite mappers
Jaroslav Hajek <highegg@gmail.com>
parents:
8983
diff
changeset
|
634 |
8774
b756ce0002db
split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents:
8397
diff
changeset
|
635 #endif |