Mercurial > hg > octave-nkf
annotate libinterp/octave-value/ov-bool-mat.h @ 18470:4c064d3d2750
Remove Octave_map class deprecated in 3.8.
* oct-map.cc: Remove all functions referencing Octave_map.
* oct-map.h: Remove all functions referencing Octave_map.
* ov.cc: Add new 3-term constructors for octave_value which begin with
octave_map or octave_scalar_map to replace the 3-term constructor based on
Octave_map.
* ov.h: Add new 3-term constructors for octave_value which begin with
octave_map or octave_scalar_map to replace the 3-term constructor based on
Octave_map.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 27 Jan 2014 09:50:53 -0800 |
parents | e473c4853afc |
children | 6113e0c6920b |
rev | line source |
---|---|
2871 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
11523 | 4 Copyright (C) 2009-2010 VZLU Prague |
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 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #if !defined (octave_ov_bool_mat_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
25 #define octave_ov_bool_mat_h 1 |
2871 | 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_value_list; |
45 | |
46 class tree_walker; | |
47 | |
48 // Character matrix values. | |
49 | |
50 class | |
4513 | 51 octave_bool_matrix : public octave_base_matrix<boolNDArray> |
2871 | 52 { |
53 public: | |
54 | |
55 octave_bool_matrix (void) | |
4513 | 56 : octave_base_matrix<boolNDArray> () { } |
57 | |
58 octave_bool_matrix (const boolNDArray& bnda) | |
59 : octave_base_matrix<boolNDArray> (bnda) { } | |
2871 | 60 |
10351
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
61 octave_bool_matrix (const Array<bool>& bnda) |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
62 : octave_base_matrix<boolNDArray> (bnda) { } |
5150ceb4dbb4
base charMatrix and boolMatrix on Array<char>
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
63 |
2871 | 64 octave_bool_matrix (const boolMatrix& bm) |
4513 | 65 : octave_base_matrix<boolNDArray> (bm) { } |
2871 | 66 |
5785 | 67 octave_bool_matrix (const boolMatrix& bm, const MatrixType& t) |
68 : octave_base_matrix<boolNDArray> (bm, t) { } | |
69 | |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
70 octave_bool_matrix (const boolNDArray& bm, const idx_vector& cache) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
71 : octave_base_matrix<boolNDArray> (bm) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
72 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
73 set_idx_cache (cache); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
74 } |
9894
83bd7f34f9da
improve idx_vector->octave_value conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9881
diff
changeset
|
75 |
2871 | 76 octave_bool_matrix (const octave_bool_matrix& bm) |
4513 | 77 : octave_base_matrix<boolNDArray> (bm) { } |
2871 | 78 |
79 ~octave_bool_matrix (void) { } | |
80 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 octave_base_value *clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
82 { return new octave_bool_matrix (*this); } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 octave_base_value *empty_clone (void) const |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 { return new octave_bool_matrix (); } |
2871 | 86 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
87 type_conv_info numeric_conversion_function (void) const; |
2871 | 88 |
5759 | 89 octave_base_value *try_narrowing_conversion (void); |
2871 | 90 |
18129
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
91 idx_vector index_vector (bool /* require_integers */ = false) const |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
92 { |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
93 return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); |
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
94 } |
2871 | 95 |
9685 | 96 builtin_type_t builtin_type (void) const { return btyp_bool; } |
97 | |
2871 | 98 bool is_bool_matrix (void) const { return true; } |
99 | |
3209 | 100 bool is_bool_type (void) const { return true; } |
101 | |
2871 | 102 bool is_real_type (void) const { return true; } |
103 | |
9841
6f1ea8241c99
make isnumeric yield false on logicals
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
104 bool is_numeric_type (void) const { return false; } |
6f1ea8241c99
make isnumeric yield false on logicals
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
105 |
5533 | 106 int8NDArray |
107 int8_array_value (void) const { return int8NDArray (matrix); } | |
108 | |
109 int16NDArray | |
110 int16_array_value (void) const { return int16NDArray (matrix); } | |
111 | |
112 int32NDArray | |
113 int32_array_value (void) const { return int32NDArray (matrix); } | |
114 | |
115 int64NDArray | |
116 int64_array_value (void) const { return int64NDArray (matrix); } | |
117 | |
118 uint8NDArray | |
119 uint8_array_value (void) const { return uint8NDArray (matrix); } | |
120 | |
121 uint16NDArray | |
122 uint16_array_value (void) const { return uint16NDArray (matrix); } | |
123 | |
124 uint32NDArray | |
125 uint32_array_value (void) const { return uint32NDArray (matrix); } | |
126 | |
127 uint64NDArray | |
128 uint64_array_value (void) const { return uint64NDArray (matrix); } | |
129 | |
2871 | 130 double double_value (bool = false) const; |
131 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
132 float float_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
133 |
3145 | 134 double scalar_value (bool frc_str_conv = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 { return double_value (frc_str_conv); } |
2916 | 136 |
4513 | 137 Matrix matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 { return Matrix (matrix.matrix_value ()); } |
2871 | 139 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
140 FloatMatrix float_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 { return FloatMatrix (matrix.matrix_value ()); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
142 |
4569 | 143 NDArray array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 { return NDArray (matrix); } |
4569 | 145 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
146 FloatNDArray float_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 { return FloatNDArray (matrix); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
148 |
2871 | 149 Complex complex_value (bool = false) const; |
150 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
151 FloatComplex float_complex_value (bool = false) const; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
152 |
3145 | 153 ComplexMatrix complex_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 { return ComplexMatrix (matrix.matrix_value ( )); } |
2871 | 155 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
156 FloatComplexMatrix float_complex_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 { return FloatComplexMatrix (matrix.matrix_value ( )); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
158 |
4569 | 159 ComplexNDArray complex_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 { return ComplexNDArray (matrix); } |
4569 | 161 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
162 FloatComplexNDArray float_complex_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
163 { return FloatComplexNDArray (matrix); } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
164 |
5533 | 165 charNDArray |
166 char_array_value (bool = false) const | |
167 { | |
168 charNDArray retval (dims ()); | |
169 | |
170 octave_idx_type nel = numel (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
171 |
5533 | 172 for (octave_idx_type i = 0; i < nel; i++) |
173 retval(i) = static_cast<char>(matrix(i)); | |
174 | |
175 return retval; | |
176 } | |
177 | |
5944 | 178 boolMatrix bool_matrix_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 { return matrix.matrix_value (); } |
2871 | 180 |
5944 | 181 boolNDArray bool_array_value (bool = false) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 { return matrix; } |
4543 | 183 |
5164 | 184 SparseMatrix sparse_matrix_value (bool = false) const |
185 { return SparseMatrix (Matrix (matrix.matrix_value ())); } | |
186 | |
187 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const | |
188 { return SparseComplexMatrix (ComplexMatrix (matrix.matrix_value ())); } | |
189 | |
190 SparseBoolMatrix sparse_bool_matrix_value (bool = false) const | |
191 { return SparseBoolMatrix (matrix.matrix_value ()); } | |
192 | |
5279 | 193 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2871 | 194 |
9607
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
195 // Use matrix_ref here to clear index cache. |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
196 void invert (void) { matrix_ref ().invert (); } |
1be3c73ed7b5
reuse temporary arrays in nested expressions
Jaroslav Hajek <highegg@gmail.com>
parents:
9358
diff
changeset
|
197 |
4643 | 198 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
199 | |
6974 | 200 bool save_ascii (std::ostream& os); |
4687 | 201 |
202 bool load_ascii (std::istream& is); | |
203 | |
204 bool save_binary (std::ostream& os, bool& save_as_floats); | |
205 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
206 bool load_binary (std::istream& is, bool swap, |
10313 | 207 oct_mach_info::float_format fmt); |
4687 | 208 |
209 #if defined (HAVE_HDF5) | |
210 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
211 | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9841
diff
changeset
|
212 bool load_hdf5 (hid_t loc_id, const char *name); |
4687 | 213 #endif |
214 | |
4970 | 215 int write (octave_stream& os, int block_size, |
10313 | 216 oct_data_conv::data_type output_type, int skip, |
217 oct_mach_info::float_format flt_fmt) const | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
4970 | 219 |
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
|
220 // 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
|
221 // 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
|
222 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
|
223 |
5900 | 224 mxArray *as_mxArray (void) const; |
225 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
226 // Mapper functions are converted to double for treatment |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9685
diff
changeset
|
227 octave_value map (unary_mapper_t umap) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
228 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 octave_matrix m (array_value ()); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 return m.map (umap); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
231 } |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
232 |
2871 | 233 protected: |
234 | |
3219 | 235 DECLARE_OCTAVE_ALLOCATOR |
2871 | 236 |
3219 | 237 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871 | 238 }; |
239 | |
240 #endif |