Mercurial > hg > octave-nkf
annotate src/ov-bool-mat.h @ 10313:f3b65e1ae355
untabify src header files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:16:43 -0500 |
parents | cd96d29c5efa |
children | 5150ceb4dbb4 |
rev | line source |
---|---|
2871 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 John W. Eaton |
2871 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2871 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2871 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_bool_matrix_h) | |
25 #define octave_bool_matrix_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
29 #include <iosfwd> |
2871 | 30 #include <string> |
31 | |
32 #include "mx-base.h" | |
33 #include "oct-alloc.h" | |
34 | |
35 #include "error.h" | |
4970 | 36 #include "oct-stream.h" |
2871 | 37 #include "ov-base.h" |
3219 | 38 #include "ov-base-mat.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
39 #include "ov-re-mat.h" |
2871 | 40 #include "ov-typeinfo.h" |
41 | |
5785 | 42 #include "MatrixType.h" |
43 | |
2871 | 44 class Octave_map; |
45 class octave_value_list; | |
46 | |
47 class tree_walker; | |
48 | |
49 // Character matrix values. | |
50 | |
51 class | |
4513 | 52 octave_bool_matrix : public octave_base_matrix<boolNDArray> |
2871 | 53 { |
54 public: | |
55 | |
56 octave_bool_matrix (void) | |
4513 | 57 : octave_base_matrix<boolNDArray> () { } |
58 | |
59 octave_bool_matrix (const boolNDArray& bnda) | |
60 : octave_base_matrix<boolNDArray> (bnda) { } | |
2871 | 61 |
62 octave_bool_matrix (const boolMatrix& bm) | |
4513 | 63 : octave_base_matrix<boolNDArray> (bm) { } |
2871 | 64 |
5785 | 65 octave_bool_matrix (const boolMatrix& bm, const MatrixType& t) |
66 : octave_base_matrix<boolNDArray> (bm, t) { } | |
67 | |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
68 octave_bool_matrix (const boolNDArray& bm, const idx_vector& cache) |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
69 : octave_base_matrix<boolNDArray> (bm) |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
70 { |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
71 set_idx_cache (cache); |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
72 } |
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
73 |
2871 | 74 octave_bool_matrix (const octave_bool_matrix& bm) |
4513 | 75 : octave_base_matrix<boolNDArray> (bm) { } |
2871 | 76 |
77 ~octave_bool_matrix (void) { } | |
78 | |
5759 | 79 octave_base_value *clone (void) const { return new octave_bool_matrix (*this); } |
80 octave_base_value *empty_clone (void) const { return new octave_bool_matrix (); } | |
2871 | 81 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
82 type_conv_info numeric_conversion_function (void) const; |
2871 | 83 |
5759 | 84 octave_base_value *try_narrowing_conversion (void); |
2871 | 85 |
9350
16a5f9e1fdb3
cache idx_vector result in matrices once used for indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
86 idx_vector index_vector (void) const |
16a5f9e1fdb3
cache idx_vector result in matrices once used for indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8950
diff
changeset
|
87 { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); } |
2871 | 88 |
9685 | 89 builtin_type_t builtin_type (void) const { return btyp_bool; } |
90 | |
2871 | 91 bool is_bool_matrix (void) const { return true; } |
92 | |
3209 | 93 bool is_bool_type (void) const { return true; } |
94 | |
2871 | 95 bool is_real_type (void) const { return true; } |
96 | |
9841
6f1ea8241c99
make isnumeric yield false on logicals
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
97 bool is_numeric_type (void) const { return false; } |
6f1ea8241c99
make isnumeric yield false on logicals
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
98 |
5533 | 99 int8NDArray |
100 int8_array_value (void) const { return int8NDArray (matrix); } | |
101 | |
102 int16NDArray | |
103 int16_array_value (void) const { return int16NDArray (matrix); } | |
104 | |
105 int32NDArray | |
106 int32_array_value (void) const { return int32NDArray (matrix); } | |
107 | |
108 int64NDArray | |
109 int64_array_value (void) const { return int64NDArray (matrix); } | |
110 | |
111 uint8NDArray | |
112 uint8_array_value (void) const { return uint8NDArray (matrix); } | |
113 | |
114 uint16NDArray | |
115 uint16_array_value (void) const { return uint16NDArray (matrix); } | |
116 | |
117 uint32NDArray | |
118 uint32_array_value (void) const { return uint32NDArray (matrix); } | |
119 | |
120 uint64NDArray | |
121 uint64_array_value (void) const { return uint64NDArray (matrix); } | |
122 | |
2871 | 123 double double_value (bool = false) const; |
124 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
125 float float_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
126 |
3145 | 127 double scalar_value (bool frc_str_conv = false) const |
128 { return double_value (frc_str_conv); } | |
2916 | 129 |
4513 | 130 Matrix matrix_value (bool = false) const |
131 { return Matrix (matrix.matrix_value ()); } | |
2871 | 132 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
133 FloatMatrix float_matrix_value (bool = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
134 { return FloatMatrix (matrix.matrix_value ()); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
135 |
4569 | 136 NDArray array_value (bool = false) const |
4650 | 137 { return NDArray (matrix); } |
4569 | 138 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
139 FloatNDArray float_array_value (bool = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
140 { return FloatNDArray (matrix); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
141 |
2871 | 142 Complex complex_value (bool = false) const; |
143 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
144 FloatComplex float_complex_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
145 |
3145 | 146 ComplexMatrix complex_matrix_value (bool = false) const |
4513 | 147 { return ComplexMatrix (matrix.matrix_value ( )); } |
2871 | 148 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
149 FloatComplexMatrix float_complex_matrix_value (bool = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
150 { return FloatComplexMatrix (matrix.matrix_value ( )); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
151 |
4569 | 152 ComplexNDArray complex_array_value (bool = false) const |
4901 | 153 { return ComplexNDArray (matrix); } |
4569 | 154 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
155 FloatComplexNDArray float_complex_array_value (bool = false) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
156 { return FloatComplexNDArray (matrix); } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
157 |
5533 | 158 charNDArray |
159 char_array_value (bool = false) const | |
160 { | |
161 charNDArray retval (dims ()); | |
162 | |
163 octave_idx_type nel = numel (); | |
164 | |
165 for (octave_idx_type i = 0; i < nel; i++) | |
166 retval(i) = static_cast<char>(matrix(i)); | |
167 | |
168 return retval; | |
169 } | |
170 | |
5944 | 171 boolMatrix bool_matrix_value (bool = false) const |
4513 | 172 { return matrix.matrix_value (); } |
2871 | 173 |
5944 | 174 boolNDArray bool_array_value (bool = false) const |
4543 | 175 { return matrix; } |
176 | |
5164 | 177 SparseMatrix sparse_matrix_value (bool = false) const |
178 { return SparseMatrix (Matrix (matrix.matrix_value ())); } | |
179 | |
180 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const | |
181 { return SparseComplexMatrix (ComplexMatrix (matrix.matrix_value ())); } | |
182 | |
183 SparseBoolMatrix sparse_bool_matrix_value (bool = false) const | |
184 { return SparseBoolMatrix (matrix.matrix_value ()); } | |
185 | |
5279 | 186 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2871 | 187 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
188 // Use matrix_ref here to clear index cache. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
189 void invert (void) { matrix_ref ().invert (); } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
190 |
4643 | 191 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
192 | |
6974 | 193 bool save_ascii (std::ostream& os); |
4687 | 194 |
195 bool load_ascii (std::istream& is); | |
196 | |
197 bool save_binary (std::ostream& os, bool& save_as_floats); | |
198 | |
199 bool load_binary (std::istream& is, bool swap, | |
10313 | 200 oct_mach_info::float_format fmt); |
4687 | 201 |
202 #if defined (HAVE_HDF5) | |
203 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
204 | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9841
diff
changeset
|
205 bool load_hdf5 (hid_t loc_id, const char *name); |
4687 | 206 #endif |
207 | |
4970 | 208 int write (octave_stream& os, int block_size, |
10313 | 209 oct_data_conv::data_type output_type, int skip, |
210 oct_mach_info::float_format flt_fmt) const | |
4970 | 211 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
212 | |
9358
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
213 // Unsafe. This function exists to support the MEX interface. |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
214 // You should not use it anywhere else. |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
215 void *mex_get_data (void) const { return matrix.mex_get_data (); } |
d4b1314a7c31
mex.cc (mxArray_octave_value::get_data): avoid enumerating types that can be handled as foreign
John W. Eaton <jwe@octave.org>
parents:
9350
diff
changeset
|
216 |
5900 | 217 mxArray *as_mxArray (void) const; |
218 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
219 // Mapper functions are converted to double for treatment |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
220 octave_value map (unary_mapper_t umap) const |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
221 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
222 octave_matrix m (array_value ()); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
223 return m.map (umap); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
224 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
225 |
2871 | 226 protected: |
227 | |
3219 | 228 DECLARE_OCTAVE_ALLOCATOR |
2871 | 229 |
3219 | 230 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871 | 231 }; |
232 | |
233 #endif |