GNU Octave  4.2.1
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-2017 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 "octave-config.h"
28 
29 #include "Sparse.h"
30 #include "MSparse.h"
31 
32 #include "boolMatrix.h"
33 #include "boolNDArray.h"
34 #include "PermMatrix.h"
35 
36 #include "Sparse-op-decls.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 
61 
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 
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,
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 
147 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
148 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
149 
150 #endif
SparseMatrix reshape(const dim_vector &new_dims) const
Definition: dSparse.cc:7477
#define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API)
bool operator!=(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:567
const octave_base_value const Array< octave_idx_type > & ra_idx
Sparse< T > & operator=(const Sparse< T > &a)
Definition: Sparse.cc:692
SparseBoolMatrix all(int dim=-1) const
Definition: dSparse.cc:7357
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:49
SparseMatrix sum(int dim=-1) const
Definition: dSparse.cc:7393
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Definition: boolSparse.h:79
#define SPARSE_SSM_EQNE_OP_DECLS(S, M, API)
SparseBoolMatrix(const PermMatrix &a)
Definition: boolSparse.h:71
for large enough k
Definition: lu.cc:606
SparseBoolMatrix(octave_idx_type r, octave_idx_type c, bool val)
Definition: boolSparse.h:54
SparseMatrix ipermute(const Array< octave_idx_type > &vec) const
Definition: dSparse.cc:7489
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:655
SparseBoolMatrix(octave_idx_type r, octave_idx_type c)
Definition: boolSparse.h:51
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:174
SparseBoolMatrix transpose(void) const
Definition: boolSparse.h:91
#define SPARSE_SMS_BOOL_OP_DECLS(M, S, API)
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:398
#define SPARSE_SSM_BOOL_OP_DECLS(S, M, API)
Matrix matrix_value(void) const
Definition: dSparse.cc:7436
SparseBoolMatrix(const boolNDArray &a)
Definition: boolSparse.h:69
#define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API)
SparseMatrix diag(octave_idx_type k=0) const
Definition: dSparse.cc:7430
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
SparseBoolMatrix(const SparseBoolMatrix &a, const dim_vector &dv)
Definition: boolSparse.h:64
bool operator==(const dim_vector &a, const dim_vector &b)
Definition: dim-vector.h:538
SparseBoolMatrix(const boolMatrix &a)
Definition: boolSparse.h:67
SparseMatrix squeeze(void) const
Definition: dSparse.cc:7471
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
SparseBoolMatrix(const dim_vector &dv, octave_idx_type nz=0)
Definition: boolSparse.h:57
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:7483
octave_value operator!(const octave_value &a)
Definition: ov.h:1484
write the output to stdout if nargout is
Definition: load-save.cc:1576
SparseBoolMatrix(const Sparse< bool > &a)
Definition: boolSparse.h:60
SparseMatrix & operator=(const SparseMatrix &a)
Definition: dSparse.h:97
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
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:1491
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
Sparse< T > transpose(void) const
Definition: Sparse.cc:1090
dim_vector dv
Definition: sub2ind.cc:263
SparseBoolMatrix(const SparseBoolMatrix &a)
Definition: boolSparse.h:62
boolMatrix dense_matrix_type
Definition: boolSparse.h:47