annotate libinterp/parse-tree/pt-cbinop.h @ 26377:fff643eb3514

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 02 Jan 2019 16:45:58 -0500
parents f23f27e78aa2 00f796120a6d
children db687716fed6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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: 25054
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: 24362
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: 24362
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: 24362
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
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
23 #if ! defined (octave_pt_cbinop_h)
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17744
diff changeset
24 #define octave_pt_cbinop_h 1
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
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
26 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
27
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 <string>
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 class octave_value;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 class octave_value_list;
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 #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
34 #include "pt-binop.h"
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
35 #include "pt-walk.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
36
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
37 namespace octave
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
38 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
39 // Binary expressions that can be reduced to compound operations
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
40
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
41 class tree_compound_binary_expression : public tree_binary_expression
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
42 {
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
43 public:
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
45 tree_compound_binary_expression (tree_expression *a, tree_expression *b,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
46 int l, int c,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
47 octave_value::binary_op t,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
48 tree_expression *ca, tree_expression *cb,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
49 octave_value::compound_binary_op ct)
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
50 : tree_binary_expression (a, b, l, c, t), m_lhs (ca), m_rhs (cb),
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
51 m_etype (ct)
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
52 { }
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
54 octave_value::compound_binary_op cop_type (void) const { return m_etype; }
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
55
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
56 bool rvalue_ok (void) const { return true; }
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
58 tree_expression * clhs (void) { return m_lhs; }
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
59 tree_expression * crhs (void) { return m_rhs; }
23522
d2e300f7700c fix compound binary op error introduced in c452180ab672
John W. Eaton <jwe@octave.org>
parents: 23444
diff changeset
60
23435
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
61 void accept (tree_walker& tw)
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
62 {
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
63 tw.visit_compound_binary_expression (*this);
c452180ab672 begin refactoring parse tree evaluator
John W. Eaton <jwe@octave.org>
parents: 23424
diff changeset
64 }
23424
872f42fb26dc let walker visit tree_boolean and tree_compound_binary expressions directly
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
65
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
66 private:
19656
bf88eab464b8 Detect binary operations with a transposed matrix and forward to BLAS (bug #42716).
David Bateman <dbateman@free.fr>
parents: 17822
diff changeset
67
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
68 tree_expression *m_lhs;
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
69 tree_expression *m_rhs;
23522
d2e300f7700c fix compound binary op error introduced in c452180ab672
John W. Eaton <jwe@octave.org>
parents: 23444
diff changeset
70
24846
7620f1f5290d use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
71 octave_value::compound_binary_op m_etype;
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
73 // No copying!
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
74
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
75 tree_compound_binary_expression (const tree_compound_binary_expression&) = delete;
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11523
diff changeset
76
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
77 tree_compound_binary_expression& operator =
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
78 (const tree_compound_binary_expression&) = delete;
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
79 };
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11523
diff changeset
80
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
81 // a "virtual constructor"
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
23075
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
83 tree_binary_expression *
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
84 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: 22865
diff changeset
85 int l = -1, int c = -1,
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
86 octave_value::binary_op t
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
87 = octave_value::unknown_binary_op);
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
88 }
4e3d47dc7e25 move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
89
7800
5861b95e9879 support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 #endif