vanilla Max version of xray.jit.sift ?

Vincent Goudard's icon

Hi community,

I'm trying to create a vanilla Max version of Wesley Smith's xray.jit.sift (from its great xray package), but can't find an efficient way of doing it.

I'm sharing the version below, which relies on jit.bsort in a ugly way, but if someone has a better idea (using jit.pix/gen?), I would be please to know!

Max Patch
Copy patch and select New From Clipboard in Max.

Rob Ramirez's icon

looks very clever! If I was to do it I'd probably use v8 and the new copymatrixtoarray and copyarraytomatrix functions.

Vincent Goudard's icon

Thanks Rob! I hadn't though about this option and actually totally missed this amazing new feature! This will probably enable to skip the CPU-heavy bsort step.

Rob Ramirez's icon

well you still need to sort, but the internet tells me the default javascript array.sort (timsort) is O(n log n) and the bubble sort of jit.bsort is O(n²)

Vincent Goudard's icon

I would just iterate the sifting array and push the incoming data array element to the output array each time the sifting array element is 1.

So no sorting, but maybe not faster either? I would assume this is O(n)...

I'll compare and report here anyway.

Vincent Goudard's icon

Here it is, and despite not being as fast as Wesley's, it's not too bad.

vg.jit.sift.js
js 3.85 KB