GNU Octave  4.0.0
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
boolSparse.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2015 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if !defined (octave_boolSparse_h)
25 #define octave_boolSparse_h 1
26 
27 #include "Sparse.h"
28 #include "MSparse-defs.h"
29 
30 #include "boolMatrix.h"
31 #include "boolNDArray.h"
32 #include "PermMatrix.h"
33 
34 #include "Sparse-op-decls.h"
35 
36 class SparseMatrix;
37 
38 class
39 OCTAVE_API
41 {
42 public:
43 
44  SparseBoolMatrix (void) : Sparse<bool> () { }
45 
47  : Sparse<bool> (r, c) { }
48 
50  : Sparse<bool> (r, c, val) { }
51 
53  : Sparse<bool> (dv, nz) { }
54 
55  SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { }
56 
58 
60  : Sparse<bool> (a, dv) { }
61 
62  explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
63 
64  explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
65 
66  explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { };
67 
69  const idx_vector& c, octave_idx_type nr = -1,
70  octave_idx_type nc = -1, bool sum_terms = true,
71  octave_idx_type nzm = -1)
72  : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { }
73 
75  octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { }
76 
78  {
80  return *this;
81  }
82 
83  bool operator == (const SparseBoolMatrix& a) const;
84  bool operator != (const SparseBoolMatrix& a) const;
85 
87  { return Sparse<bool>::transpose (); }
88 
89  // destructive insert/delete/reorder operations
90 
93 
95  const Array<octave_idx_type>& indx);
96 
99 
100  SparseBoolMatrix diag (octave_idx_type k = 0) const;
101 
102  boolMatrix matrix_value (void) const;
103 
104  SparseBoolMatrix squeeze (void) const;
105 
106  SparseBoolMatrix index (const idx_vector& i, bool resize_ok) const;
107 
108  SparseBoolMatrix index (const idx_vector& i, const idx_vector& j,
109  bool resize_ok) const;
110 
111  SparseBoolMatrix reshape (const dim_vector& new_dims) const;
112 
114  bool inv = false) const;
115 
117 
118  // unary operations
119 
120  SparseBoolMatrix operator ! (void) const;
121 
122  // other operations
123 
124  SparseBoolMatrix all (int dim = -1) const;
125  SparseBoolMatrix any (int dim = -1) const;
126  SparseMatrix sum (int dim = -1) const;
127 
128  // i/o
129 
130  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
131  const SparseBoolMatrix& a);
132  friend OCTAVE_API std::istream& operator >> (std::istream& is,
133  SparseBoolMatrix& a);
134 };
135 
136 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
137 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
138 
139 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
140 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
141 
142 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
143 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
144 
145 #endif
SparseMatrix reshape(const dim_vector &new_dims) const
Definition: dSparse.cc:7541
#define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API)
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:548
const octave_base_value const Array< octave_idx_type > & ra_idx
Sparse< T > & operator=(const Sparse< T > &a)
Definition: Sparse.cc:683
SparseBoolMatrix all(int dim=-1) const
Definition: dSparse.cc:7421
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
#define SPARSE_SMS_EQNE_OP_DECLS(M, S, API)
SparseBoolMatrix(void)
Definition: boolSparse.h:44
SparseMatrix sum(int dim=-1) const
Definition: dSparse.cc:7457
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: boolSparse.h:74
#define SPARSE_SSM_EQNE_OP_DECLS(S, M, API)
SparseBoolMatrix(const PermMatrix &a)
Definition: boolSparse.h:66
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition: boolSparse.h:49
SparseMatrix ipermute(const Array< octave_idx_type > &vec) const
Definition: dSparse.cc:7553
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:664
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition: boolSparse.h:46
Sparse< double > index(const idx_vector &i, bool resize_ok=false) const
SparseMatrix & insert(const SparseMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: dSparse.cc:257
SparseBoolMatrix transpose(void) const
Definition: boolSparse.h:86
#define SPARSE_SMS_BOOL_OP_DECLS(M, S, API)
#define SPARSE_SSM_BOOL_OP_DECLS(S, M, API)
Matrix matrix_value(void) const
Definition: dSparse.cc:7500
SparseBoolMatrix(const boolNDArray &a)
Definition: boolSparse.h:64
#define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API)
SparseMatrix diag(octave_idx_type k=0) const
Definition: dSparse.cc:7494
SparseBoolMatrix any(int dim=-1) const
Definition: dSparse.cc:7427
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition: boolSparse.h:59
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:519
SparseBoolMatrix(const boolMatrix &a)
Definition: boolSparse.h:62
SparseMatrix squeeze(void) const
Definition: dSparse.cc:7535
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition: boolSparse.h:52
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
SparseMatrix permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: dSparse.cc:7547
octave_value operator!(const octave_value &a)
Definition: ov.h:1293
SparseBoolMatrix(const Sparse< bool > &a)
Definition: boolSparse.h:55
SparseMatrix & operator=(const SparseMatrix &a)
Definition: dSparse.h:93
SparseBoolMatrix(const Array< bool > &a, const idx_vector &r, const idx_vector &c, octave_idx_type nr=-1, octave_idx_type nc=-1, bool sum_terms=true, octave_idx_type nzm=-1)
Definition: boolSparse.h:68
Sparse< T > transpose(void) const
Definition: Sparse.cc:1096
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition: boolSparse.h:57