annotate src/OPERATORS/op-bm-bm.cc @ 7017:a1dbe9d80eee

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