Mercurial > octave
annotate libinterp/parse-tree/pt-cbinop.cc @ 27374:d171d356767b
don't apply std::move to temporary values
Files affected: pt-binop.cc, pt-cbinop.cc, pt-colon.cc, pt-eval.cc,
pt-idx.cc, and pt-unop.cc.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 04 Sep 2019 15:34:51 -0400 |
parents | fcaecdbc8d8a |
children | b442ec6dda5c |
rev | line source |
---|---|
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
1 /* |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
2 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
25832
diff
changeset
|
3 Copyright (C) 2008-2019 Jaroslav Hajek |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
4 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23656
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23656
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
10 (at your option) any later version. |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
15 GNU General Public License for more details. |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23656
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
20 |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
21 */ |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21662
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
24 # include "config.h" |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 #endif |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
27 #include "interpreter.h" |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 #include "ov.h" |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 #include "pt-cbinop.h" |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
30 #include "pt-eval.h" |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 #include "pt-unop.h" |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
33 namespace octave |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
34 { |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
35 octave_value |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
36 tree_compound_binary_expression::evaluate (tree_evaluator& tw, int) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
37 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
38 octave_value val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
39 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
40 if (m_lhs) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
41 { |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
42 octave_value a = m_lhs->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
43 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
44 if (a.is_defined () && m_rhs) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
45 { |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
46 octave_value b = m_rhs->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
47 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
48 if (b.is_defined ()) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
49 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
50 interpreter& interp = tw.get_interpreter (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
51 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
52 type_info& ti = interp.get_type_info (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
53 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
54 val = ::do_binary_op (ti, m_etype, a, b); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
55 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
56 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
57 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
58 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
59 return val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
60 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
27277
diff
changeset
|
61 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
62 typedef tree_expression* tree_expression_ptr_t; |
19656
bf88eab464b8
Detect binary operations with a transposed matrix and forward to BLAS (bug #42716).
David Bateman <dbateman@free.fr>
parents:
18100
diff
changeset
|
63 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
64 // If a tree expression is a transpose or hermitian transpose, return |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
65 // the argument and corresponding operator. |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
66 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
67 static octave_value::unary_op |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
68 strip_trans_herm (tree_expression_ptr_t& exp) |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
69 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
70 if (exp->is_unary_expression ()) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
71 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
72 tree_unary_expression *uexp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
73 = dynamic_cast<tree_unary_expression *> (exp); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
74 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
75 octave_value::unary_op op = uexp->op_type (); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
76 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
77 if (op == octave_value::op_transpose |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
78 || op == octave_value::op_hermitian) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
79 exp = uexp->operand (); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
80 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
81 op = octave_value::unknown_unary_op; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
83 return op; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
84 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
85 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
86 return octave_value::unknown_unary_op; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
87 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 |
25831
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
89 #if 0 |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
90 // Restore this code if short-circuit behavior can be preserved when needed. |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
91 // See bug #54465. |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
92 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 static octave_value::unary_op |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
94 strip_not (tree_expression_ptr_t& exp) |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
95 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
96 if (exp->is_unary_expression ()) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
97 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
98 tree_unary_expression *uexp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
99 = dynamic_cast<tree_unary_expression *> (exp); |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
100 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
101 octave_value::unary_op op = uexp->op_type (); |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
102 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 if (op == octave_value::op_not) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
104 exp = uexp->operand (); |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 op = octave_value::unknown_unary_op; |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
107 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
108 return op; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
111 return octave_value::unknown_unary_op; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
112 } |
25831
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
113 #endif |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
114 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 // Possibly convert multiplication to trans_mul, mul_trans, herm_mul, |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 // or mul_herm. |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
117 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
118 static octave_value::compound_binary_op |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
119 simplify_mul_op (tree_expression_ptr_t& a, tree_expression_ptr_t& b) |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
121 octave_value::compound_binary_op retop |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 = octave_value::unknown_compound_binary_op; |
13222
82f3a0c27569
fix warnings for uninitialized variables
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
123 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 octave_value::unary_op opa = strip_trans_herm (a); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
125 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 if (opa == octave_value::op_hermitian) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
127 retop = octave_value::op_herm_mul; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
128 else if (opa == octave_value::op_transpose) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
129 retop = octave_value::op_trans_mul; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
130 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
131 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 octave_value::unary_op opb = strip_trans_herm (b); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
133 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 if (opb == octave_value::op_hermitian) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
135 retop = octave_value::op_mul_herm; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 else if (opb == octave_value::op_transpose) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
137 retop = octave_value::op_mul_trans; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
139 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 return retop; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
142 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 // Possibly convert left division to trans_ldiv or herm_ldiv. |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
144 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 static octave_value::compound_binary_op |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
146 simplify_ldiv_op (tree_expression_ptr_t& a, tree_expression_ptr_t&) |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 octave_value::compound_binary_op retop |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
149 = octave_value::unknown_compound_binary_op; |
13222
82f3a0c27569
fix warnings for uninitialized variables
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
150 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 octave_value::unary_op opa = strip_trans_herm (a); |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
152 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 if (opa == octave_value::op_hermitian) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 retop = octave_value::op_herm_ldiv; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 else if (opa == octave_value::op_transpose) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 retop = octave_value::op_trans_ldiv; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
157 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 return retop; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 } |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
160 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 // Possibly contract and/or with negation. |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
162 |
25831
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
163 #if 0 |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
164 // Restore this code if short-circuit behavior can be preserved when needed. |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
165 // See bug #54465. |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 static octave_value::compound_binary_op |
25336
389757b7b6af
eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
167 simplify_and_or_op (tree_expression_ptr_t& a, tree_expression_ptr_t& b, |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 octave_value::binary_op op) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
169 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 octave_value::compound_binary_op retop |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
171 = octave_value::unknown_compound_binary_op; |
13222
82f3a0c27569
fix warnings for uninitialized variables
John W. Eaton <jwe@octave.org>
parents:
11586
diff
changeset
|
172 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
173 octave_value::unary_op opa = strip_not (a); |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
174 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
175 if (opa == octave_value::op_not) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
177 if (op == octave_value::op_el_and) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
178 retop = octave_value::op_el_not_and; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 else if (op == octave_value::op_el_or) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
180 retop = octave_value::op_el_not_or; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
181 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
182 else |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
183 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
184 octave_value::unary_op opb = strip_not (b); |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
185 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
186 if (opb == octave_value::op_not) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
187 { |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
188 if (op == octave_value::op_el_and) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
189 retop = octave_value::op_el_and_not; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
190 else if (op == octave_value::op_el_or) |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 retop = octave_value::op_el_or_not; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
192 } |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
193 } |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
194 |
24722
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
195 return retop; |
af6c1ed60581
avoid splitting namespace blocks unnecessarily
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
196 } |
25831
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
197 #endif |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
198 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
199 tree_binary_expression * |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
200 maybe_compound_binary_expression (tree_expression *a, tree_expression *b, |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
201 int l, int c, octave_value::binary_op t) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
202 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
203 tree_expression *ca = a; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
204 tree_expression *cb = b; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
205 octave_value::compound_binary_op ct; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
206 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
207 switch (t) |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
208 { |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
209 case octave_value::op_mul: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
210 ct = simplify_mul_op (ca, cb); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
211 break; |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
212 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
213 case octave_value::op_ldiv: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
214 ct = simplify_ldiv_op (ca, cb); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
215 break; |
9661
afcf852256d2
optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
216 |
25829
8ac4bfa55053
restore optimization for compound transpose-mul/div ops (bug #45890)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
217 #if 0 |
25831
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
218 // Restore this case if short-circuit behavior can be preserved |
d0062829754a
Silence compiler warnings about unused functions from cset 8ac4bfa55053.
Rik <rik@octave.org>
parents:
25829
diff
changeset
|
219 // when needed. See bug #54465. |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
220 case octave_value::op_el_and: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
221 case octave_value::op_el_or: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
222 ct = simplify_and_or_op (ca, cb, t); |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
223 break; |
25829
8ac4bfa55053
restore optimization for compound transpose-mul/div ops (bug #45890)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
224 #endif |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
225 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
226 default: |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
227 ct = octave_value::unknown_compound_binary_op; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
228 break; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
229 } |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
230 |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
231 tree_binary_expression *ret |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
232 = (ct == octave_value::unknown_compound_binary_op |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
233 ? new tree_binary_expression (a, b, l, c, t) |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24722
diff
changeset
|
234 : new tree_compound_binary_expression (a, b, l, c, t, ca, cb, ct)); |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
235 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
236 return ret; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
237 } |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
238 } |