2871
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
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 |
|
41 class Octave_map; |
|
42 class octave_value_list; |
|
43 |
|
44 class tree_walker; |
|
45 |
|
46 // Character matrix values. |
|
47 |
|
48 class |
4513
|
49 octave_bool_matrix : public octave_base_matrix<boolNDArray> |
2871
|
50 { |
|
51 public: |
|
52 |
|
53 octave_bool_matrix (void) |
4513
|
54 : octave_base_matrix<boolNDArray> () { } |
|
55 |
|
56 octave_bool_matrix (const boolNDArray& bnda) |
|
57 : octave_base_matrix<boolNDArray> (bnda) { } |
2871
|
58 |
|
59 octave_bool_matrix (const boolMatrix& bm) |
4513
|
60 : octave_base_matrix<boolNDArray> (bm) { } |
2871
|
61 |
3225
|
62 octave_bool_matrix (const Array2<bool>& a) |
4513
|
63 : octave_base_matrix<boolNDArray> (a) { } |
3225
|
64 |
2871
|
65 octave_bool_matrix (const octave_bool_matrix& bm) |
4513
|
66 : octave_base_matrix<boolNDArray> (bm) { } |
2871
|
67 |
|
68 ~octave_bool_matrix (void) { } |
|
69 |
5759
|
70 octave_base_value *clone (void) const { return new octave_bool_matrix (*this); } |
|
71 octave_base_value *empty_clone (void) const { return new octave_bool_matrix (); } |
2871
|
72 |
|
73 type_conv_fcn numeric_conversion_function (void) const; |
|
74 |
5759
|
75 octave_base_value *try_narrowing_conversion (void); |
2871
|
76 |
4650
|
77 idx_vector index_vector (void) const { return idx_vector (matrix); } |
2871
|
78 |
|
79 bool is_bool_matrix (void) const { return true; } |
|
80 |
3209
|
81 bool is_bool_type (void) const { return true; } |
|
82 |
2871
|
83 bool is_real_type (void) const { return true; } |
|
84 |
|
85 bool valid_as_scalar_index (void) const; |
|
86 |
5533
|
87 int8NDArray |
|
88 int8_array_value (void) const { return int8NDArray (matrix); } |
|
89 |
|
90 int16NDArray |
|
91 int16_array_value (void) const { return int16NDArray (matrix); } |
|
92 |
|
93 int32NDArray |
|
94 int32_array_value (void) const { return int32NDArray (matrix); } |
|
95 |
|
96 int64NDArray |
|
97 int64_array_value (void) const { return int64NDArray (matrix); } |
|
98 |
|
99 uint8NDArray |
|
100 uint8_array_value (void) const { return uint8NDArray (matrix); } |
|
101 |
|
102 uint16NDArray |
|
103 uint16_array_value (void) const { return uint16NDArray (matrix); } |
|
104 |
|
105 uint32NDArray |
|
106 uint32_array_value (void) const { return uint32NDArray (matrix); } |
|
107 |
|
108 uint64NDArray |
|
109 uint64_array_value (void) const { return uint64NDArray (matrix); } |
|
110 |
2871
|
111 double double_value (bool = false) const; |
|
112 |
3145
|
113 double scalar_value (bool frc_str_conv = false) const |
|
114 { return double_value (frc_str_conv); } |
2916
|
115 |
4513
|
116 Matrix matrix_value (bool = false) const |
|
117 { return Matrix (matrix.matrix_value ()); } |
2871
|
118 |
4569
|
119 NDArray array_value (bool = false) const |
4650
|
120 { return NDArray (matrix); } |
4569
|
121 |
2871
|
122 Complex complex_value (bool = false) const; |
|
123 |
3145
|
124 ComplexMatrix complex_matrix_value (bool = false) const |
4513
|
125 { return ComplexMatrix (matrix.matrix_value ( )); } |
2871
|
126 |
4569
|
127 ComplexNDArray complex_array_value (bool = false) const |
4901
|
128 { return ComplexNDArray (matrix); } |
4569
|
129 |
5533
|
130 charNDArray |
|
131 char_array_value (bool = false) const |
|
132 { |
|
133 charNDArray retval (dims ()); |
|
134 |
|
135 octave_idx_type nel = numel (); |
|
136 |
|
137 for (octave_idx_type i = 0; i < nel; i++) |
|
138 retval(i) = static_cast<char>(matrix(i)); |
|
139 |
|
140 return retval; |
|
141 } |
|
142 |
3545
|
143 boolMatrix bool_matrix_value (void) const |
4513
|
144 { return matrix.matrix_value (); } |
2871
|
145 |
4580
|
146 boolNDArray bool_array_value (void) const |
4543
|
147 { return matrix; } |
|
148 |
5164
|
149 SparseMatrix sparse_matrix_value (bool = false) const |
|
150 { return SparseMatrix (Matrix (matrix.matrix_value ())); } |
|
151 |
|
152 SparseComplexMatrix sparse_complex_matrix_value (bool = false) const |
|
153 { return SparseComplexMatrix (ComplexMatrix (matrix.matrix_value ())); } |
|
154 |
|
155 SparseBoolMatrix sparse_bool_matrix_value (bool = false) const |
|
156 { return SparseBoolMatrix (matrix.matrix_value ()); } |
|
157 |
5279
|
158 octave_value convert_to_str_internal (bool pad, bool force, char type) const; |
2871
|
159 |
4643
|
160 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
|
161 |
4687
|
162 bool save_ascii (std::ostream& os, bool& infnan_warned, |
|
163 bool strip_nan_and_inf); |
|
164 |
|
165 bool load_ascii (std::istream& is); |
|
166 |
|
167 bool save_binary (std::ostream& os, bool& save_as_floats); |
|
168 |
|
169 bool load_binary (std::istream& is, bool swap, |
|
170 oct_mach_info::float_format fmt); |
|
171 |
|
172 #if defined (HAVE_HDF5) |
|
173 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); |
|
174 |
|
175 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); |
|
176 #endif |
|
177 |
4970
|
178 int write (octave_stream& os, int block_size, |
|
179 oct_data_conv::data_type output_type, int skip, |
|
180 oct_mach_info::float_format flt_fmt) const |
|
181 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } |
|
182 |
2871
|
183 protected: |
|
184 |
3219
|
185 DECLARE_OCTAVE_ALLOCATOR |
2871
|
186 |
3219
|
187 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2871
|
188 }; |
|
189 |
|
190 #endif |
|
191 |
|
192 /* |
|
193 ;;; Local Variables: *** |
|
194 ;;; mode: C++ *** |
|
195 ;;; End: *** |
|
196 */ |