Mercurial > hg > octave-lyh
comparison liboctave/idx-vector.h @ 10273:3a8c13b71612
implement special-case optimization for sort of index vectors
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 08 Feb 2010 11:16:52 +0100 |
parents | 4c0cdbe0acca |
children | 22a7913bbeb5 |
comparison
equal
deleted
inserted
replaced
10272:272179888089 | 10273:3a8c13b71612 |
---|---|
87 // Index class. | 87 // Index class. |
88 virtual idx_class_type idx_class (void) const { return class_invalid; } | 88 virtual idx_class_type idx_class (void) const { return class_invalid; } |
89 | 89 |
90 // Sorts, maybe uniqifies, and returns a clone object pointer. | 90 // Sorts, maybe uniqifies, and returns a clone object pointer. |
91 virtual idx_base_rep *sort_uniq_clone (bool uniq = false) = 0; | 91 virtual idx_base_rep *sort_uniq_clone (bool uniq = false) = 0; |
92 // Sorts, and returns a sorting permutation (aka Array::sort). | |
93 virtual idx_base_rep *sort_idx (Array<octave_idx_type>&) = 0; | |
92 | 94 |
93 // Checks whether the index is colon or a range equivalent to colon. | 95 // Checks whether the index is colon or a range equivalent to colon. |
94 virtual bool is_colon_equiv (octave_idx_type) const | 96 virtual bool is_colon_equiv (octave_idx_type) const |
95 { return false; } | 97 { return false; } |
96 | 98 |
132 | 134 |
133 idx_class_type idx_class (void) const { return class_colon; } | 135 idx_class_type idx_class (void) const { return class_colon; } |
134 | 136 |
135 idx_base_rep *sort_uniq_clone (bool = false) | 137 idx_base_rep *sort_uniq_clone (bool = false) |
136 { count++; return this; } | 138 { count++; return this; } |
139 | |
140 idx_base_rep *sort_idx (Array<octave_idx_type>&); | |
137 | 141 |
138 bool is_colon_equiv (octave_idx_type) const | 142 bool is_colon_equiv (octave_idx_type) const |
139 { return true; } | 143 { return true; } |
140 | 144 |
141 std::ostream& print (std::ostream& os) const; | 145 std::ostream& print (std::ostream& os) const; |
181 | 185 |
182 idx_class_type idx_class (void) const { return class_range; } | 186 idx_class_type idx_class (void) const { return class_range; } |
183 | 187 |
184 idx_base_rep *sort_uniq_clone (bool uniq = false); | 188 idx_base_rep *sort_uniq_clone (bool uniq = false); |
185 | 189 |
190 idx_base_rep *sort_idx (Array<octave_idx_type>&); | |
191 | |
186 bool is_colon_equiv (octave_idx_type n) const | 192 bool is_colon_equiv (octave_idx_type n) const |
187 { return start == 0 && step == 1 && len == n; } | 193 { return start == 0 && step == 1 && len == n; } |
188 | 194 |
189 dim_vector orig_dimensions (void) const | 195 dim_vector orig_dimensions (void) const |
190 { return dim_vector (1, len); } | 196 { return dim_vector (1, len); } |
237 | 243 |
238 idx_class_type idx_class (void) const { return class_scalar; } | 244 idx_class_type idx_class (void) const { return class_scalar; } |
239 | 245 |
240 idx_base_rep *sort_uniq_clone (bool = false) | 246 idx_base_rep *sort_uniq_clone (bool = false) |
241 { count++; return this; } | 247 { count++; return this; } |
248 | |
249 idx_base_rep *sort_idx (Array<octave_idx_type>&); | |
242 | 250 |
243 bool is_colon_equiv (octave_idx_type n) const | 251 bool is_colon_equiv (octave_idx_type n) const |
244 { return n == 1 && data == 0; } | 252 { return n == 1 && data == 0; } |
245 | 253 |
246 dim_vector orig_dimensions (void) const | 254 dim_vector orig_dimensions (void) const |
303 | 311 |
304 idx_class_type idx_class (void) const { return class_vector; } | 312 idx_class_type idx_class (void) const { return class_vector; } |
305 | 313 |
306 idx_base_rep *sort_uniq_clone (bool uniq = false); | 314 idx_base_rep *sort_uniq_clone (bool uniq = false); |
307 | 315 |
316 idx_base_rep *sort_idx (Array<octave_idx_type>&); | |
317 | |
308 dim_vector orig_dimensions (void) const | 318 dim_vector orig_dimensions (void) const |
309 { return orig_dims; } | 319 { return orig_dims; } |
310 | 320 |
311 const octave_idx_type *get_data (void) const { return data; } | 321 const octave_idx_type *get_data (void) const { return data; } |
312 | 322 |
367 idx_class_type idx_class (void) const { return class_mask; } | 377 idx_class_type idx_class (void) const { return class_mask; } |
368 | 378 |
369 idx_base_rep *sort_uniq_clone (bool = false) | 379 idx_base_rep *sort_uniq_clone (bool = false) |
370 { count++; return this; } | 380 { count++; return this; } |
371 | 381 |
382 idx_base_rep *sort_idx (Array<octave_idx_type>&); | |
383 | |
372 dim_vector orig_dimensions (void) const | 384 dim_vector orig_dimensions (void) const |
373 { return orig_dims; } | 385 { return orig_dims; } |
374 | 386 |
375 bool is_colon_equiv (octave_idx_type n) const | 387 bool is_colon_equiv (octave_idx_type n) const |
376 { return len == n && ext == n; } | 388 { return len == n && ext == n; } |
557 bool is_colon_equiv (octave_idx_type n) const | 569 bool is_colon_equiv (octave_idx_type n) const |
558 { return rep->is_colon_equiv (n); } | 570 { return rep->is_colon_equiv (n); } |
559 | 571 |
560 idx_vector sorted (bool uniq = false) const | 572 idx_vector sorted (bool uniq = false) const |
561 { return idx_vector (rep->sort_uniq_clone (uniq)); } | 573 { return idx_vector (rep->sort_uniq_clone (uniq)); } |
574 | |
575 idx_vector sorted (Array<octave_idx_type>& sidx) const | |
576 { return idx_vector (rep->sort_idx (sidx)); } | |
562 | 577 |
563 dim_vector orig_dimensions (void) const { return rep->orig_dimensions (); } | 578 dim_vector orig_dimensions (void) const { return rep->orig_dimensions (); } |
564 | 579 |
565 octave_idx_type orig_rows (void) const | 580 octave_idx_type orig_rows (void) const |
566 { return orig_dimensions () (0); } | 581 { return orig_dimensions () (0); } |