Mercurial > octave-nkf
annotate libinterp/operators/op-bm-bm.cc @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | f90c8372b7ba |
children |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include "gripes.h" | |
4055 | 28 #include "oct-obj.h" |
2928 | 29 #include "ov.h" |
30 #include "ov-bool-mat.h" | |
7105 | 31 #include "ov-scalar.h" |
5898 | 32 #include "ov-range.h" |
4915 | 33 #include "ov-re-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7105
diff
changeset
|
34 #include "ov-flt-re-mat.h" |
5898 | 35 #include "ov-re-sparse.h" |
36 #include "ov-str-mat.h" | |
37 #include "ov-int8.h" | |
38 #include "ov-int16.h" | |
39 #include "ov-int32.h" | |
40 #include "ov-int64.h" | |
41 #include "ov-uint8.h" | |
42 #include "ov-uint16.h" | |
43 #include "ov-uint32.h" | |
44 #include "ov-uint64.h" | |
2928 | 45 #include "ov-typeinfo.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
46 #include "ov-null-mat.h" |
2928 | 47 #include "ops.h" |
48 #include "xdiv.h" | |
49 #include "xpow.h" | |
50 | |
3203 | 51 // unary bool matrix ops. |
52 | |
4550 | 53 DEFNDUNOP_OP (not, bool_matrix, bool_array, !) |
4965 | 54 DEFNDUNOP_OP (uplus, bool_matrix, array, +) |
55 DEFNDUNOP_OP (uminus, bool_matrix, array, -) | |
3203 | 56 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
57 DEFNCUNOP_METHOD (invert, bool_matrix, invert) |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
58 |
3203 | 59 DEFUNOP (transpose, bool_matrix) |
60 { | |
61 CAST_UNOP_ARG (const octave_bool_matrix&); | |
62 | |
4673 | 63 if (v.ndims () > 2) |
64 { | |
65 error ("transpose not defined for N-d objects"); | |
66 return octave_value (); | |
67 } | |
68 else | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 return octave_value (v.bool_matrix_value ().transpose ()); |
3203 | 70 } |
71 | |
2928 | 72 // bool matrix by bool matrix ops. |
73 | |
4550 | 74 DEFNDBINOP_FN (eq, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_eq) |
75 DEFNDBINOP_FN (ne, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_ne) | |
2928 | 76 |
4669 | 77 DEFNDBINOP_FN (el_and, bool_matrix, bool_matrix, bool_array, bool_array, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
78 mx_el_and) |
4669 | 79 |
80 DEFNDBINOP_FN (el_or, bool_matrix, bool_matrix, bool_array, bool_array, | |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
81 mx_el_or) |
4669 | 82 |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
83 DEFNDBINOP_FN (el_not_and, bool_matrix, bool_matrix, bool_array, bool_array, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
84 mx_el_not_and) |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
85 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
86 DEFNDBINOP_FN (el_not_or, bool_matrix, bool_matrix, bool_array, bool_array, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
87 mx_el_not_or) |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
88 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
89 DEFNDBINOP_FN (el_and_not, bool_matrix, bool_matrix, bool_array, bool_array, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
90 mx_el_and_not) |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
91 |
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
92 DEFNDBINOP_FN (el_or_not, bool_matrix, bool_matrix, bool_array, bool_array, |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
93 mx_el_or_not) |
8982
dc6bda6f9994
implement compound logical ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
94 |
4964 | 95 DEFNDCATOP_FN (bm_bm, bool_matrix, bool_matrix, bool_array, bool_array, concat) |
4915 | 96 DEFNDCATOP_FN (bm_m, bool_matrix, matrix, array, array, concat) |
97 DEFNDCATOP_FN (m_bm, matrix, bool_matrix, array, array, concat) | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
98 DEFNDCATOP_FN (bm_fm, bool_matrix, float_matrix, float_array, float_array, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 concat) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 DEFNDCATOP_FN (fm_bm, float_matrix, bool_matrix, float_array, float_array, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 concat) |
4915 | 102 |
4686 | 103 DEFNDASSIGNOP_FN (assign, bool_matrix, bool_matrix, bool_array, assign) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
104 DEFNDASSIGNOP_FNOP (assign_and, bool_matrix, bool_matrix, bool_array, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 mx_el_and_assign) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 DEFNDASSIGNOP_FNOP (assign_or, bool_matrix, bool_matrix, bool_array, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 mx_el_or_assign) |
4669 | 108 |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
109 DEFNULLASSIGNOP_FN (null_assign, bool_matrix, delete_elements) |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
110 |
5898 | 111 static octave_value |
112 oct_assignop_conv_and_assign (octave_base_value& a1, | |
9931
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
113 const octave_value_list& idx, |
fb6b6fcafa62
untabify files in src/OPERATORS directory
John W. Eaton <jwe@octave.org>
parents:
9607
diff
changeset
|
114 const octave_base_value& a2) |
5898 | 115 { |
116 octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1); | |
117 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 // FIXME: perhaps add a warning for this conversion |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 // if the values are not all 0 or 1? |
5898 | 120 |
5943 | 121 boolNDArray v2 = a2.bool_array_value (true); |
5898 | 122 |
20587
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19731
diff
changeset
|
123 v1.assign (idx, v2); |
5898 | 124 |
125 return octave_value (); | |
126 } | |
127 | |
7105 | 128 DEFCONVFN (matrix_to_bool_matrix, matrix, bool) |
129 DEFCONVFN (scalar_to_bool_matrix, scalar, bool) | |
130 | |
2928 | 131 void |
132 install_bm_bm_ops (void) | |
133 { | |
3538 | 134 INSTALL_UNOP (op_not, octave_bool_matrix, not); |
4965 | 135 INSTALL_UNOP (op_uplus, octave_bool_matrix, uplus); |
136 INSTALL_UNOP (op_uminus, octave_bool_matrix, uminus); | |
3538 | 137 INSTALL_UNOP (op_transpose, octave_bool_matrix, transpose); |
138 INSTALL_UNOP (op_hermitian, octave_bool_matrix, transpose); | |
3203 | 139 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
140 INSTALL_NCUNOP (op_not, octave_bool_matrix, invert); |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9548
diff
changeset
|
141 |
3538 | 142 INSTALL_BINOP (op_eq, octave_bool_matrix, octave_bool_matrix, eq); |
143 INSTALL_BINOP (op_ne, octave_bool_matrix, octave_bool_matrix, ne); | |
4669 | 144 |
145 INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_bool_matrix, el_and); | |
146 INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_bool_matrix, el_or); | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 INSTALL_BINOP (op_el_not_and, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 el_not_and); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 INSTALL_BINOP (op_el_not_or, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 el_not_or); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 INSTALL_BINOP (op_el_and_not, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
152 el_and_not); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
153 INSTALL_BINOP (op_el_or_not, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 el_or_not); |
4669 | 155 |
4915 | 156 INSTALL_CATOP (octave_bool_matrix, octave_bool_matrix, bm_bm); |
157 INSTALL_CATOP (octave_bool_matrix, octave_matrix, bm_m); | |
158 INSTALL_CATOP (octave_matrix, octave_bool_matrix, m_bm); | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7105
diff
changeset
|
159 INSTALL_CATOP (octave_bool_matrix, octave_float_matrix, bm_fm); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7105
diff
changeset
|
160 INSTALL_CATOP (octave_float_matrix, octave_bool_matrix, fm_bm); |
4915 | 161 |
7105 | 162 INSTALL_CONVOP (octave_matrix, octave_bool_matrix, matrix_to_bool_matrix); |
163 INSTALL_CONVOP (octave_scalar, octave_bool_matrix, scalar_to_bool_matrix); | |
164 | |
4669 | 165 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool_matrix, assign); |
5898 | 166 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
167 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
169 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_char_matrix_str, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
170 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
171 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_char_matrix_sq_str, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
172 conv_and_assign); |
5898 | 173 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
174 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_range, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 conv_and_assign); |
5898 | 176 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
177 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_sparse_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
178 conv_and_assign); |
5898 | 179 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
180 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int8_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
181 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int16_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
183 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
184 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int32_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
186 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int64_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
187 conv_and_assign); |
5898 | 188 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
189 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint8_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
190 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint16_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
192 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
193 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint32_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
194 conv_and_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
195 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint64_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 conv_and_assign); |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
197 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_null_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 null_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_null_str, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
201 null_assign); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
202 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_null_sq_str, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
203 null_assign); |
9548
e5f7aee2ab8c
optimize &=, |= operators
Jaroslav Hajek <highegg@gmail.com>
parents:
8982
diff
changeset
|
204 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
205 INSTALL_ASSIGNOP (op_el_and_eq, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
206 assign_and); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
207 INSTALL_ASSIGNOP (op_el_or_eq, octave_bool_matrix, octave_bool_matrix, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 assign_or); |
2928 | 209 } |