Mercurial > hg > octave-lyh
annotate liboctave/boolMatrix.cc @ 10485:b4e14e628fc9
Truncate argv() for scripts used without command line parameters. Bug #29423
author | Judd Storrs <jstorrs@gmail.com> |
---|---|
date | Fri, 02 Apr 2010 13:28:02 -0400 |
parents | b47ab50a6aa8 |
children | 4d1fc073fbb7 |
rev | line source |
---|---|
2828 | 1 // Matrix manipulations. |
2 /* | |
3 | |
7017 | 4 Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, |
8920 | 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 | 7 |
8 This file is part of Octave. | |
9 | |
10 Octave is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
7016 | 12 Free Software Foundation; either version 3 of the License, or (at your |
13 option) any later version. | |
2828 | 14 |
15 Octave is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
7016 | 21 along with Octave; see the file COPYING. If not, see |
22 <http://www.gnu.org/licenses/>. | |
2828 | 23 |
24 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
3503 | 30 #include <iostream> |
2828 | 31 |
4669 | 32 #include "Array-util.h" |
2828 | 33 #include "lo-error.h" |
34 #include "str-vec.h" | |
35 #include "mx-base.h" | |
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 | 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 | |
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 | 48 } |
49 | |
50 bool | |
51 boolMatrix::operator != (const boolMatrix& a) const | |
52 { | |
53 return !(*this == a); | |
54 } | |
55 | |
56 boolMatrix& | |
5275 | 57 boolMatrix::insert (const boolMatrix& a, octave_idx_type r, octave_idx_type c) |
2828 | 58 { |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
59 Array<bool>::insert (a, r, c); |
2828 | 60 return *this; |
61 } | |
62 | |
3203 | 63 // unary operations |
64 | |
65 boolMatrix | |
66 boolMatrix::operator ! (void) const | |
67 { | |
5275 | 68 octave_idx_type nr = rows (); |
69 octave_idx_type nc = cols (); | |
3203 | 70 |
71 boolMatrix b (nr, nc); | |
72 | |
5275 | 73 for (octave_idx_type j = 0; j < nc; j++) |
74 for (octave_idx_type i = 0; i < nr; i++) | |
3203 | 75 b.elem (i, j) = ! elem (i, j); |
76 | |
77 return b; | |
78 } | |
79 | |
80 // other operations | |
81 | |
6979 | 82 boolMatrix |
83 boolMatrix::diag (octave_idx_type k) const | |
84 { | |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10158
diff
changeset
|
85 return Array<bool>::diag (k); |
6979 | 86 } |
87 | |
5775 | 88 // FIXME Do these really belong here? Maybe they should be |
4015 | 89 // in a base class? |
90 | |
2832 | 91 boolMatrix |
4015 | 92 boolMatrix::all (int dim) const |
2832 | 93 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10351
diff
changeset
|
94 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_all); |
2832 | 95 } |
96 | |
97 boolMatrix | |
4015 | 98 boolMatrix::any (int dim) const |
2832 | 99 { |
10362
b47ab50a6aa8
simplify appliers in mx-inlines.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10351
diff
changeset
|
100 return do_mx_red_op<bool, bool> (*this, dim, mx_inline_any); |
2832 | 101 } |
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) |