GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
boolSparse.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1998-2025 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
39{
40public:
41
42 // Corresponding dense matrix type for this sparse matrix type.
44
46
49
51 : Sparse<bool> (r, c, val) { }
52
54 : Sparse<bool> (dv, nz) { }
55
57
59
61 : Sparse<bool> (a, dv) { }
62
63 explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
64
65 explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
66
67 explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { };
68
69 SparseBoolMatrix (const Array<bool>& a, const octave::idx_vector& r,
70 const octave::idx_vector& c, octave_idx_type nr = -1,
71 octave_idx_type nc = -1, bool sum_terms = true,
72 octave_idx_type nzm = -1)
73 : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { }
74
77
79 {
81 return *this;
82 }
83
84 ~SparseBoolMatrix () = default;
85
86 OCTAVE_API bool operator == (const SparseBoolMatrix& a) const;
87 OCTAVE_API bool operator != (const SparseBoolMatrix& a) const;
88
91
92 // destructive insert/delete/reorder operations
93
96
98 insert (const SparseBoolMatrix& a, const Array<octave_idx_type>& indx);
99
102
104
105 OCTAVE_API boolMatrix matrix_value () const;
106
108
110 index (const octave::idx_vector& i, bool resize_ok) const;
111
113 index (const octave::idx_vector& i, const octave::idx_vector& j,
114 bool resize_ok) const;
115
116 OCTAVE_API SparseBoolMatrix reshape (const dim_vector& new_dims) const;
117
119 permute (const Array<octave_idx_type>& vec, bool inv = false) const;
120
122 ipermute (const Array<octave_idx_type>& vec) const;
123
124 // unary operations
125
127
128 // other operations
129
130 OCTAVE_API SparseBoolMatrix all (int dim = -1) const;
131 OCTAVE_API SparseBoolMatrix any (int dim = -1) const;
132 OCTAVE_API SparseMatrix sum (int dim = -1) const;
133
134 // i/o
135
136 friend OCTAVE_API std::ostream& operator << (std::ostream& os,
137 const SparseBoolMatrix& a);
138 friend OCTAVE_API std::istream& operator >> (std::istream& is,
140};
141
144
147
150
151#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)
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
SparseBoolMatrix(const boolNDArray &a)
Definition boolSparse.h:65
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition boolSparse.h:47
SparseBoolMatrix(const Sparse< bool > &a)
Definition boolSparse.h:56
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition boolSparse.h:75
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition boolSparse.h:60
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition boolSparse.h:50
SparseBoolMatrix transpose() const
Definition boolSparse.h:89
SparseBoolMatrix(const boolMatrix &a)
Definition boolSparse.h:63
boolMatrix dense_matrix_type
Definition boolSparse.h:43
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:69
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition boolSparse.h:58
~SparseBoolMatrix()=default
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition boolSparse.h:53
SparseBoolMatrix(const PermMatrix &a)
Definition boolSparse.h:67
Sparse< T, Alloc > diag(octave_idx_type k=0) const
Definition Sparse.cc:2492
Sparse< T, Alloc > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition Sparse.cc:930
Sparse< T, Alloc > index(const octave::idx_vector &i, bool resize_ok=false) const
Definition Sparse.cc:1433
Sparse< T, Alloc > squeeze() const
Definition Sparse.h:370
Sparse< T, Alloc > & insert(const Sparse< T, Alloc > &a, octave_idx_type r, octave_idx_type c)
Definition Sparse.cc:1043
Sparse< T, Alloc > ipermute(const Array< octave_idx_type > &vec) const
Definition Sparse.h:542
Sparse< T, Alloc > & operator=(const Sparse< T, Alloc > &a)
Definition Sparse.cc:714
Sparse< T, Alloc > transpose() const
Definition Sparse.cc:1139
Sparse< T, Alloc > reshape(const dim_vector &new_dims) const
Definition Sparse.cc:847
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:532
bool operator==(const dim_vector &a, const dim_vector &b)
Definition dim-vector.h:516
#define OCTAVE_API
Definition main.in.cc:55
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition ov.h:1648