comparison src/ov-str-mat.h @ 7503:8c32f95c2639

convert mapper functions to new format
author David Bateman <dbateman@free.fr>
date Wed, 20 Feb 2008 04:22:50 -0500
parents 2467639bd8c0
children 26d8a92644de
comparison
equal deleted inserted replaced
7502:2ce6b4258e96 7503:8c32f95c2639
33 #include "str-vec.h" 33 #include "str-vec.h"
34 34
35 #include "error.h" 35 #include "error.h"
36 #include "oct-stream.h" 36 #include "oct-stream.h"
37 #include "ov.h" 37 #include "ov.h"
38 #include "ov-re-mat.h"
38 #include "ov-ch-mat.h" 39 #include "ov-ch-mat.h"
39 #include "ov-typeinfo.h" 40 #include "ov-typeinfo.h"
40 41
41 class Octave_map; 42 class Octave_map;
42 class octave_value_list; 43 class octave_value_list;
125 string_vector all_strings (bool pad = false) const; 126 string_vector all_strings (bool pad = false) const;
126 127
127 std::string string_value (bool force = false) const; 128 std::string string_value (bool force = false) const;
128 129
129 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const 130 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
130 { return octave_value (matrix.sort (dim, mode), true); } 131 { return octave_value (matrix.sort (dim, mode), true); }
132
131 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, 133 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
132 sortmode mode = ASCENDING) const 134 sortmode mode = ASCENDING) const
133 { return octave_value (matrix.sort (sidx, dim, mode), true); } 135 { return octave_value (matrix.sort (sidx, dim, mode), true); }
134 136
135 bool print_as_scalar (void) const { return (rows () <= 1); } 137 bool print_as_scalar (void) const { return (rows () <= 1); }
136 138
137 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const; 139 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
138 140
153 155
154 int write (octave_stream& os, int block_size, 156 int write (octave_stream& os, int block_size,
155 oct_data_conv::data_type output_type, int skip, 157 oct_data_conv::data_type output_type, int skip,
156 oct_mach_info::float_format flt_fmt) const 158 oct_mach_info::float_format flt_fmt) const
157 { return os.write (matrix, block_size, output_type, skip, flt_fmt); } 159 { return os.write (matrix, block_size, output_type, skip, flt_fmt); }
160
161 octave_value isalnum (void) const;
162 octave_value isalpha (void) const;
163 octave_value isascii (void) const;
164 octave_value iscntrl (void) const;
165 octave_value isdigit (void) const;
166 octave_value isgraph (void) const;
167 octave_value islower (void) const;
168 octave_value isprint (void) const;
169 octave_value ispunct (void) const;
170 octave_value isspace (void) const;
171 octave_value isupper (void) const;
172 octave_value isxdigit (void) const;
173 octave_value toascii (void) const;
174 octave_value tolower (void) const;
175 octave_value toupper (void) const;
176
177 #define MAT_MAPPER(MAP) \
178 octave_value MAP (void) const \
179 { \
180 octave_matrix m (array_value (true)); \
181 return m.MAP (); \
182 }
183
184 MAT_MAPPER (abs)
185 MAT_MAPPER (angle)
186 MAT_MAPPER (arg)
187 MAT_MAPPER (ceil)
188 MAT_MAPPER (conj)
189 MAT_MAPPER (fix)
190 MAT_MAPPER (floor)
191 MAT_MAPPER (imag)
192 MAT_MAPPER (real)
193 MAT_MAPPER (round)
194 MAT_MAPPER (signum)
195
196 #undef MAT_MAPPER
197
198 #define BOOL_MAT_MAPPER(MAP, VAL) \
199 octave_value MAP (void) const \
200 { \
201 return boolNDArray (matrix.dims (), VAL); \
202 }
203
204 BOOL_MAT_MAPPER (finite, true)
205 BOOL_MAT_MAPPER (isinf, false)
206 BOOL_MAT_MAPPER (isna, false)
207 BOOL_MAT_MAPPER (isnan, false)
208
209 #undef BOOL_MAT_MAPPER
158 210
159 protected: 211 protected:
160 212
161 octave_value do_index_op_internal (const octave_value_list& idx, 213 octave_value do_index_op_internal (const octave_value_list& idx,
162 bool resize_ok, char type = '"'); 214 bool resize_ok, char type = '"');
226 bool resize_ok = false) 278 bool resize_ok = false)
227 { return do_index_op_internal (idx, resize_ok, '\''); } 279 { return do_index_op_internal (idx, resize_ok, '\''); }
228 280
229 281
230 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const 282 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const
231 { return octave_value (matrix.sort (dim, mode), true, '\''); } 283 { return octave_value (matrix.sort (dim, mode), true, '\''); }
284
232 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0, 285 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
233 sortmode mode = ASCENDING) const 286 sortmode mode = ASCENDING) const
234 { return octave_value (matrix.sort (sidx, dim, mode), true, '\''); } 287 { return octave_value (matrix.sort (sidx, dim, mode), true, '\''); }
235 288
236 private: 289 private:
237 290
238 DECLARE_OCTAVE_ALLOCATOR 291 DECLARE_OCTAVE_ALLOCATOR
239 292