Mercurial > octave-nkf
annotate src/ov-str-mat.h @ 7463:2467639bd8c0
eliminate UNDEFINED sort mode
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 08 Feb 2008 16:00:16 -0500 |
parents | 402168152bb9 |
children | 8c32f95c2639 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
2376 | 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. | |
2376 | 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/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_char_matrix_str_h) | |
25 #define octave_char_matrix_str_h 1 | |
26 | |
27 #include <cstdlib> | |
28 | |
3503 | 29 #include <iostream> |
2376 | 30 #include <string> |
31 | |
32 #include "mx-base.h" | |
33 #include "str-vec.h" | |
34 | |
35 #include "error.h" | |
4944 | 36 #include "oct-stream.h" |
3202 | 37 #include "ov.h" |
2376 | 38 #include "ov-ch-mat.h" |
39 #include "ov-typeinfo.h" | |
40 | |
41 class Octave_map; | |
42 class octave_value_list; | |
43 | |
44 class tree_walker; | |
45 | |
2477 | 46 // Character matrix values with special properties for use as |
47 // strings. | |
2376 | 48 |
49 class | |
6109 | 50 OCTINTERP_API |
2376 | 51 octave_char_matrix_str : public octave_char_matrix |
52 { | |
53 public: | |
54 | |
55 octave_char_matrix_str (void) | |
56 : octave_char_matrix () { } | |
57 | |
58 octave_char_matrix_str (const charMatrix& chm) | |
59 : octave_char_matrix (chm) { } | |
60 | |
4513 | 61 octave_char_matrix_str (const charNDArray& chm) |
62 : octave_char_matrix (chm) { } | |
63 | |
3189 | 64 octave_char_matrix_str (char c) |
65 : octave_char_matrix (c) { } | |
66 | |
2376 | 67 octave_char_matrix_str (const char *s) |
68 : octave_char_matrix (s) { } | |
69 | |
3523 | 70 octave_char_matrix_str (const std::string& s) |
2376 | 71 : octave_char_matrix (s) { } |
72 | |
73 octave_char_matrix_str (const string_vector& s) | |
74 : octave_char_matrix (s) { } | |
75 | |
76 octave_char_matrix_str (const octave_char_matrix& chm) | |
77 : octave_char_matrix (chm) { } | |
78 | |
79 octave_char_matrix_str (const octave_char_matrix_str& chms) | |
80 : octave_char_matrix (chms) { } | |
81 | |
82 ~octave_char_matrix_str (void) { } | |
83 | |
5759 | 84 octave_base_value *clone (void) const { return new octave_char_matrix_str (*this); } |
85 octave_base_value *empty_clone (void) const { return new octave_char_matrix_str (); } | |
2376 | 86 |
2412 | 87 type_conv_fcn numeric_conversion_function (void) const; |
2376 | 88 |
5885 | 89 octave_value do_index_op (const octave_value_list& idx, |
90 bool resize_ok = false) | |
5400 | 91 { return do_index_op_internal (idx, resize_ok); } |
2407 | 92 |
93 void assign (const octave_value_list& idx, const charMatrix& rhs); | |
94 | |
4569 | 95 octave_value reshape (const dim_vector& new_dims) const |
96 { return octave_value (charNDArray (matrix.reshape (new_dims)), true); } | |
97 | |
5533 | 98 octave_value permute (const Array<int>& vec, bool inv = false) const |
99 { return octave_value (charNDArray (matrix.permute (vec, inv)), true); } | |
100 | |
5731 | 101 octave_value resize (const dim_vector& dv, bool fill = false) const; |
5533 | 102 |
2376 | 103 bool is_string (void) const { return true; } |
104 | |
4323 | 105 bool is_real_type (void) const { return false; } |
2376 | 106 |
4323 | 107 bool is_matrix_type (void) const { return false; } |
3202 | 108 |
4323 | 109 bool is_numeric_type (void) const { return false; } |
3221 | 110 |
2376 | 111 bool valid_as_scalar_index (void) const; |
112 | |
4643 | 113 double double_value (bool = false) const; |
114 | |
2376 | 115 Matrix matrix_value (bool = false) const; |
116 | |
4668 | 117 NDArray array_value (bool = false) const; |
118 | |
119 Complex complex_value (bool = false) const; | |
120 | |
121 ComplexMatrix complex_matrix_value (bool = false) const; | |
122 | |
123 ComplexNDArray complex_array_value (bool = false) const; | |
124 | |
5715 | 125 string_vector all_strings (bool pad = false) const; |
2376 | 126 |
4457 | 127 std::string string_value (bool force = false) const; |
2376 | 128 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
129 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 130 { return octave_value (matrix.sort (dim, mode), true); } |
131 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
132 sortmode mode = ASCENDING) const |
7433 | 133 { return octave_value (matrix.sort (sidx, dim, mode), true); } |
134 | |
3219 | 135 bool print_as_scalar (void) const { return (rows () <= 1); } |
2901 | 136 |
3523 | 137 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; |
2901 | 138 |
6974 | 139 bool save_ascii (std::ostream& os); |
4687 | 140 |
141 bool load_ascii (std::istream& is); | |
142 | |
143 bool save_binary (std::ostream& os, bool& save_as_floats); | |
144 | |
145 bool load_binary (std::istream& is, bool swap, | |
146 oct_mach_info::float_format fmt); | |
147 | |
148 #if defined (HAVE_HDF5) | |
149 bool save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats); | |
150 | |
151 bool load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug); | |
152 #endif | |
153 | |
4944 | 154 int write (octave_stream& os, int block_size, |
155 oct_data_conv::data_type output_type, int skip, | |
156 oct_mach_info::float_format flt_fmt) const | |
157 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } | |
158 | |
5400 | 159 protected: |
160 | |
161 octave_value do_index_op_internal (const octave_value_list& idx, | |
5885 | 162 bool resize_ok, char type = '"'); |
5400 | 163 |
2376 | 164 private: |
165 | |
3219 | 166 DECLARE_OCTAVE_ALLOCATOR |
2376 | 167 |
3219 | 168 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA |
2376 | 169 }; |
170 | |
5279 | 171 typedef octave_char_matrix_str octave_char_matrix_dq_str; |
172 | |
173 class | |
174 octave_char_matrix_sq_str : public octave_char_matrix_str | |
175 { | |
176 public: | |
177 | |
178 octave_char_matrix_sq_str (void) | |
179 : octave_char_matrix_str () { } | |
180 | |
181 octave_char_matrix_sq_str (const charMatrix& chm) | |
182 : octave_char_matrix_str (chm) { } | |
183 | |
184 octave_char_matrix_sq_str (const charNDArray& chm) | |
185 : octave_char_matrix_str (chm) { } | |
186 | |
187 octave_char_matrix_sq_str (char c) | |
188 : octave_char_matrix_str (c) { } | |
189 | |
190 octave_char_matrix_sq_str (const char *s) | |
191 : octave_char_matrix_str (s) { } | |
192 | |
193 octave_char_matrix_sq_str (const std::string& s) | |
194 : octave_char_matrix_str (s) { } | |
195 | |
196 octave_char_matrix_sq_str (const string_vector& s) | |
197 : octave_char_matrix_str (s) { } | |
198 | |
199 octave_char_matrix_sq_str (const octave_char_matrix_str& chm) | |
200 : octave_char_matrix_str (chm) { } | |
201 | |
202 octave_char_matrix_sq_str (const octave_char_matrix_sq_str& chms) | |
203 : octave_char_matrix_str (chms) { } | |
204 | |
205 ~octave_char_matrix_sq_str (void) { } | |
206 | |
5759 | 207 octave_base_value *clone (void) const { return new octave_char_matrix_sq_str (*this); } |
208 octave_base_value *empty_clone (void) const { return new octave_char_matrix_sq_str (); } | |
5279 | 209 |
5533 | 210 octave_value reshape (const dim_vector& new_dims) const |
211 { return octave_value (charNDArray (matrix.reshape (new_dims)), true, '\''); } | |
212 | |
213 octave_value permute (const Array<int>& vec, bool inv = false) const | |
214 { return octave_value (charNDArray (matrix.permute (vec, inv)), true, '\''); } | |
215 | |
5890 | 216 octave_value resize (const dim_vector& dv, bool = false) const |
5533 | 217 { |
218 charNDArray retval (matrix); | |
219 retval.resize (dv); | |
220 return octave_value (retval, true, '\''); | |
221 } | |
222 | |
5279 | 223 bool is_sq_string (void) const { return true; } |
224 | |
5885 | 225 octave_value do_index_op (const octave_value_list& idx, |
226 bool resize_ok = false) | |
5400 | 227 { return do_index_op_internal (idx, resize_ok, '\''); } |
228 | |
7433 | 229 |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
230 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const |
7433 | 231 { return octave_value (matrix.sort (dim, mode), true, '\''); } |
232 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, | |
7463
2467639bd8c0
eliminate UNDEFINED sort mode
John W. Eaton <jwe@octave.org>
parents:
7433
diff
changeset
|
233 sortmode mode = ASCENDING) const |
7433 | 234 { return octave_value (matrix.sort (sidx, dim, mode), true, '\''); } |
235 | |
5279 | 236 private: |
237 | |
238 DECLARE_OCTAVE_ALLOCATOR | |
239 | |
240 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA | |
241 }; | |
242 | |
2376 | 243 #endif |
244 | |
245 /* | |
246 ;;; Local Variables: *** | |
247 ;;; mode: C++ *** | |
248 ;;; End: *** | |
249 */ |