Mercurial > octave
annotate libinterp/operators/op-b-b.cc @ 33634:4a70f390c85e default tip @
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 28 May 2024 15:25:54 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31867
diff
changeset
|
3 // Copyright (C) 1996-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
2928 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
2928 | 28 #endif |
29 | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
30 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
31 #include "ovl.h" |
2928 | 32 #include "ov.h" |
33 #include "ov-bool.h" | |
4964 | 34 #include "ov-bool-mat.h" |
4915 | 35 #include "ov-scalar.h" |
24654
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
36 #include "ov-re-mat.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
37 #include "ov-complex.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
38 #include "ov-cx-mat.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
39 #include "ov-float.h" |
24654
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
40 #include "ov-flt-re-mat.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
41 #include "ov-flt-complex.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
42 #include "ov-flt-cx-mat.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
43 #include "ov-int8.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
44 #include "ov-int16.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
45 #include "ov-int32.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
46 #include "ov-int64.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
47 #include "ov-uint8.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
48 #include "ov-uint16.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
49 #include "ov-uint32.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
50 #include "ov-uint64.h" |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
51 #include "ov-null-mat.h" |
2928 | 52 #include "ov-typeinfo.h" |
53 #include "ops.h" | |
54 #include "xdiv.h" | |
55 #include "xpow.h" | |
56 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
57 OCTAVE_BEGIN_NAMESPACE(octave) |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
58 |
3203 | 59 // bool unary ops. |
60 | |
61 // scalar unary ops. | |
62 | |
63 DEFUNOP_OP (not, bool, !) | |
4965 | 64 |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
65 static octave_value |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
66 oct_unop_uplus (const octave_base_value& a) |
4965 | 67 { |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
68 OCTAVE_CAST_BASE_VALUE (const octave_bool&, v, a); |
4965 | 69 return octave_value (v.double_value ()); |
70 } | |
71 | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
72 static octave_value |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
73 oct_unop_uminus (const octave_base_value& a) |
4965 | 74 { |
31867
a9c8b1f8fb32
use macro to simplify octave_base_value casts in operator functions
John W. Eaton <jwe@octave.org>
parents:
31866
diff
changeset
|
75 OCTAVE_CAST_BASE_VALUE (const octave_bool&, v, a); |
4965 | 76 return octave_value (- v.double_value ()); |
77 } | |
78 | |
3203 | 79 DEFUNOP_OP (transpose, bool, /* no-op */) |
80 DEFUNOP_OP (hermitian, bool, /* no-op */) | |
81 | |
2928 | 82 // bool by bool ops. |
83 | |
84 DEFBINOP_OP (eq, bool, bool, ==) | |
85 DEFBINOP_OP (ne, bool, bool, !=) | |
3798 | 86 DEFBINOP_OP (el_and, bool, bool, &&) |
87 DEFBINOP_OP (el_or, bool, bool, ||) | |
3797 | 88 |
4964 | 89 DEFNDCATOP_FN (b_b, bool, bool, bool_array, bool_array, concat) |
4915 | 90 DEFNDCATOP_FN (b_s, bool, scalar, array, array, concat) |
91 DEFNDCATOP_FN (s_b, scalar, bool, array, array, concat) | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
92 DEFNDCATOP_FN (b_f, bool, float_scalar, float_array, float_array, concat) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
93 DEFNDCATOP_FN (f_b, float_scalar, bool, float_array, float_array, concat) |
4915 | 94 |
24654
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
95 #define OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(TRHS) \ |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
96 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_ ## TRHS ## _scalar, octave_bool_matrix) \ |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
97 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_ ## TRHS ## _matrix, octave_bool_matrix) |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
98 |
2928 | 99 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
100 install_b_b_ops (octave::type_info& ti) |
2928 | 101 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
102 INSTALL_UNOP_TI (ti, op_not, octave_bool, not); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 INSTALL_UNOP_TI (ti, op_uplus, octave_bool, uplus); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
104 INSTALL_UNOP_TI (ti, op_uminus, octave_bool, uminus); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 INSTALL_UNOP_TI (ti, op_transpose, octave_bool, transpose); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
106 INSTALL_UNOP_TI (ti, op_hermitian, octave_bool, hermitian); |
3203 | 107 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
108 INSTALL_BINOP_TI (ti, op_eq, octave_bool, octave_bool, eq); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
109 INSTALL_BINOP_TI (ti, op_ne, octave_bool, octave_bool, ne); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
110 INSTALL_BINOP_TI (ti, op_el_and, octave_bool, octave_bool, el_and); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
111 INSTALL_BINOP_TI (ti, op_el_or, octave_bool, octave_bool, el_or); |
4915 | 112 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
113 INSTALL_CATOP_TI (ti, octave_bool, octave_bool, b_b); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
114 INSTALL_CATOP_TI (ti, octave_bool, octave_scalar, b_s); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
115 INSTALL_CATOP_TI (ti, octave_scalar, octave_bool, s_b); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
116 INSTALL_CATOP_TI (ti, octave_bool, octave_float_scalar, b_f); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 INSTALL_CATOP_TI (ti, octave_float_scalar, octave_bool, f_b); |
4964 | 118 |
24654
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
119 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(int8); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
120 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(int16); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
121 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(int32); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
122 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(int64); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
123 |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
124 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(uint8); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
125 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(uint16); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
126 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(uint32); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
127 OCTAVE_INSTALL_BOOL_INT_ASSIGNCONV(uint64); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
128 |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
129 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_scalar, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
130 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_matrix, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
131 |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
132 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_complex, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
133 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_complex_matrix, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
134 |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
135 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_float_scalar, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
136 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_float_matrix, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
137 |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
138 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_float_complex_scalar, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
139 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_float_complex_matrix, octave_bool_matrix); |
6daa29105d21
don't convert type of logial scalars on assignment (bug #53007)
John W. Eaton <jwe@octave.org>
parents:
24540
diff
changeset
|
140 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_bool, octave_bool_matrix); |
18213
cda4bd2fd0c0
fix null matrix assignment to indexed integer and logical values (bug #35921)
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
142 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_null_matrix, octave_bool_matrix); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_null_str, octave_bool_matrix); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_null_sq_str, octave_bool_matrix); |
2928 | 146 } |
29989
b260322f6730
move xdiv, xnorm, and xpow inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
147 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
148 OCTAVE_END_NAMESPACE(octave) |