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