GNU Octave  4.4.1
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) 2004-2018 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
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License 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 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_boolSparse_h)
25 #define octave_boolSparse_h 1
26 
27 #include "octave-config.h"
28 
29 #include "MSparse.h"
30 #include "PermMatrix.h"
31 #include "Sparse-op-decls.h"
32 #include "Sparse.h"
33 #include "boolMatrix.h"
34 #include "boolNDArray.h"
35 
36 class SparseMatrix;
37 
38 class
39 OCTAVE_API
41 {
42 public:
43 
44  // Corresponding dense matrix type for this sparse matrix type.
46 
47  SparseBoolMatrix (void) : Sparse<bool> () { }
48 
50  : Sparse<bool> (r, c) { }
51 
53  : Sparse<bool> (r, c, val) { }
54 
56  : Sparse<bool> (dv, nz) { }
57 
59 
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 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 
81  {
83  return *this;
84  }
85 
86  bool operator == (const SparseBoolMatrix& a) const;
87  bool operator != (const SparseBoolMatrix& a) const;
88 
90  { return Sparse<bool>::transpose (); }
91 
92  // destructive insert/delete/reorder operations
93 
96 
98  const Array<octave_idx_type>& indx);
99 
102 
104 
105  boolMatrix matrix_value (void) const;
106 
107  SparseBoolMatrix squeeze (void) const;
108 
109  SparseBoolMatrix index (const idx_vector& i, bool resize_ok) const;
110 
111  SparseBoolMatrix index (const idx_vector& i, const idx_vector& j,
112  bool resize_ok) const;
113 
114  SparseBoolMatrix reshape (const dim_vector& new_dims) const;
115 
117  bool inv = false) const;
118 
120 
121  // unary operations
122 
123  SparseBoolMatrix operator ! (void) const;
124 
125  // other operations
126 
127  SparseBoolMatrix all (int dim = -1) const;
128  SparseBoolMatrix any (int dim = -1) const;
129  SparseMatrix sum (int dim = -1) const;
130 
131  // i/o
132 
133  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
134  const SparseBoolMatrix& a);
135  friend OCTAVE_API std::istream& operator >> (std::istream& is,
137 };
138 
139 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
140 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
141 
142 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
143 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
144 
147 
148 #endif
#define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API)
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:566
const octave_base_value const Array< octave_idx_type > & ra_idx
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:47
Sparse< double > index(const idx_vector &i, bool resize_ok=false) const
Definition: Sparse.cc:1380
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: boolSparse.h:77
#define SPARSE_SSM_EQNE_OP_DECLS(S, M, API)
SparseMatrix sum(int dim=-1) const
Definition: dSparse.cc:7435
SparseBoolMatrix(const PermMatrix &a)
Definition: boolSparse.h:69
for large enough k
Definition: lu.cc:617
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition: boolSparse.h:52
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition: boolSparse.h:49
SparseMatrix & insert(const SparseMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: dSparse.cc:170
Sparse< T > transpose(void) const
Definition: Sparse.cc:1092
the second is matched to the second specifier and placed in the second column and so forth If there are more words than specifiers then the process is repeated until all words have been processed or the limit imposed by any(non-whitespace) text in the format that is not one of these specifiers is considered a literal. If there is a literal between two format specifiers then that same literal must appear in the input stream between the matching words. The following specifiers are valid
Definition: file-io.cc:1499
#define SPARSE_SMS_BOOL_OP_DECLS(M, S, API)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
SparseMatrix reshape(const dim_vector &new_dims) const
Definition: dSparse.cc:7519
SparseMatrix ipermute(const Array< octave_idx_type > &vec) const
Definition: dSparse.cc:7531
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
#define SPARSE_SSM_BOOL_OP_DECLS(S, M, API)
SparseBoolMatrix(const boolNDArray &a)
Definition: boolSparse.h:67
#define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API)
SparseMatrix squeeze(void) const
Definition: dSparse.cc:7513
SparseMatrix diag(octave_idx_type k=0) const
Definition: dSparse.cc:7472
Sparse< T > & operator=(const Sparse< T > &a)
Definition: Sparse.cc:695
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition: boolSparse.h:62
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:550
SparseBoolMatrix(const boolMatrix &a)
Definition: boolSparse.h:65
Matrix matrix_value(void) const
Definition: dSparse.cc:7478
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition: boolSparse.h:55
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
for i
Definition: data.cc:5264
octave_value operator!(const octave_value &a)
Definition: ov.h:1573
write the output to stdout if nargout is
Definition: load-save.cc:1612
SparseBoolMatrix(const Sparse< bool > &a)
Definition: boolSparse.h:58
SparseMatrix & operator=(const SparseMatrix &a)
Definition: dSparse.h:94
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
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:71
dim_vector dv
Definition: sub2ind.cc:263
SparseBoolMatrix transpose(void) const
Definition: boolSparse.h:89
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition: boolSparse.h:60
SparseMatrix permute(const Array< octave_idx_type > &vec, bool inv=false) const
Definition: dSparse.cc:7525
octave::stream os
Definition: file-io.cc:627
SparseBoolMatrix all(int dim=-1) const
Definition: dSparse.cc:7399
boolMatrix dense_matrix_type
Definition: boolSparse.h:45