2828
|
1 // Matrix manipulations. |
|
2 /* |
|
3 |
2847
|
4 Copyright (C) 1996, 1997 John W. Eaton |
2828
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
4192
|
24 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
2828
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include <config.h> |
|
30 #endif |
|
31 |
3503
|
32 #include <iostream> |
2828
|
33 |
4669
|
34 #include "Array-util.h" |
2828
|
35 #include "lo-error.h" |
|
36 #include "str-vec.h" |
|
37 #include "mx-base.h" |
|
38 #include "mx-inlines.cc" |
|
39 |
|
40 // boolMatrix class. |
|
41 |
|
42 bool |
|
43 boolMatrix::operator == (const boolMatrix& a) const |
|
44 { |
|
45 if (rows () != a.rows () || cols () != a.cols ()) |
|
46 return 0; |
|
47 |
3769
|
48 return mx_inline_equal (data (), a.data (), length ()); |
2828
|
49 } |
|
50 |
|
51 bool |
|
52 boolMatrix::operator != (const boolMatrix& a) const |
|
53 { |
|
54 return !(*this == a); |
|
55 } |
|
56 |
|
57 boolMatrix& |
|
58 boolMatrix::insert (const boolMatrix& a, int r, int c) |
|
59 { |
|
60 Array2<bool>::insert (a, r, c); |
|
61 return *this; |
|
62 } |
|
63 |
3203
|
64 // unary operations |
|
65 |
|
66 boolMatrix |
|
67 boolMatrix::operator ! (void) const |
|
68 { |
|
69 int nr = rows (); |
|
70 int nc = cols (); |
|
71 |
|
72 boolMatrix b (nr, nc); |
|
73 |
|
74 for (int j = 0; j < nc; j++) |
|
75 for (int i = 0; i < nr; i++) |
|
76 b.elem (i, j) = ! elem (i, j); |
|
77 |
|
78 return b; |
|
79 } |
|
80 |
|
81 // other operations |
|
82 |
4015
|
83 // XXX FIXME XXX Do these really belong here? Maybe they should be |
|
84 // in a base class? |
|
85 |
2832
|
86 boolMatrix |
4015
|
87 boolMatrix::all (int dim) const |
2832
|
88 { |
4015
|
89 MX_ALL_OP (dim); |
2832
|
90 } |
|
91 |
|
92 boolMatrix |
4015
|
93 boolMatrix::any (int dim) const |
2832
|
94 { |
4015
|
95 MX_ANY_OP (dim); |
2832
|
96 } |
|
97 |
4543
|
98 MM_CMP_OPS (boolMatrix, , boolMatrix, ) |
3685
|
99 |
2828
|
100 /* |
|
101 ;;; Local Variables: *** |
|
102 ;;; mode: C++ *** |
|
103 ;;; End: *** |
|
104 */ |