annotate liboctave/boolMatrix.cc @ 10158:4c0cdbe0acca

remove Emacs local-variable settings from liboctave source files
author John W. Eaton <jwe@octave.org>
date Wed, 20 Jan 2010 19:04:35 -0500
parents a9b37bae1802
children 5150ceb4dbb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
1 // Matrix manipulations.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
2 /*
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
3
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
4 Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8774
diff changeset
5 2006, 2007, 2008, 2009 John W. Eaton
9601
a9b37bae1802 add a couple of missing copyright statements
Jaroslav Hajek <highegg@gmail.com>
parents: 9578
diff changeset
6 Copyright (C) 2009 VZLU Prague, a.s.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
7
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
8 This file is part of Octave.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
9
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
10 Octave is free software; you can redistribute it and/or modify it
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
11 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: 6979
diff changeset
12 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6979
diff changeset
13 option) any later version.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
14
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
15 Octave is distributed in the hope that it will be useful, but WITHOUT
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
18 for more details.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
19
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
20 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: 6979
diff changeset
21 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6979
diff changeset
22 <http://www.gnu.org/licenses/>.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
23
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
24 */
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
25
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
27 #include <config.h>
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
28 #endif
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
29
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3225
diff changeset
30 #include <iostream>
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
31
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4543
diff changeset
32 #include "Array-util.h"
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
33 #include "lo-error.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
34 #include "str-vec.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
35 #include "mx-base.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
36 #include "mx-inlines.cc"
8774
b756ce0002db split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
37 #include "mx-op-defs.h"
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
38
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
39 // boolMatrix class.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
40
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
41 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
42 boolMatrix::operator == (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
43 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
44 if (rows () != a.rows () || cols () != a.cols ())
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
45 return 0;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
46
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
47 return mx_inline_equal (length (), data (), a.data ());
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
48 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
49
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
50 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
51 boolMatrix::operator != (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
52 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
53 return !(*this == a);
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
54 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
55
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
56 boolMatrix&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
57 boolMatrix::insert (const boolMatrix& a, octave_idx_type r, octave_idx_type c)
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
58 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
59 Array2<bool>::insert (a, r, c);
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
60 return *this;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
61 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
62
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
63 // unary operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
64
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
65 boolMatrix
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
66 boolMatrix::operator ! (void) const
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
67 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
68 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
69 octave_idx_type nc = cols ();
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
70
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
71 boolMatrix b (nr, nc);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
72
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
73 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
74 for (octave_idx_type i = 0; i < nr; i++)
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
75 b.elem (i, j) = ! elem (i, j);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
76
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
77 return b;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
78 }
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
79
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
80 // other operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
81
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
82 boolMatrix
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
83 boolMatrix::diag (octave_idx_type k) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
84 {
7620
36594d5bbe13 Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
85 return Array2<bool>::diag (k);
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
86 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
87
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5307
diff changeset
88 // FIXME Do these really belong here? Maybe they should be
4015
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
89 // in a base class?
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
90
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
91 boolMatrix
4015
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
92 boolMatrix::all (int dim) const
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
93 {
9227
8145f2255276 use explicit template qualifs to please Intel C++ and MSVC++
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
94 return do_mx_red_op<boolMatrix, bool> (*this, dim, mx_inline_all);
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
95 }
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
96
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
97 boolMatrix
4015
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
98 boolMatrix::any (int dim) const
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
99 {
9227
8145f2255276 use explicit template qualifs to please Intel C++ and MSVC++
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
100 return do_mx_red_op<boolMatrix, bool> (*this, dim, mx_inline_any);
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
101 }
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
102
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
103 MM_BOOL_OPS (boolMatrix, boolMatrix)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
104 MS_BOOL_OPS (boolMatrix, bool)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
105 SM_BOOL_OPS (bool, boolMatrix)
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
106 MM_CMP_OPS (boolMatrix, boolMatrix)