GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
boolMatrix.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague, a.s.
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <iostream>
29 
30 #include "Array-util.h"
31 #include "boolMatrix.h"
32 #include "lo-error.h"
33 #include "str-vec.h"
34 #include "mx-inlines.cc"
35 #include "mx-op-defs.h"
36 
37 // boolMatrix class.
38 
39 bool
41 {
42  if (rows () != a.rows () || cols () != a.cols ())
43  return 0;
44 
45  return mx_inline_equal (numel (), data (), a.data ());
46 }
47 
48 bool
50 {
51  return !(*this == a);
52 }
53 
56 {
57  Array<bool>::insert (a, r, c);
58  return *this;
59 }
60 
61 // unary operations
62 
65 {
66  octave_idx_type nr = rows ();
67  octave_idx_type nc = cols ();
68 
69  boolMatrix b (nr, nc);
70 
71  for (octave_idx_type j = 0; j < nc; j++)
72  for (octave_idx_type i = 0; i < nr; i++)
73  b.elem (i, j) = ! elem (i, j);
74 
75  return b;
76 }
77 
78 // other operations
79 
82 {
83  return Array<bool>::diag (k);
84 }
85 
octave_idx_type rows(void) const
Definition: Array.h:404
#define MM_BOOL_OPS(M1, M2)
Definition: mx-op-defs.h:212
const bool * data(void) const
Definition: Array.h:582
#define SM_BOOL_OPS(S, M)
Definition: mx-op-defs.h:169
for large enough k
Definition: lu.cc:617
bool & elem(octave_idx_type n)
Definition: Array.h:488
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
octave_idx_type cols(void) const
Definition: Array.h:412
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:1583
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:400
boolMatrix & insert(const boolMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: boolMatrix.cc:55
boolMatrix diag(octave_idx_type k=0) const
Definition: boolMatrix.cc:81
boolMatrix operator!(void) const
Definition: boolMatrix.cc:64
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Definition: Array.cc:2530
b
Definition: cellfun.cc:400
#define MS_BOOL_OPS(M, S)
Definition: mx-op-defs.h:126
#define MM_CMP_OPS(M1, M2)
Definition: mx-op-defs.h:195
for i
Definition: data.cc:5264
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
bool mx_inline_equal(size_t n, const T1 *x, const T2 *y)
Definition: mx-inlines.cc:569
bool operator==(const boolMatrix &a) const
Definition: boolMatrix.cc:40
bool operator!=(const boolMatrix &a) const
Definition: boolMatrix.cc:49