GNU Octave  9.1.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-2024 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 "PermMatrix.h"
32 #include "Sparse-op-decls.h"
33 #include "Sparse.h"
34 #include "boolMatrix.h"
35 #include "boolNDArray.h"
36 #include "mx-fwd.h"
37 
38 class
41 {
42 public:
43 
44  // Corresponding dense matrix type for this sparse matrix type.
46 
47  SparseBoolMatrix () : Sparse<bool> () { }
48 
50  : Sparse<bool> (r, c) { }
51 
53  : Sparse<bool> (r, c, val) { }
54 
56  : Sparse<bool> (dv, nz) { }
57 
58  SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { }
59 
60  SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { }
61 
63  : Sparse<bool> (a, dv) { }
64 
65  explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
66 
67  explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
68 
69  explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { };
70 
72  const octave::idx_vector& c, octave_idx_type nr = -1,
73  octave_idx_type nc = -1, bool sum_terms = true,
74  octave_idx_type nzm = -1)
75  : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { }
76 
78  octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { }
79 
80  SparseBoolMatrix& operator = (const SparseBoolMatrix& a)
81  {
83  return *this;
84  }
85 
86  ~SparseBoolMatrix () = default;
87 
88  OCTAVE_API bool operator == (const SparseBoolMatrix& a) const;
89  OCTAVE_API bool operator != (const SparseBoolMatrix& a) const;
90 
92  { return Sparse<bool>::transpose (); }
93 
94  // destructive insert/delete/reorder operations
95 
97  insert (const SparseBoolMatrix& a, octave_idx_type r, octave_idx_type c);
98 
100  insert (const SparseBoolMatrix& a, const Array<octave_idx_type>& indx);
101 
104 
105  OCTAVE_API SparseBoolMatrix diag (octave_idx_type k = 0) const;
106 
107  OCTAVE_API boolMatrix matrix_value () const;
108 
109  OCTAVE_API SparseBoolMatrix squeeze () const;
110 
112  index (const octave::idx_vector& i, bool resize_ok) const;
113 
115  index (const octave::idx_vector& i, const octave::idx_vector& j,
116  bool resize_ok) const;
117 
118  OCTAVE_API SparseBoolMatrix reshape (const dim_vector& new_dims) const;
119 
121  permute (const Array<octave_idx_type>& vec, bool inv = false) const;
122 
124  ipermute (const Array<octave_idx_type>& vec) const;
125 
126  // unary operations
127 
129 
130  // other operations
131 
132  OCTAVE_API SparseBoolMatrix all (int dim = -1) const;
133  OCTAVE_API SparseBoolMatrix any (int dim = -1) const;
134  OCTAVE_API SparseMatrix sum (int dim = -1) const;
135 
136  // i/o
137 
138  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
139  const SparseBoolMatrix& a);
140  friend OCTAVE_API std::istream& operator >> (std::istream& is,
141  SparseBoolMatrix& a);
142 };
143 
146 
149 
152 
153 #endif
template 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:279
SparseBoolMatrix(const boolNDArray &a)
Definition: boolSparse.h:67
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition: boolSparse.h:49
SparseBoolMatrix(const Sparse< bool > &a)
Definition: boolSparse.h:58
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: boolSparse.h:77
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition: boolSparse.h:62
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition: boolSparse.h:52
SparseBoolMatrix transpose() const
Definition: boolSparse.h:91
SparseBoolMatrix(const boolMatrix &a)
Definition: boolSparse.h:65
boolMatrix dense_matrix_type
Definition: boolSparse.h:45
SparseBoolMatrix(const Array< bool > &a, const octave::idx_vector &r, const octave::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:71
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition: boolSparse.h:60
~SparseBoolMatrix()=default
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition: boolSparse.h:55
SparseBoolMatrix(const PermMatrix &a)
Definition: boolSparse.h:69
Sparse< T, Alloc > & operator=(const Sparse< T, Alloc > &a)
Definition: Sparse.cc:715
Sparse< T, Alloc > transpose() const
Definition: Sparse.cc:1140
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:536
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:520
octave::idx_vector idx_vector
Definition: idx-vector.h:1022
#define OCTAVE_API
Definition: main.cc:55
T * r
Definition: mx-inlines.cc:781
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1633