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 |
|
24 #if defined (__GNUG__) |
|
25 #pragma implementation |
|
26 #endif |
|
27 |
|
28 #ifdef HAVE_CONFIG_H |
|
29 #include <config.h> |
|
30 #endif |
|
31 |
3503
|
32 #include <iostream> |
2828
|
33 |
|
34 #include "lo-error.h" |
|
35 #include "str-vec.h" |
|
36 #include "mx-base.h" |
|
37 #include "mx-inlines.cc" |
|
38 |
|
39 // boolMatrix class. |
|
40 |
|
41 bool |
|
42 boolMatrix::operator == (const boolMatrix& a) const |
|
43 { |
|
44 if (rows () != a.rows () || cols () != a.cols ()) |
|
45 return 0; |
|
46 |
3769
|
47 return mx_inline_equal (data (), a.data (), length ()); |
2828
|
48 } |
|
49 |
|
50 bool |
|
51 boolMatrix::operator != (const boolMatrix& a) const |
|
52 { |
|
53 return !(*this == a); |
|
54 } |
|
55 |
|
56 boolMatrix& |
|
57 boolMatrix::insert (const boolMatrix& a, int r, int c) |
|
58 { |
|
59 Array2<bool>::insert (a, r, c); |
|
60 return *this; |
|
61 } |
|
62 |
3203
|
63 // unary operations |
|
64 |
|
65 boolMatrix |
|
66 boolMatrix::operator ! (void) const |
|
67 { |
|
68 int nr = rows (); |
|
69 int nc = cols (); |
|
70 |
|
71 boolMatrix b (nr, nc); |
|
72 |
|
73 for (int j = 0; j < nc; j++) |
|
74 for (int i = 0; i < nr; i++) |
|
75 b.elem (i, j) = ! elem (i, j); |
|
76 |
|
77 return b; |
|
78 } |
|
79 |
|
80 // other operations |
|
81 |
4015
|
82 // XXX FIXME XXX Do these really belong here? Maybe they should be |
|
83 // in a base class? |
|
84 |
2832
|
85 boolMatrix |
4015
|
86 boolMatrix::all (int dim) const |
2832
|
87 { |
4015
|
88 MX_ALL_OP (dim); |
2832
|
89 } |
|
90 |
|
91 boolMatrix |
4015
|
92 boolMatrix::any (int dim) const |
2832
|
93 { |
4015
|
94 MX_ANY_OP (dim); |
2832
|
95 } |
|
96 |
3685
|
97 MM_CMP_OPS(boolMatrix, , boolMatrix, ) |
|
98 |
2828
|
99 /* |
|
100 ;;; Local Variables: *** |
|
101 ;;; mode: C++ *** |
|
102 ;;; End: *** |
|
103 */ |