Mercurial > hg > octave-lyh
annotate liboctave/array/boolMatrix.cc @ 17136:f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
* scripts/geometry/delaunay.m: check for equal size of X and Y, check for 2 column single matrix input, added 2 tests for these two changes
author | Andreas Weber <andreas.weber@hs-offenburg.de> |
---|---|
date | Thu, 01 Aug 2013 15:16:14 +0200 |
parents | 648dabbb4c6b |
children |
rev | line source |
---|---|
2828 | 1 // Matrix manipulations. |
2 /* | |
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 | 5 Copyright (C) 2009-2010 VZLU Prague, a.s. |
2828 | 6 |
7 This file is part of Octave. | |
8 | |
9 Octave is free software; you can redistribute it and/or modify it | |
10 under the terms of the GNU General Public License as published by the | |
7016 | 11 Free Software Foundation; either version 3 of the License, or (at your |
12 option) any later version. | |
2828 | 13 |
14 Octave is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
7016 | 20 along with Octave; see the file COPYING. If not, see |
21 <http://www.gnu.org/licenses/>. | |
2828 | 22 |
23 */ | |
24 | |
25 #ifdef HAVE_CONFIG_H | |
26 #include <config.h> | |
27 #endif | |
28 | |
3503 | 29 #include <iostream> |
2828 | 30 |
4669 | 31 #include "Array-util.h" |
2828 | 32 #include "lo-error.h" |
33 #include "str-vec.h" | |
34 #include "mx-base.h" | |
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 | 37 |
38 // boolMatrix class. | |
39 | |
40 bool | |
41 boolMatrix::operator == (const boolMatrix& a) const | |
42 { | |
43 if (rows () != a.rows () || cols () != a.cols ()) | |
44 return 0; | |
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 | 47 } |
48 | |
49 bool | |
50 boolMatrix::operator != (const boolMatrix& a) const | |
51 { | |
52 return !(*this == a); | |
53 } | |
54 | |
55 boolMatrix& | |
5275 | 56 boolMatrix::insert (const boolMatrix& a, octave_idx_type r, octave_idx_type c) |
2828 | 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 | 59 return *this; |
60 } | |
61 | |
3203 | 62 // unary operations |
63 | |
64 boolMatrix | |
65 boolMatrix::operator ! (void) const | |
66 { | |
5275 | 67 octave_idx_type nr = rows (); |
68 octave_idx_type nc = cols (); | |
3203 | 69 |
70 boolMatrix b (nr, nc); | |
71 | |
5275 | 72 for (octave_idx_type j = 0; j < nc; j++) |
73 for (octave_idx_type i = 0; i < nr; i++) | |
3203 | 74 b.elem (i, j) = ! elem (i, j); |
75 | |
76 return b; | |
77 } | |
78 | |
79 // other operations | |
80 | |
6979 | 81 boolMatrix |
82 boolMatrix::diag (octave_idx_type k) const | |
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 | 85 } |
86 | |
5775 | 87 // FIXME Do these really belong here? Maybe they should be |
4015 | 88 // in a base class? |
89 | |
2832 | 90 boolMatrix |
4015 | 91 boolMatrix::all (int dim) const |
2832 | 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 | 94 } |
95 | |
96 boolMatrix | |
4015 | 97 boolMatrix::any (int dim) const |
2832 | 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 | 100 } |
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) |