GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-bm-b.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2001-2023 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.h"
34 #include "ov-bool-mat.h"
35 #include "ov-scalar.h"
36 #include "ov-float.h"
37 #include "ov-re-mat.h"
38 #include "ov-flt-re-mat.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 "ops.h"
50 #include "xdiv.h"
51 #include "xpow.h"
52 
54 
55 // bool matrix by bool ops.
56 
57 DEFNDBINOP_FN (el_and, bool_matrix, bool, bool_array, bool, mx_el_and)
58 DEFNDBINOP_FN (el_or, bool_matrix, bool, bool_array, bool, mx_el_or)
59 
60 DEFNDBINOP_FN (el_not_and, bool_matrix, bool, bool_array, bool, mx_el_not_and)
61 DEFNDBINOP_FN (el_not_or, bool_matrix, bool, bool_array, bool, mx_el_not_or)
62 
63 DEFNDCATOP_FN (bm_b, bool_matrix, bool, bool_array, bool_array, concat)
64 DEFNDCATOP_FN (bm_s, bool_matrix, scalar, array, array, concat)
65 DEFNDCATOP_FN (m_b, matrix, bool, array, array, concat)
66 DEFNDCATOP_FN (bm_f, bool_matrix, float_scalar, float_array, float_array,
68 DEFNDCATOP_FN (fm_b, float_matrix, bool, float_array, float_array, concat)
69 
70 DEFNDASSIGNOP_FN (assign, bool_matrix, bool, bool_array, assign)
71 
72 static octave_value
74  const octave_value_list& idx,
75  const octave_base_value& a2)
76 {
77  octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1);
78 
79  // FIXME: perhaps add a warning for this conversion
80  // if the values are not all 0 or 1?
81 
83 
84  v1.assign (idx, v2);
85 
86  return octave_value ();
87 }
88 
89 void
90 install_bm_b_ops (octave::type_info& ti)
91 {
94  INSTALL_BINOP_TI (ti, op_el_not_and, octave_bool_matrix, octave_bool, el_not_and);
95  INSTALL_BINOP_TI (ti, op_el_not_or, octave_bool_matrix, octave_bool, el_not_or);
96 
102 
103  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_bool, assign);
104 
106  conv_and_assign);
107 
108  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int8_scalar,
109  conv_and_assign);
110  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int16_scalar,
111  conv_and_assign);
112  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int32_scalar,
113  conv_and_assign);
114  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int64_scalar,
115  conv_and_assign);
116 
117  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint8_scalar,
118  conv_and_assign);
119  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint16_scalar,
120  conv_and_assign);
121  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint32_scalar,
122  conv_and_assign);
124  conv_and_assign);
125 }
126 
OCTAVE_END_NAMESPACE(octave)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
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
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
OCTINTERP_API void assign(const octave_value_list &idx, const MT &rhs)
Definition: ov-base-mat.cc:225
virtual boolNDArray bool_array_value(bool=false) const
Definition: ov-base.cc:617
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void install_bm_b_ops(octave::type_info &ti)
Definition: op-bm-b.cc:90
static octave_value oct_assignop_conv_and_assign(octave_base_value &a1, const octave_value_list &idx, const octave_base_value &a2)
Definition: op-bm-b.cc:73
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:112
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:301
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:55
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:349
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition: ops.h:60
#define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f)
Definition: ops.h:64
static bool scalar(const dim_vector &dims)
Definition: ov-struct.cc:679
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1888
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1887