GNU Octave  4.4.1
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-2018 John W. Eaton
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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include "errwarn.h"
28 #include "ovl.h"
29 #include "ov.h"
30 #include "ov-bool-mat.h"
31 #include "ov-scalar.h"
32 #include "ov-range.h"
33 #include "ov-re-mat.h"
34 #include "ov-flt-re-mat.h"
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"
45 #include "ov-typeinfo.h"
46 #include "ov-null-mat.h"
47 #include "ops.h"
48 #include "xdiv.h"
49 #include "xpow.h"
50 
51 // unary bool matrix ops.
52 
53 DEFNDUNOP_OP (not, bool_matrix, bool_array, !)
54 DEFNDUNOP_OP (uplus, bool_matrix, array, +)
55 DEFNDUNOP_OP (uminus, bool_matrix, array, -)
56 
57 DEFNCUNOP_METHOD (invert, bool_matrix, invert)
58 
59 DEFUNOP (transpose, bool_matrix)
60 {
61  const octave_bool_matrix& v = dynamic_cast<const octave_bool_matrix&> (a);
62 
63  if (v.ndims () > 2)
64  error ("transpose not defined for N-D objects");
65 
66  return octave_value (v.bool_matrix_value ().transpose ());
67 }
68 
69 // bool matrix by bool matrix ops.
70 
71 DEFNDBINOP_FN (eq, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_eq)
72 DEFNDBINOP_FN (ne, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_ne)
73 
74 DEFNDBINOP_FN (el_and, bool_matrix, bool_matrix, bool_array, bool_array,
76 
77 DEFNDBINOP_FN (el_or, bool_matrix, bool_matrix, bool_array, bool_array,
79 
80 DEFNDBINOP_FN (el_not_and, bool_matrix, bool_matrix, bool_array, bool_array,
82 
83 DEFNDBINOP_FN (el_not_or, bool_matrix, bool_matrix, bool_array, bool_array,
85 
86 DEFNDBINOP_FN (el_and_not, bool_matrix, bool_matrix, bool_array, bool_array,
88 
89 DEFNDBINOP_FN (el_or_not, bool_matrix, bool_matrix, bool_array, bool_array,
91 
92 DEFNDCATOP_FN (bm_bm, bool_matrix, bool_matrix, bool_array, bool_array, concat)
93 DEFNDCATOP_FN (bm_m, bool_matrix, matrix, array, array, concat)
94 DEFNDCATOP_FN (m_bm, matrix, bool_matrix, array, array, concat)
95 DEFNDCATOP_FN (bm_fm, bool_matrix, float_matrix, float_array, float_array,
97 DEFNDCATOP_FN (fm_bm, float_matrix, bool_matrix, float_array, float_array,
99 
100 DEFNDASSIGNOP_FN (assign, bool_matrix, bool_matrix, bool_array, assign)
101 DEFNDASSIGNOP_FNOP (assign_and, bool_matrix, bool_matrix, bool_array,
103 DEFNDASSIGNOP_FNOP (assign_or, bool_matrix, bool_matrix, bool_array,
105 
106 DEFNULLASSIGNOP_FN (null_assign, bool_matrix, delete_elements)
107 
108 static octave_value
110  const octave_value_list& idx,
111  const octave_base_value& a2)
112 {
113  octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1);
114 
115  // FIXME: perhaps add a warning for this conversion
116  // if the values are not all 0 or 1?
117 
119 
120  v1.assign (idx, v2);
121 
122  return octave_value ();
123 }
124 
125 void
127 {
133 
135 
138 
142  el_not_and);
144  el_not_or);
146  el_and_not);
148  el_or_not);
149 
155 
157  assign);
158 
160  conv_and_assign);
162  conv_and_assign);
163  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix,
165  conv_and_assign);
166 
168  conv_and_assign);
169 
171  conv_and_assign);
172 
173  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int8_matrix,
174  conv_and_assign);
175  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int16_matrix,
176  conv_and_assign);
177  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int32_matrix,
178  conv_and_assign);
179  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_int64_matrix,
180  conv_and_assign);
181 
182  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint8_matrix,
183  conv_and_assign);
184  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint16_matrix,
185  conv_and_assign);
186  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint32_matrix,
187  conv_and_assign);
188  INSTALL_ASSIGNOP_TI (ti, op_asn_eq, octave_bool_matrix, octave_uint64_matrix,
189  conv_and_assign);
190 
192  null_assign);
194  null_assign);
196  null_assign);
197 
199  assign_and);
201  assign_or);
202 }
#define INSTALL_ASSIGNOP_TI(ti, op, t1, t2, f)
Definition: ops.h:62
octave_value op_uplus(const octave_value &a)
Definition: ov.h:1574
boolMatrix transpose(void) const
Definition: boolMatrix.h:60
#define DEFUNOP(name, t)
Definition: ops.h:213
#define INSTALL_BINOP_TI(ti, op, t1, t2, f)
Definition: ops.h:53
characters Given a string matrix
Definition: hex2num.cc:155
octave_value op_eq(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1613
boolNDArray mx_el_and_not(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:135
#define DEFNDASSIGNOP_FNOP(name, t1, t2, f, fnop)
Definition: ops.h:175
void assign(const octave_value_list &idx, const MT &rhs)
Definition: ov-base-mat.cc:214
boolNDArray mx_el_not_or(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:135
#define DEFNULLASSIGNOP_FN(name, t, f)
Definition: ops.h:134
boolNDArray mx_el_not_and(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:135
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)
Definition: symrcm.cc:386
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
void error(const char *fmt,...)
Definition: error.cc:578
#define INSTALL_NCUNOP_TI(ti, op, t, f)
Definition: ops.h:49
#define DEFNDBINOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:335
const octave_base_value & a2
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
#define INSTALL_UNOP_TI(ti, op, t, f)
Definition: ops.h:45
then the function must return scalars which will be concatenated into the return array(s). If code
Definition: cellfun.cc:400
octave_value op_el_or(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1623
octave_value op_not(const octave_value &a)
Definition: ov.h:1573
#define INSTALL_CATOP_TI(ti, t1, t2, f)
Definition: ops.h:58
octave_value op_transpose(const octave_value &a)
Definition: ov.h:1577
octave_value op_el_and(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1622
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-bm.cc:109
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:89
boolMatrix bool_matrix_value(bool=false) const
Definition: ov-bool-mat.h:177
boolNDArray & mx_el_and_assign(boolNDArray &a, const boolNDArray &b)
Definition: boolNDArray.cc:145
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
int ndims(void) const
Definition: ov-base-mat.h:109
const octave_char_matrix & v2
boolMatrix mx_el_or(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:86
#define DEFNDASSIGNOP_FN(name, t1, t2, e, f)
Definition: ops.h:146
void install_bm_bm_ops(octave::type_info &ti)
Definition: op-bm-bm.cc:126
octave_value op_ne(const octave_value &a1, const octave_value &a2)
Definition: ov.h:1616
boolMatrix mx_el_and(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:86
boolNDArray mx_el_or_not(const boolNDArray &m1, const boolNDArray &m2)
Definition: boolNDArray.cc:135
#define DEFNDUNOP_OP(name, t, e, op)
Definition: ops.h:225
octave_value op_hermitian(const octave_value &a)
Definition: ov.h:1578
#define DEFNDCATOP_FN(name, t1, t2, e1, e2, f)
Definition: ops.h:382
boolMatrix mx_el_eq(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:89
octave_value op_uminus(const octave_value &a)
Definition: ov.h:1575
boolNDArray & mx_el_or_assign(boolNDArray &a, const boolNDArray &b)
Definition: boolNDArray.cc:157
virtual boolNDArray bool_array_value(bool=false) const
Definition: ov-base.cc:614
#define DEFNCUNOP_METHOD(name, t, method)
Definition: ops.h:251