GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
array
boolMatrix.cc
Go to the documentation of this file.
1
// Matrix manipulations.
2
/*
3
4
Copyright (C) 1996-2013 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
#ifdef HAVE_CONFIG_H
26
#include <config.h>
27
#endif
28
29
#include <iostream>
30
31
#include "
Array-util.h
"
32
#include "
lo-error.h
"
33
#include "
str-vec.h
"
34
#include "
mx-base.h
"
35
#include "
mx-inlines.cc
"
36
#include "
mx-op-defs.h
"
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
46
return
mx_inline_equal
(
length
(),
data
(), a.
data
());
47
}
48
49
bool
50
boolMatrix::operator !=
(
const
boolMatrix
& a)
const
51
{
52
return
!(*
this
== a);
53
}
54
55
boolMatrix
&
56
boolMatrix::insert
(
const
boolMatrix
& a,
octave_idx_type
r,
octave_idx_type
c)
57
{
58
Array<bool>::insert
(a, r, c);
59
return
*
this
;
60
}
61
62
// unary operations
63
64
boolMatrix
65
boolMatrix::operator !
(
void
)
const
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
81
boolMatrix
82
boolMatrix::diag
(
octave_idx_type
k)
const
83
{
84
return
Array<bool>::diag
(k);
85
}
86
87
// FIXME: Do these really belong here? Maybe they should be in a base class?
88
89
boolMatrix
90
boolMatrix::all
(
int
dim)
const
91
{
92
return
do_mx_red_op<bool, bool> (*
this
, dim,
mx_inline_all
);
93
}
94
95
boolMatrix
96
boolMatrix::any
(
int
dim)
const
97
{
98
return
do_mx_red_op<bool, bool> (*
this
, dim,
mx_inline_any
);
99
}
100
101
MM_BOOL_OPS
(
boolMatrix
,
boolMatrix
)
102
MS_BOOL_OPS
(
boolMatrix
,
bool
)
103
SM_BOOL_OPS
(
bool
, boolMatrix)
104
MM_CMP_OPS
(boolMatrix, boolMatrix)
Generated on Mon Dec 30 2013 03:04:39 for GNU Octave by
1.8.1.2