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