Commit badcf7d
committed
Replace np.unique function with a simpler set of calls that exploits sorting
The np.unique function makes no assumption about whether or not the input
is sorted. Since we've done the work to sort the list of morton codes and
face id pairings, computing the start, count, and unique keys of the hash table
can be done with just three operations:
1. Find the indices where the morton codes in the sorted list change value -
prepending this list of indices with [0] gives the starting indices for a
CSR format matrix
2. The keys for the hash table are just the unique morton code values. Once
we know the `start` indices, we can quickly index for the unique morton codes
3. The count (the number of faces per morton code / hash table key) is just the
np.diff of the `start` indices.
This results in a minor improvement in construction speed.1 parent 35dd7d9 commit badcf7d
1 file changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
288 | 289 | | |
289 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
290 | 293 | | |
| 294 | + | |
291 | 295 | | |
292 | 296 | | |
293 | 297 | | |
294 | 298 | | |
295 | | - | |
296 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
297 | 307 | | |
298 | 308 | | |
299 | 309 | | |
| |||
0 commit comments