1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2003-2021 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-typeinfo.h"
40 #include "ops.h"
41 #include "xdiv.h"
42 #include "xpow.h"
43 
44 // bool matrix by bool ops.
45 
DEFNDBINOP_FN(el_and,bool,bool_matrix,bool,bool_array,mx_el_and)46 DEFNDBINOP_FN (el_and, bool, bool_matrix, bool, bool_array, mx_el_and)
47 DEFNDBINOP_FN (el_or, bool, bool_matrix, bool, bool_array, mx_el_or)
48 
49 DEFNDBINOP_FN (el_and_not, bool, bool_matrix, bool, bool_array, mx_el_and_not)
50 DEFNDBINOP_FN (el_or_not, bool, bool_matrix, bool, bool_array, mx_el_or_not)
51 
52 DEFNDCATOP_FN (b_bm, bool, bool_matrix, bool_array, bool_array, concat)
53 DEFNDCATOP_FN (b_m, bool, matrix, array, array, concat)
54 DEFNDCATOP_FN (s_bm, scalar, bool_matrix, array, array, concat)
55 
56 DEFNDCATOP_FN (b_fm, bool, float_matrix, float_array, float_array, concat)
57 DEFNDCATOP_FN (f_bm, float_scalar, bool_matrix, float_array, float_array,
58                concat)
59 
60 DEFCONV (bool_matrix_conv, bool, bool_matrix)
61 {
62   const octave_bool& v = dynamic_cast<const octave_bool&> (a);
63 
64   return new octave_bool_matrix (v.bool_matrix_value ());
65 }
66 
67 void
install_b_bm_ops(octave::type_info & ti)68 install_b_bm_ops (octave::type_info& ti)
69 {
70   INSTALL_BINOP_TI (ti, op_el_and, octave_bool, octave_bool_matrix, el_and);
71   INSTALL_BINOP_TI (ti, op_el_or, octave_bool, octave_bool_matrix, el_or);
72   INSTALL_BINOP_TI (ti, op_el_and_not, octave_bool, octave_bool_matrix, el_and_not);
73   INSTALL_BINOP_TI (ti, op_el_or_not, octave_bool, octave_bool_matrix, el_or_not);
74 
75   INSTALL_CATOP_TI (ti, octave_bool, octave_bool_matrix, b_bm);
76   INSTALL_CATOP_TI (ti, octave_bool, octave_matrix, b_m);
77   INSTALL_CATOP_TI (ti, octave_scalar, octave_bool_matrix, s_bm);
78   INSTALL_CATOP_TI (ti, octave_bool, octave_float_matrix, b_fm);
79   INSTALL_CATOP_TI (ti, octave_float_scalar, octave_bool_matrix, f_bm);
80 
81   INSTALL_ASSIGNCONV_TI (ti, octave_bool, octave_bool_matrix, octave_bool_matrix);
82 
83   INSTALL_WIDENOP_TI (ti, octave_bool, octave_bool_matrix, bool_matrix_conv);
84 }
85