2928
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 the |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2928
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2928
|
20 |
|
21 */ |
|
22 |
|
23 #ifdef HAVE_CONFIG_H |
|
24 #include <config.h> |
|
25 #endif |
|
26 |
|
27 #include "gripes.h" |
4055
|
28 #include "oct-obj.h" |
2928
|
29 #include "ov.h" |
|
30 #include "ov-bool-mat.h" |
5898
|
31 #include "ov-range.h" |
4915
|
32 #include "ov-re-mat.h" |
5898
|
33 #include "ov-re-sparse.h" |
|
34 #include "ov-str-mat.h" |
|
35 #include "ov-int8.h" |
|
36 #include "ov-int16.h" |
|
37 #include "ov-int32.h" |
|
38 #include "ov-int64.h" |
|
39 #include "ov-uint8.h" |
|
40 #include "ov-uint16.h" |
|
41 #include "ov-uint32.h" |
|
42 #include "ov-uint64.h" |
2928
|
43 #include "ov-typeinfo.h" |
|
44 #include "ops.h" |
|
45 #include "xdiv.h" |
|
46 #include "xpow.h" |
|
47 |
3203
|
48 // unary bool matrix ops. |
|
49 |
4550
|
50 DEFNDUNOP_OP (not, bool_matrix, bool_array, !) |
4965
|
51 DEFNDUNOP_OP (uplus, bool_matrix, array, +) |
|
52 DEFNDUNOP_OP (uminus, bool_matrix, array, -) |
3203
|
53 |
|
54 DEFUNOP (transpose, bool_matrix) |
|
55 { |
|
56 CAST_UNOP_ARG (const octave_bool_matrix&); |
|
57 |
4673
|
58 if (v.ndims () > 2) |
|
59 { |
|
60 error ("transpose not defined for N-d objects"); |
|
61 return octave_value (); |
|
62 } |
|
63 else |
|
64 return octave_value (v.bool_matrix_value().transpose ()); |
3203
|
65 } |
|
66 |
2928
|
67 // bool matrix by bool matrix ops. |
|
68 |
4550
|
69 DEFNDBINOP_FN (eq, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_eq) |
|
70 DEFNDBINOP_FN (ne, bool_matrix, bool_matrix, bool_array, bool_array, mx_el_ne) |
2928
|
71 |
4669
|
72 DEFNDBINOP_FN (el_and, bool_matrix, bool_matrix, bool_array, bool_array, |
|
73 mx_el_and) |
|
74 |
|
75 DEFNDBINOP_FN (el_or, bool_matrix, bool_matrix, bool_array, bool_array, |
|
76 mx_el_or) |
|
77 |
4964
|
78 DEFNDCATOP_FN (bm_bm, bool_matrix, bool_matrix, bool_array, bool_array, concat) |
4915
|
79 DEFNDCATOP_FN (bm_m, bool_matrix, matrix, array, array, concat) |
|
80 DEFNDCATOP_FN (m_bm, matrix, bool_matrix, array, array, concat) |
|
81 |
4686
|
82 DEFNDASSIGNOP_FN (assign, bool_matrix, bool_matrix, bool_array, assign) |
4669
|
83 |
5898
|
84 static octave_value |
|
85 oct_assignop_conv_and_assign (octave_base_value& a1, |
|
86 const octave_value_list& idx, |
|
87 const octave_base_value& a2) |
|
88 { |
|
89 octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1); |
|
90 |
|
91 // FIXME -- perhaps add a warning for this conversion if the values |
|
92 // are not all 0 or 1? |
|
93 |
5943
|
94 boolNDArray v2 = a2.bool_array_value (true); |
5898
|
95 |
|
96 if (! error_state) |
|
97 v1.assign (idx, v2); |
|
98 |
|
99 return octave_value (); |
|
100 } |
|
101 |
2928
|
102 void |
|
103 install_bm_bm_ops (void) |
|
104 { |
3538
|
105 INSTALL_UNOP (op_not, octave_bool_matrix, not); |
4965
|
106 INSTALL_UNOP (op_uplus, octave_bool_matrix, uplus); |
|
107 INSTALL_UNOP (op_uminus, octave_bool_matrix, uminus); |
3538
|
108 INSTALL_UNOP (op_transpose, octave_bool_matrix, transpose); |
|
109 INSTALL_UNOP (op_hermitian, octave_bool_matrix, transpose); |
3203
|
110 |
3538
|
111 INSTALL_BINOP (op_eq, octave_bool_matrix, octave_bool_matrix, eq); |
|
112 INSTALL_BINOP (op_ne, octave_bool_matrix, octave_bool_matrix, ne); |
4669
|
113 |
|
114 INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_bool_matrix, el_and); |
|
115 INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_bool_matrix, el_or); |
|
116 |
4915
|
117 INSTALL_CATOP (octave_bool_matrix, octave_bool_matrix, bm_bm); |
|
118 INSTALL_CATOP (octave_bool_matrix, octave_matrix, bm_m); |
|
119 INSTALL_CATOP (octave_matrix, octave_bool_matrix, m_bm); |
|
120 |
4669
|
121 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool_matrix, assign); |
5898
|
122 |
|
123 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_matrix, conv_and_assign); |
|
124 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_char_matrix_str, conv_and_assign); |
|
125 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_char_matrix_sq_str, conv_and_assign); |
|
126 |
|
127 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_range, conv_and_assign); |
|
128 |
|
129 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_sparse_matrix, conv_and_assign); |
|
130 |
|
131 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int8_matrix, conv_and_assign); |
|
132 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int16_matrix, conv_and_assign); |
|
133 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int32_matrix, conv_and_assign); |
|
134 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int64_matrix, conv_and_assign); |
|
135 |
|
136 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint8_matrix, conv_and_assign); |
|
137 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint16_matrix, conv_and_assign); |
|
138 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint32_matrix, conv_and_assign); |
|
139 INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint64_matrix, conv_and_assign); |
2928
|
140 } |
|
141 |
|
142 /* |
|
143 ;;; Local Variables: *** |
|
144 ;;; mode: C++ *** |
|
145 ;;; End: *** |
|
146 */ |