2871
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
|
4 2007 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 |
3503
|
29 #include <iostream> |
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" |
2871
|
39 #include "ov-typeinfo.h" |
|
40 |
5785
|
41 #include "MatrixType.h" |
|
42 |
2871
|
43 class Octave_map; |
|
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 |
|
61 octave_bool_matrix (const boolMatrix& bm) |
4513
|
62 : octave_base_matrix<boolNDArray> (bm) { } |
2871
|
63 |
5785
|
64 octave_bool_matrix (const boolMatrix& bm, const MatrixType& t) |
|
65 : octave_base_matrix<boolNDArray> (bm, t) { } |
|
66 |
3225
|
67 octave_bool_matrix (const Array2<bool>& a) |
4513
|
68 : octave_base_matrix<boolNDArray> (a) { } |
3225
|
69 |
2871
|
70 octave_bool_matrix (const octave_bool_matrix& bm) |
4513
|
71 : octave_base_matrix<boolNDArray> (bm) { } |
2871
|
72 |
|
73 ~octave_bool_matrix (void) { } |
|
74 |
5759
|
75 octave_base_value *clone (void) const { return new octave_bool_matrix (*this); } |
|
76 octave_base_value *empty_clone (void) const { return new octave_bool_matrix (); } |
2871
|
77 |
|
78 type_conv_fcn numeric_conversion_function (void) const; |
|
79 |
5759
|
80 octave_base_value *try_narrowing_conversion (void); |
2871
|
81 |
4650
|
82 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2871
|
83 |
|
84 bool is_bool_matrix (void) const { return true; } |
|
85 |
3209
|
86 bool is_bool_type (void) const { return true; } |
|
87 |
2871
|
88 bool is_real_type (void) const { return true; } |
|
89 |
|
90 bool valid_as_scalar_index (void) const; |
|
91 |
5533
|
92 int8NDArray |
|
93 int8_array_value (void) const { return int8NDArray (matrix); } |
|
94 |
|
95 int16NDArray |
|
96 int16_array_value (void) const { return int16NDArray (matrix); } |
|
97 |
|
98 int32NDArray |
|
99 int32_array_value (void) const { return int32NDArray (matrix); } |
|
100 |
|
101 int64NDArray |
|
102 int64_array_value (void) const { return int64NDArray (matrix); } |
|
103 |
|
104 uint8NDArray |
|
105 uint8_array_value (void) const { return uint8NDArray (matrix); } |
|
106 |
|
107 uint16NDArray |
|
108 uint16_array_value (void) const { return uint16NDArray (matrix); } |
|
109 |
|
110 uint32NDArray |
|
111 uint32_array_value (void) const { return uint32NDArray (matrix); } |
|
112 |
|
113 uint64NDArray |
|
114 uint64_array_value (void) const { return uint64NDArray (matrix); } |
|
115 |
2871
|
116 double double_value (bool = false) const; |
|
117 |
3145
|
118 double scalar_value (bool frc_str_conv = false) const |
|
119 { return double_value (frc_str_conv); } |
2916
|
120 |
4513
|
121 Matrix matrix_value (bool = false) const |
|
122 { return Matrix (matrix.matrix_value ()); } |
2871
|
123 |
4569
|
124 NDArray array_value (bool = false) const |
4650
|
125 { return NDArray (matrix); } |
4569
|
126 |
2871
|
127 Complex complex_value (bool = false) const; |
|
128 |
3145
|
129 ComplexMatrix complex_matrix_value (bool = false) const |
4513
|
130 { return ComplexMatrix (matrix.matrix_value ( )); } |
2871
|
131 |
4569
|
132 ComplexNDArray complex_array_value (bool = false) const |
4901
|
133 { return ComplexNDArray (matrix); } |
4569
|
134 |
5533
|
135 charNDArray |
|
136 char_array_value (bool = false) const |
|
137 { |
|
138 charNDArray retval (dims ()); |
|
139 |
|
140 octave_idx_type nel = numel (); |
|
141 |
|
142 for (octave_idx_type i = 0; i < nel; i++) |
|
143 retval(i) = static_cast<char>(matrix(i)); |
|
144 |
|
145 return retval; |
|
146 } |
|
147 |
5944
|
148 boolMatrix bool_matrix_value (bool = false) const |
4513
|
149 { return matrix.matrix_value (); } |
2871
|
150 |
5944
|
151 boolNDArray bool_array_value (bool = false) const |
4543
|
152 { return matrix; } |
|
153 |
5164
|
154 SparseMatrix sparse_matrix_value (bool = false) const |
|
155 { return SparseMatrix (Matrix (matrix.matrix_value ())); } |
|
156 |
|
157 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const |
|
158 { return SparseComplexMatrix (ComplexMatrix (matrix.matrix_value ())); } |
|
159 |
|
160 SparseBoolMatrix sparse_bool_matrix_value (bool = false) const |
|
161 { return SparseBoolMatrix (matrix.matrix_value ()); } |
|
162 |
5279
|
163 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2871
|
164 |
4643
|
165 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
166 |
6974
|
167 bool save_ascii (std::ostream& os); |
4687
|
168 |
|
169 bool load_ascii (std::istream& is); |
|
170 |
|
171 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
172 |
|
173 bool load_binary (std::istream& is, bool swap, |
|
174 oct_mach_info::float_format fmt); |
|
175 |
|
176 #if defined (HAVE_HDF5) |
|
177 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
178 |
|
179 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
180 #endif |
|
181 |
4970
|
182 int write (octave_stream& os, int block_size, |
|
183 oct_data_conv::data_type output_type, int skip, |
|
184 oct_mach_info::float_format flt_fmt) const |
|
185 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
186 |
5900
|
187 mxArray *as_mxArray (void) const; |
|
188 |
2871
|
189 protected: |
|
190 |
3219
|
191 DECLARE_OCTAVE_ALLOCATOR |
2871
|
192 |
3219
|
193 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871
|
194 }; |
|
195 |
|
196 #endif |
|
197 |
|
198 /* |
|
199 ;;; Local Variables: *** |
|
200 ;;; mode: C++ *** |
|
201 ;;; End: *** |
|
202 */ |