annotate liboctave/boolMatrix.cc @ 14204:704f7895eef0 stable release-3-6-0 release-3.6.0

Version 3.6.0 released. * configure.ac (AC_INIT): Version is now 3.6.0. (OCTAVE_API_VERSION_NUMBER): Now 48. (OCTAVE_RELEASE_DATE): Now 2012-01-15.
author John W. Eaton <jwe@octave.org>
date Sun, 15 Jan 2012 13:02:42 -0500
parents 72c96de7a403
children
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
4 Copyright (C) 1996-2012 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10521
diff changeset
5 Copyright (C) 2009-2010 VZLU Prague, a.s.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
6
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
7 This file is part of Octave.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
8
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
9 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
10 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
11 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
12 option) any later version.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
13
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
14 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
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
16 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
17 for more details.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
18
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
19 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
20 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
21 <http://www.gnu.org/licenses/>.
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
22
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 #ifdef HAVE_CONFIG_H
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
26 #include <config.h>
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
27 #endif
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
28
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3225
diff changeset
29 #include <iostream>
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
30
4669
334a27c8f453 [project @ 2003-11-26 07:02:42 by jwe]
jwe
parents: 4543
diff changeset
31 #include "Array-util.h"
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
32 #include "lo-error.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
33 #include "str-vec.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
34 #include "mx-base.h"
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
35 #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
36 #include "mx-op-defs.h"
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
37
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
38 // boolMatrix class.
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
39
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
40 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
41 boolMatrix::operator == (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
42 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
43 if (rows () != a.rows () || cols () != a.cols ())
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
44 return 0;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
45
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
46 return mx_inline_equal (length (), data (), a.data ());
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
47 }
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 bool
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
50 boolMatrix::operator != (const boolMatrix& a) const
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
51 {
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
52 return !(*this == a);
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
53 }
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 boolMatrix&
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
56 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
57 {
10351
5150ceb4dbb4 base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
58 Array<bool>::insert (a, r, c);
2828
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
59 return *this;
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
60 }
92826d6e8bd9 [project @ 1997-03-25 23:41:41 by jwe]
jwe
parents:
diff changeset
61
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
62 // unary operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
63
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
64 boolMatrix
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
65 boolMatrix::operator ! (void) const
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
66 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
67 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
68 octave_idx_type nc = cols ();
3203
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
69
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
70 boolMatrix b (nr, nc);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
71
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
72 for (octave_idx_type j = 0; j < nc; j++)
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
73 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
74 b.elem (i, j) = ! elem (i, j);
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
75
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
76 return b;
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
77 }
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 // other operations
bc61b0e8d60e [project @ 1998-10-30 20:26:27 by jwe]
jwe
parents: 2847
diff changeset
80
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
81 boolMatrix
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
82 boolMatrix::diag (octave_idx_type k) const
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
83 {
10351
5150ceb4dbb4 base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
84 return Array<bool>::diag (k);
6979
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
85 }
2883ea1c5c18 [project @ 2007-10-08 20:23:48 by dbateman]
dbateman
parents: 5775
diff changeset
86
5775
ace8d8d26933 [project @ 2006-04-24 19:13:06 by jwe]
jwe
parents: 5307
diff changeset
87 // 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
88 // in a base class?
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
89
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
90 boolMatrix
4015
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
91 boolMatrix::all (int dim) const
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
92 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10351
diff changeset
93 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_all);
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
94 }
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 boolMatrix
4015
6476dd85a65f [project @ 2002-08-02 07:59:19 by jwe]
jwe
parents: 3769
diff changeset
97 boolMatrix::any (int dim) const
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
98 {
10362
b47ab50a6aa8 simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents: 10351
diff changeset
99 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_any);
2832
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
100 }
4dff308e9acc [project @ 1997-03-26 05:16:58 by jwe]
jwe
parents: 2828
diff changeset
101
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
102 MM_BOOL_OPS (boolMatrix, boolMatrix)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
103 MS_BOOL_OPS (boolMatrix, bool)
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
104 SM_BOOL_OPS (bool, boolMatrix)
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9550
diff changeset
105 MM_CMP_OPS (boolMatrix, boolMatrix)