Mercurial > octave
annotate liboctave/oct-sort.h @ 9407:0951174cbb03
remove experimental stuff from lookup, simplify
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 29 Jun 2009 14:07:32 +0200 |
parents | 2ebf3ca62add |
children | aea3a3a950e1 |
rev | line source |
---|---|
4851 | 1 /* |
8920 | 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 David Bateman |
4851 | 3 |
4 This file is part of Octave. | |
5 | |
6 Octave is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
7016 | 8 Free Software Foundation; either version 3 of the License, or (at your |
9 option) any later version. | |
4851 | 10 |
11 Octave is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
7016 | 17 along with Octave; see the file COPYING. If not, see |
18 <http://www.gnu.org/licenses/>. | |
4851 | 19 |
20 Code stolen in large part from Python's, listobject.c, which itself had | |
21 no license header. However, thanks to Tim Peters for the parts of the | |
22 code I ripped-off. | |
23 | |
24 As required in the Python license the short description of the changes | |
25 made are | |
26 | |
27 * convert the sorting code in listobject.cc into a generic class, | |
28 replacing PyObject* with the type of the class T. | |
29 | |
30 The Python license is | |
31 | |
32 PSF LICENSE AGREEMENT FOR PYTHON 2.3 | |
33 -------------------------------------- | |
34 | |
35 1. This LICENSE AGREEMENT is between the Python Software Foundation | |
36 ("PSF"), and the Individual or Organization ("Licensee") accessing and | |
37 otherwise using Python 2.3 software in source or binary form and its | |
38 associated documentation. | |
39 | |
40 2. Subject to the terms and conditions of this License Agreement, PSF | |
41 hereby grants Licensee a nonexclusive, royalty-free, world-wide | |
42 license to reproduce, analyze, test, perform and/or display publicly, | |
43 prepare derivative works, distribute, and otherwise use Python 2.3 | |
44 alone or in any derivative version, provided, however, that PSF's | |
45 License Agreement and PSF's notice of copyright, i.e., "Copyright (c) | |
46 2001, 2002, 2003 Python Software Foundation; All Rights Reserved" are | |
47 retained in Python 2.3 alone or in any derivative version prepared by | |
48 Licensee. | |
49 | |
50 3. In the event Licensee prepares a derivative work that is based on | |
51 or incorporates Python 2.3 or any part thereof, and wants to make | |
52 the derivative work available to others as provided herein, then | |
53 Licensee hereby agrees to include in any such work a brief summary of | |
54 the changes made to Python 2.3. | |
55 | |
56 4. PSF is making Python 2.3 available to Licensee on an "AS IS" | |
57 basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR | |
58 IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND | |
59 DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS | |
60 FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.3 WILL NOT | |
61 INFRINGE ANY THIRD PARTY RIGHTS. | |
62 | |
63 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON | |
64 2.3 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS | |
65 A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.3, | |
66 OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. | |
67 | |
68 6. This License Agreement will automatically terminate upon a material | |
69 breach of its terms and conditions. | |
70 | |
71 7. Nothing in this License Agreement shall be deemed to create any | |
72 relationship of agency, partnership, or joint venture between PSF and | |
73 Licensee. This License Agreement does not grant permission to use PSF | |
74 trademarks or trade name in a trademark sense to endorse or promote | |
75 products or services of Licensee, or any third party. | |
76 | |
77 8. By copying, installing or otherwise using Python 2.3, Licensee | |
78 agrees to be bound by the terms and conditions of this License | |
79 Agreement. | |
80 */ | |
81 | |
82 #if !defined (octave_sort_h) | |
83 #define octave_sort_h 1 | |
84 | |
8725 | 85 #include "lo-traits.h" |
86 | |
7234 | 87 // The maximum number of entries in a MergeState's pending-runs stack. |
88 // This is enough to sort arrays of size up to about | |
89 // 32 * phi ** MAX_MERGE_PENDING | |
90 // where phi ~= 1.618. 85 is ridiculously large enough, good for an array | |
91 // with 2**64 elements. | |
4851 | 92 #define MAX_MERGE_PENDING 85 |
93 | |
7234 | 94 // When we get into galloping mode, we stay there until both runs win less |
95 // often than MIN_GALLOP consecutive times. See listsort.txt for more info. | |
4851 | 96 #define MIN_GALLOP 7 |
97 | |
7234 | 98 // Avoid malloc for small temp arrays. |
4851 | 99 #define MERGESTATE_TEMP_SIZE 1024 |
100 | |
7433 | 101 // Enum for type of sort function |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
102 enum sortmode { UNSORTED = 0, ASCENDING, DESCENDING }; |
7433 | 103 |
4851 | 104 template <class T> |
105 class | |
106 octave_sort | |
107 { | |
4998 | 108 public: |
109 | |
8725 | 110 typedef bool (*compare_fcn_type) (typename ref_param<T>::type, |
111 typename ref_param<T>::type); | |
112 | |
4851 | 113 octave_sort (void); |
114 | |
8725 | 115 octave_sort (compare_fcn_type); |
4851 | 116 |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
117 ~octave_sort (void); |
4998 | 118 |
8725 | 119 void set_compare (compare_fcn_type comp) { compare = comp; } |
4851 | 120 |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
121 void set_compare (sortmode mode); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
122 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
123 // Sort an array in-place. |
8700 | 124 void sort (T *data, octave_idx_type nel); |
125 | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
126 // Ditto, but also permute the passed indices (may not be valid indices). |
8700 | 127 void sort (T *data, octave_idx_type *idx, octave_idx_type nel); |
128 | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
129 // Check whether an array is sorted. |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
130 bool is_sorted (const T *data, octave_idx_type nel); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
131 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
132 // Sort a matrix by rows, return a permutation |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
133 // vector. |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
134 void sort_rows (const T *data, octave_idx_type *idx, |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
135 octave_idx_type rows, octave_idx_type cols); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
136 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
137 // Determine whether a matrix (as a contiguous block) is sorted by rows. |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
138 bool is_sorted_rows (const T *data, |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
139 octave_idx_type rows, octave_idx_type cols); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
140 |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
141 // Do a binary lookup in a sorted array. |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
142 octave_idx_type lookup (const T *data, octave_idx_type nel, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
143 const T& value); |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
144 |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
145 // Ditto, but for an array of values, specializing on long runs. |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
146 // Adds offset to all indices. |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
147 void lookup (const T *data, octave_idx_type nel, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
148 const T* values, octave_idx_type nvalues, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
149 octave_idx_type *idx, octave_idx_type offset = 0); |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
150 |
9341
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
151 // Lookup an array of values, only returning indices of |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
152 // exact matches. Non-matches are returned as -1. |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
153 void lookupm (const T *data, octave_idx_type nel, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
154 const T* values, octave_idx_type nvalues, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
155 octave_idx_type *idx); |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
156 |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
157 // Lookup an array of values, only indicating exact matches. |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
158 void lookupb (const T *data, octave_idx_type nel, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
159 const T* values, octave_idx_type nvalues, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
160 bool *match); |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
161 |
8725 | 162 static bool ascending_compare (typename ref_param<T>::type, |
163 typename ref_param<T>::type); | |
164 | |
165 static bool descending_compare (typename ref_param<T>::type, | |
166 typename ref_param<T>::type); | |
4851 | 167 |
4998 | 168 private: |
169 | |
7234 | 170 // One MergeState exists on the stack per invocation of mergesort. |
171 // It's just a convenient way to pass state around among the helper | |
172 // functions. | |
173 // | |
174 // DGB: This isn't needed with mergesort in a class, but it doesn't | |
175 // slow things up, and it is likely to make my life easier for any | |
176 // potential backporting of changes in the Python code. | |
4851 | 177 |
178 struct s_slice | |
179 { | |
8700 | 180 octave_idx_type base, len; |
4851 | 181 }; |
182 | |
7234 | 183 struct MergeState |
4851 | 184 { |
8820
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
185 MergeState (void) |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
186 : a (0), ia (0), alloced (0) |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
187 { reset (); } |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
188 |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
189 ~MergeState (void) |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
190 { delete [] a; delete [] ia; } |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
191 |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
192 void reset (void) |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
193 { min_gallop = MIN_GALLOP; n = 0; } |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
194 |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
195 void getmem (octave_idx_type need); |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
196 |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
197 void getmemi (octave_idx_type need); |
89b95972e178
fix previously introduced problem in octave_sort, improve design
Jaroslav Hajek <highegg@gmail.com>
parents:
8814
diff
changeset
|
198 |
7234 | 199 // This controls when we get *into* galloping mode. It's |
200 // initialized to MIN_GALLOP. merge_lo and merge_hi tend to nudge | |
201 // it higher for random data, and lower for highly structured | |
202 // data. | |
7433 | 203 octave_idx_type min_gallop; |
4851 | 204 |
7234 | 205 // 'a' is temp storage to help with merges. It contains room for |
206 // alloced entries. | |
207 T *a; // may point to temparray below | |
8700 | 208 octave_idx_type *ia; |
7433 | 209 octave_idx_type alloced; |
4851 | 210 |
7234 | 211 // A stack of n pending runs yet to be merged. Run #i starts at |
212 // address base[i] and extends for len[i] elements. It's always | |
213 // true (so long as the indices are in bounds) that | |
214 // | |
215 // pending[i].base + pending[i].len == pending[i+1].base | |
216 // | |
217 // so we could cut the storage for this, but it's a minor amount, | |
218 // and keeping all the info explicit simplifies the code. | |
7433 | 219 octave_idx_type n; |
4851 | 220 struct s_slice pending[MAX_MERGE_PENDING]; |
7234 | 221 }; |
4851 | 222 |
8725 | 223 compare_fcn_type compare; |
4851 | 224 |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
225 MergeState *ms; |
4851 | 226 |
8700 | 227 |
228 template <class Comp> | |
229 void binarysort (T *data, octave_idx_type nel, | |
230 octave_idx_type start, Comp comp); | |
231 | |
232 template <class Comp> | |
233 void binarysort (T *data, octave_idx_type *idx, octave_idx_type nel, | |
234 octave_idx_type start, Comp comp); | |
4851 | 235 |
8700 | 236 template <class Comp> |
237 octave_idx_type count_run (T *lo, octave_idx_type n, bool& descending, Comp comp); | |
4851 | 238 |
8700 | 239 template <class Comp> |
240 octave_idx_type gallop_left (T key, T *a, octave_idx_type n, octave_idx_type hint, | |
241 Comp comp); | |
4851 | 242 |
8700 | 243 template <class Comp> |
244 octave_idx_type gallop_right (T key, T *a, octave_idx_type n, octave_idx_type hint, | |
245 Comp comp); | |
4851 | 246 |
8700 | 247 template <class Comp> |
248 int merge_lo (T *pa, octave_idx_type na, | |
249 T *pb, octave_idx_type nb, | |
250 Comp comp); | |
4851 | 251 |
8700 | 252 template <class Comp> |
253 int merge_lo (T *pa, octave_idx_type *ipa, octave_idx_type na, | |
254 T *pb, octave_idx_type *ipb, octave_idx_type nb, | |
255 Comp comp); | |
256 | |
257 template <class Comp> | |
258 int merge_hi (T *pa, octave_idx_type na, | |
259 T *pb, octave_idx_type nb, | |
260 Comp comp); | |
4851 | 261 |
8700 | 262 template <class Comp> |
263 int merge_hi (T *pa, octave_idx_type *ipa, octave_idx_type na, | |
264 T *pb, octave_idx_type *ipb, octave_idx_type nb, | |
265 Comp comp); | |
266 | |
267 template <class Comp> | |
268 int merge_at (octave_idx_type i, T *data, | |
269 Comp comp); | |
4851 | 270 |
8700 | 271 template <class Comp> |
272 int merge_at (octave_idx_type i, T *data, octave_idx_type *idx, | |
273 Comp comp); | |
274 | |
275 template <class Comp> | |
276 int merge_collapse (T *data, Comp comp); | |
4851 | 277 |
8700 | 278 template <class Comp> |
279 int merge_collapse (T *data, octave_idx_type *idx, Comp comp); | |
280 | |
281 template <class Comp> | |
282 int merge_force_collapse (T *data, Comp comp); | |
283 | |
284 template <class Comp> | |
285 int merge_force_collapse (T *data, octave_idx_type *idx, Comp comp); | |
4851 | 286 |
7433 | 287 octave_idx_type merge_compute_minrun (octave_idx_type n); |
8700 | 288 |
289 template <class Comp> | |
290 void sort (T *data, octave_idx_type nel, Comp comp); | |
291 | |
292 template <class Comp> | |
293 void sort (T *data, octave_idx_type *idx, octave_idx_type nel, Comp comp); | |
294 | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
295 template <class Comp> |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
296 bool is_sorted (const T *data, octave_idx_type nel, Comp comp); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
297 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
298 template <class Comp> |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
299 void sort_rows (const T *data, octave_idx_type *idx, |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
300 octave_idx_type rows, octave_idx_type cols, |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
301 Comp comp); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
302 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
303 template <class Comp> |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
304 bool is_sorted_rows (const T *data, octave_idx_type rows, |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
305 octave_idx_type cols, Comp comp); |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
306 |
8814
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
307 template <class Comp> |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
308 octave_idx_type lookup (const T *data, octave_idx_type nel, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
309 const T& value, Comp comp); |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
310 |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
311 template <class Comp> |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
312 void lookup (const T *data, octave_idx_type nel, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
313 const T* values, octave_idx_type nvalues, |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
314 octave_idx_type *idx, octave_idx_type offset, Comp comp); |
de16ebeef93d
improve lookup, provide Array<T>::lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
8725
diff
changeset
|
315 |
9341
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
316 template <class Comp> |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
317 void lookupm (const T *data, octave_idx_type nel, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
318 const T* values, octave_idx_type nvalues, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
319 octave_idx_type *idx, Comp comp); |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
320 |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
321 template <class Comp> |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
322 void lookupb (const T *data, octave_idx_type nel, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
323 const T* values, octave_idx_type nvalues, |
9fd5c56ce57a
extend lookup capabilities
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
324 bool *match, Comp comp); |
4851 | 325 }; |
326 | |
7433 | 327 template <class T> |
328 class | |
329 vec_index | |
330 { | |
331 public: | |
332 T vec; | |
333 octave_idx_type indx; | |
334 }; | |
4851 | 335 #endif |
336 | |
337 /* | |
338 ;;; Local Variables: *** | |
339 ;;; mode: C++ *** | |
340 ;;; End: *** | |
341 */ |