GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
boolMatrix.cc
Go to the documentation of this file.
1 // Matrix manipulations.
2 /*
3 
4 Copyright (C) 1996-2017 John W. Eaton
5 Copyright (C) 2009-2010 VZLU Prague, a.s.
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
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
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
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if defined (HAVE_CONFIG_H)
26 # include "config.h"
27 #endif
28 
29 #include <iostream>
30 
31 #include "Array-util.h"
32 #include "boolMatrix.h"
33 #include "lo-error.h"
34 #include "str-vec.h"
35 #include "mx-inlines.cc"
36 #include "mx-op-defs.h"
37 
38 // boolMatrix class.
39 
40 bool
42 {
43  if (rows () != a.rows () || cols () != a.cols ())
44  return 0;
45 
46  return mx_inline_equal (numel (), data (), a.data ());
47 }
48 
49 bool
51 {
52  return !(*this == a);
53 }
54 
57 {
58  Array<bool>::insert (a, r, c);
59  return *this;
60 }
61 
62 // unary operations
63 
66 {
67  octave_idx_type nr = rows ();
68  octave_idx_type nc = cols ();
69 
70  boolMatrix b (nr, nc);
71 
72  for (octave_idx_type j = 0; j < nc; j++)
73  for (octave_idx_type i = 0; i < nr; i++)
74  b.elem (i, j) = ! elem (i, j);
75 
76  return b;
77 }
78 
79 // other operations
80 
83 {
84  return Array<bool>::diag (k);
85 }
86 
89 SM_BOOL_OPS (bool, boolMatrix)
90 MM_CMP_OPS (boolMatrix, boolMatrix)
#define MM_BOOL_OPS(M1, M2)
Definition: mx-op-defs.h:212
boolMatrix diag(octave_idx_type k=0) const
Definition: boolMatrix.cc:82
bool operator==(const boolMatrix &a) const
Definition: boolMatrix.cc:41
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
#define SM_BOOL_OPS(S, M)
Definition: mx-op-defs.h:169
for large enough k
Definition: lu.cc:606
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2529
T & elem(octave_idx_type n)
Definition: Array.h:482
octave_idx_type rows(void) const
Definition: Array.h:401
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
Definition: Array.cc:1601
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
boolMatrix & insert(const boolMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: boolMatrix.cc:56
const bool * data(void) const
Definition: Array.h:582
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
b
Definition: cellfun.cc:398
#define MS_BOOL_OPS(M, S)
Definition: mx-op-defs.h:126
#define MM_CMP_OPS(M1, M2)
Definition: mx-op-defs.h:195
bool mx_inline_equal(size_t n, const T1 *x, const T2 *y)
Definition: mx-inlines.cc:532
octave_idx_type cols(void) const
Definition: Array.h:409
bool operator!=(const boolMatrix &a) const
Definition: boolMatrix.cc:50
boolMatrix operator!(void) const
Definition: boolMatrix.cc:65