GNU Octave  3.8.0
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
ov-bool-sparse.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2013 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_ov_bool_sparse_h)
25 #define octave_ov_bool_sparse_h 1
26 
27 #include <cstdlib>
28 
29 #include <iosfwd>
30 #include <string>
31 
32 #include "mx-base.h"
33 #include "oct-alloc.h"
34 #include "str-vec.h"
35 
36 #include "error.h"
37 #include "oct-stream.h"
38 #include "ov-base.h"
39 #include "ov-typeinfo.h"
40 
41 #include "boolSparse.h"
42 #include "ov-base-sparse.h"
43 #include "ov-re-sparse.h"
44 
45 class octave_value_list;
46 
47 class tree_walker;
48 
49 class
52 {
53 public:
54 
57 
60 
62  const MatrixType& t)
63  : octave_base_sparse<SparseBoolMatrix> (bnda, t) { }
64 
67 
70 
73 
76 
78 
79  octave_base_value *clone (void) const
80  { return new octave_sparse_bool_matrix (*this); }
81  octave_base_value *empty_clone (void) const
82  { return new octave_sparse_bool_matrix (); }
83 
84  type_conv_info numeric_conversion_function (void) const;
85 
86  octave_base_value *try_narrowing_conversion (void);
87 
88  // FIXME Adapt idx_vector to allow sparse logical indexing without overflow!!
89  idx_vector index_vector (void) const
90  { return idx_vector (matrix); }
91 
92  builtin_type_t builtin_type (void) const { return btyp_bool; }
93 
94  bool is_bool_matrix (void) const { return true; }
95 
96  bool is_bool_type (void) const { return true; }
97 
98  bool is_real_type (void) const { return true; }
99 
100  bool is_numeric_type (void) const { return false; }
101 
102  double double_value (bool = false) const;
103 
104  double scalar_value (bool frc_str_conv = false) const
105  { return double_value (frc_str_conv); }
106 
107  Matrix matrix_value (bool = false) const;
108 
109  NDArray array_value (bool = false) const;
110 
111  Complex complex_value (bool = false) const;
112 
113  ComplexMatrix complex_matrix_value (bool = false) const;
114 
115  ComplexNDArray complex_array_value (bool = false) const;
116 
117  charNDArray char_array_value (bool = false) const;
118 
119  boolMatrix bool_matrix_value (bool = false) const;
120 
121  boolNDArray bool_array_value (bool = false) const;
122 
123  SparseMatrix sparse_matrix_value (bool = false) const;
124 
125  SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
126 
127  SparseBoolMatrix sparse_bool_matrix_value (bool = false) const
128  { return matrix; }
129 
130  octave_value convert_to_str_internal (bool pad, bool force, char type) const;
131 
132  bool save_binary (std::ostream& os, bool& save_as_floats);
133 
134  bool load_binary (std::istream& is, bool swap,
136 
137 #if defined (HAVE_HDF5)
138  bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats);
139 
140  bool load_hdf5 (hid_t loc_id, const char *name);
141 #endif
142 
143  mxArray *as_mxArray (void) const;
144 
145  // Mapper functions are converted to double for treatment
146  octave_value map (unary_mapper_t umap) const
147  {
148  octave_sparse_matrix m (sparse_matrix_value ());
149  return m.map (umap);
150  }
151 
152 protected:
153 
155 
157 };
158 
159 #endif