GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-bm-bm.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include "errwarn.h"
31 #include "ovl.h"
32 #include "ov.h"
33 #include "ov-bool-mat.h"
34 #include "ov-scalar.h"
35 #include "ov-range.h"
36 #include "ov-re-mat.h"
37 #include "ov-flt-re-mat.h"
38 #include "ov-re-sparse.h"
39 #include "ov-str-mat.h"
40 #include "ov-int8.h"
41 #include "ov-int16.h"
42 #include "ov-int32.h"
43 #include "ov-int64.h"
44 #include "ov-uint8.h"
45 #include "ov-uint16.h"
46 #include "ov-uint32.h"
47 #include "ov-uint64.h"
48 #include "ov-typeinfo.h"
49 #include "ov-null-mat.h"
50 #include "ops.h"
51 #include "xdiv.h"
52 #include "xpow.h"
53 
55 
56 // unary bool matrix ops.
57 
58 DEFNDUNOP_OP (not, bool_matrix, bool_array, !)
59 DEFNDUNOP_OP (uplus, bool_matrix, array, +)
60 DEFNDUNOP_OP (uminus, bool_matrix, array, -)
61 
62 DEFNCUNOP_METHOD (invert, bool_matrix, invert)
63 
64 DEFUNOP (transpose, bool_matrix)
65 {
67 
68  if (v.ndims () > 2)
69  error ("transpose not defined for N-D objects");
70 
71  return octave_value (v.bool_matrix_value ().transpose ());
72 }
73 
74 // bool matrix by bool matrix ops.
75 
76 DEFNDBINOP_FN (eq, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_eq)
77 DEFNDBINOP_FN (ne, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_ne)
78 
79 DEFNDBINOP_FN (el_and, bool_matrix, bool_matrix, bool_array, bool_array,
80  mx_el_and)
81 
82 DEFNDBINOP_FN (el_or, bool_matrix, bool_matrix, bool_array, bool_array,
83  mx_el_or)
84 
85 DEFNDBINOP_FN (el_not_and, bool_matrix, bool_matrix, bool_array, bool_array,
87 
88 DEFNDBINOP_FN (el_not_or, bool_matrix, bool_matrix, bool_array, bool_array,
90 
91 DEFNDBINOP_FN (el_and_not, bool_matrix, bool_matrix, bool_array, bool_array,
93 
94 DEFNDBINOP_FN (el_or_not, bool_matrix, bool_matrix, bool_array, bool_array,
96 
97 DEFNDCATOP_FN (bm_bm, bool_matrix, bool_matrix, bool_array, bool_array, concat)
98 DEFNDCATOP_FN (bm_m, bool_matrix, matrix, array, array, concat)
99 DEFNDCATOP_FN (m_bm, matrix, bool_matrix, array, array, concat)
100 DEFNDCATOP_FN (bm_fm, bool_matrix, float_matrix, float_array, float_array,
101  concat)
102 DEFNDCATOP_FN (fm_bm, float_matrix, bool_matrix, float_array, float_array,
103  concat)
104 
105 DEFNDASSIGNOP_FN (assign, bool_matrix, bool_matrix, bool_array, assign)
106 DEFNDASSIGNOP_FNOP (assign_and, bool_matrix, bool_matrix, bool_array,
108 DEFNDASSIGNOP_FNOP (assign_or, bool_matrix, bool_matrix, bool_array,
110 
111 DEFNULLASSIGNOP_FN (null_assign, bool_matrix, delete_elements)
112 
113 static octave_value
114 oct_assignop_conv_and_assign (octave_base_value& a1,
115  const octave_value_list& idx,
116  const octave_base_value& a2)
117 {
119 
120  // FIXME: perhaps add a warning for this conversion
121  // if the values are not all 0 or 1?
122 
124 
125  v1.assign (idx, v2);
126 
127  return octave_value ();
128 }
129 
130 void
131 install_bm_bm_ops (octave::type_info& ti)
132 {
138 
140 
143 
147  el_not_and);
149  el_not_or);
151  el_and_not);
153  el_or_not);
154 
160 
162  assign);
163 
165  conv_and_assign);
167  conv_and_assign);
168  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix,
170  conv_and_assign);
171 
173  conv_and_assign);
174 
176  conv_and_assign);
177 
178  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int8_matrix,
179  conv_and_assign);
180  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int16_matrix,
181  conv_and_assign);
182  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int32_matrix,
183  conv_and_assign);
184  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int64_matrix,
185  conv_and_assign);
186 
187  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint8_matrix,
188  conv_and_assign);
189  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint16_matrix,
190  conv_and_assign);
191  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint32_matrix,
192  conv_and_assign);
194  conv_and_assign);
195 
197  null_assign);
199  null_assign);
201  null_assign);
202 
204  assign_and);
206  assign_or);
207 }
208 
209 OCTAVE_END_NAMESPACE(octave)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolMatrix mx_el_or(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:88
boolMatrix mx_el_and(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:88
boolMatrix mx_el_eq(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
boolNDArray mx_el_or_not(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:122
boolNDArray mx_el_and_not(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:122
boolNDArray mx_el_not_and(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:122
boolNDArray mx_el_not_or(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:122
boolNDArray & mx_el_or_assign(boolNDArray &a, const boolNDArray &b)
Definition: boolNDArray.cc:144
boolNDArray & mx_el_and_assign(boolNDArray &a, const boolNDArray &b)
Definition: boolNDArray.cc:132
void assign(const octave::idx_vector &i, const Array< T, Alloc > &rhs, const T &rfv)
Indexed assignment (always with resize & fill).
Definition: Array-base.cc:1128
virtual boolNDArray bool_array_value(bool=false) const
Definition: ov-base.cc:675
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void() error(const char *fmt,...)
Definition: error.cc:988
void install_bm_bm_ops(octave::type_info &ti)
Definition: op-bm-bm.cc:131
const octave_base_value & a2
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
const octave_char_matrix & v2
#define DEFNDASSIGNOP_FN(name, t1, t2, e, f)
Definition: ops.h:127
#define INSTALL_NCUNOP_TI(ti, op, t, f)
Definition: ops.h:66
#define DEFNULLASSIGNOP_FN(name, t, f)
Definition: ops.h:115
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:316
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition: ops.h:156
#define DEFNDUNOP_OP(name, t, e, op)
Definition: ops.h:206
#define OCTAVE_CAST_BASE_VALUE(T, T_VAL, BASE_VAL)
Definition: ops.h:52
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:232
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:70
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:364
#define DEFUNOP(name, t)
Definition: ops.h:194
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition: ops.h:75
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition: ops.h:62
#define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f)
Definition: ops.h:79
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1676
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1634
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1635
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1637
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1683
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1638
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1682
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1673
octave_value op_not(const octave_value &a)
Definition: ov.h:1633