GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
boolSparse.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1998-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_boolSparse_h)
27 #define octave_boolSparse_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MSparse.h"
32 #include "PermMatrix.h"
33 #include "Sparse-op-decls.h"
34 #include "Sparse.h"
35 #include "boolMatrix.h"
36 #include "boolNDArray.h"
37 
38 class SparseMatrix;
39 
40 class
41 OCTAVE_API
43 {
44 public:
45 
46  // Corresponding dense matrix type for this sparse matrix type.
48 
49  SparseBoolMatrix (void) : Sparse<bool> () { }
50 
52  : Sparse<bool> (r, c) { }
53 
55  : Sparse<bool> (r, c, val) { }
56 
58  : Sparse<bool> (dv, nz) { }
59 
60  SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { }
61 
62  SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { }
63 
65  : Sparse<bool> (a, dv) { }
66 
67  explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
68 
69  explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
70 
71  explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { };
72 
74  const idx_vector& c, octave_idx_type nr = -1,
75  octave_idx_type nc = -1, bool sum_terms = true,
76  octave_idx_type nzm = -1)
77  : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { }
78 
80  octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { }
81 
83  {
85  return *this;
86  }
87 
88  bool operator == (const SparseBoolMatrix& a) const;
89  bool operator != (const SparseBoolMatrix& a) const;
90 
92  { return Sparse<bool>::transpose (); }
93 
94  // destructive insert/delete/reorder operations
95 
98 
100  const Array<octave_idx_type>& indx);
101 
104 
105  SparseBoolMatrix diag (octave_idx_type k = 0) const;
106 
107  boolMatrix matrix_value (void) const;
108 
109  SparseBoolMatrix squeeze (void) const;
110 
111  SparseBoolMatrix index (const idx_vector& i, bool resize_ok) const;
112 
113  SparseBoolMatrix index (const idx_vector& i, const idx_vector& j,
114  bool resize_ok) const;
115 
116  SparseBoolMatrix reshape (const dim_vector& new_dims) const;
117 
119  bool inv = false) const;
120 
122 
123  // unary operations
124 
125  SparseBoolMatrix operator ! (void) const;
126 
127  // other operations
128 
129  SparseBoolMatrix all (int dim = -1) const;
130  SparseBoolMatrix any (int dim = -1) const;
131  SparseMatrix sum (int dim = -1) const;
132 
133  // i/o
134 
135  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
136  const SparseBoolMatrix& a);
137  friend OCTAVE_API std::istream& operator >> (std::istream& is,
138  SparseBoolMatrix& a);
139 };
140 
141 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
142 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
143 
144 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
145 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
146 
149 
150 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
#define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API)
#define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API)
#define SPARSE_SMS_BOOL_OP_DECLS(M, S, API)
#define SPARSE_SSM_BOOL_OP_DECLS(S, M, API)
#define SPARSE_SSM_EQNE_OP_DECLS(S, M, API)
#define SPARSE_SMS_EQNE_OP_DECLS(M, S, API)
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:281
SparseBoolMatrix transpose(void) const
Definition: boolSparse.h:91
SparseBoolMatrix(const boolNDArray &a)
Definition: boolSparse.h:69
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition: boolSparse.h:51
SparseBoolMatrix(const Sparse< bool > &a)
Definition: boolSparse.h:60
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: boolSparse.h:79
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition: boolSparse.h:64
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:73
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition: boolSparse.h:54
SparseBoolMatrix(const boolMatrix &a)
Definition: boolSparse.h:67
boolMatrix dense_matrix_type
Definition: boolSparse.h:47
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition: boolSparse.h:62
SparseBoolMatrix(void)
Definition: boolSparse.h:49
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition: boolSparse.h:57
SparseBoolMatrix(const PermMatrix &a)
Definition: boolSparse.h:71
SparseMatrix & insert(const SparseMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: dSparse.cc:171
SparseMatrix reshape(const dim_vector &new_dims) const
Definition: dSparse.cc:7519
SparseMatrix sum(int dim=-1) const
Definition: dSparse.cc:7435
SparseBoolMatrix any(int dim=-1) const
Definition: dSparse.cc:7405
SparseMatrix diag(octave_idx_type k=0) const
Definition: dSparse.cc:7472
SparseBoolMatrix all(int dim=-1) const
Definition: dSparse.cc:7399
Matrix matrix_value(void) const
Definition: dSparse.cc:7478
SparseMatrix permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: dSparse.cc:7525
SparseMatrix ipermute(const Array< octave_idx_type > &vec) const
Definition: dSparse.cc:7531
SparseMatrix & operator=(const SparseMatrix &a)
Definition: dSparse.h:96
SparseMatrix squeeze(void) const
Definition: dSparse.cc:7513
Sparse< T > transpose(void) const
Definition: Sparse.cc:1105
Sparse< T > index(const idx_vector &i, bool resize_ok=false) const
Definition: Sparse.cc:1393
Sparse< T > & operator=(const Sparse< T > &a)
Definition: Sparse.cc:702
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:601
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:585
T * r
Definition: mx-inlines.cc:773
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1536