08-23-2023 04:36 AM
Hello
I am plotting some data in 3D and is rather slow... so I am trying to decimate an array to a fixed length (I know the decimate function, it's not that simple) :
If I have an array of length N and want to decimate to an array of length M (both N and M are decided at runtime). I made something like this, I am wondering if you have a better way.
It's not that important, this thing works for me, but just wondering if there is a better way.
Thanks
Solved! Go to Solution.
08-23-2023 04:40 AM
Hi nitad,
@nitad54449 wrote:
I made something like this, I am wondering if you have a better way.
08-23-2023 05:03 AM
Hi
The divide in the loop is a rookie mistake,... but I don't get your second comment. I want to delete those indexes (or should I do it the other way around ? I mean I could use a conditional indexer, I was thinking this is slow).
(well, slow, is maybe not that important but the "array in" has typically 2k to 10k length, each element is a cluster with 5 to 10 arrays of 100 to 500 doubles...)
thanks
08-23-2023 06:06 AM
Hi nitad,
@nitad54449 wrote:
I want to delete those indexes (or should I do it the other way around ? I mean I could use a conditional indexer, I was thinking this is slow).
I don't use those green functions (OpenG? GPower?) so I cannot comment in their purpose just from looking at the image.
When I "decimate" an array I typically pick the elements that should remain instead of deleting all other elements - should be more performant when the decimation factor is >>1…
@nitad54449 wrote:
the "array in" has typically 2k to 10k length, each element is a cluster with 5 to 10 arrays of 100 to 500 doubles...)
Your "array in" is a 1D array of I32 values according to the image!? No clusters, no DBLs…
08-23-2023 07:12 AM
Hi
I put a simplified version, here is a real life vi
it takes 27 msec on my computer (the green stuff is openG)
08-23-2023 07:25 AM
08-23-2023 07:38 AM
Hi
Here it is in 2019
A simpler version without OpenG (11 msec now), Vi attached.
08-23-2023 08:44 AM
"Delete from array" should never be inside a tight loop! I'll have a look.
08-23-2023 08:53 AM - edited 08-23-2023 08:54 AM
Hi nitad,
so you want to pick 200 elements out of ~3700 elements, so the solution is to delete ~3500 elements from the array?
I repeat: I would just pick the elements I need:
You may use a different rounding (or no rounding at all as ToI32 will also round)…
08-23-2023 09:24 AM
Hi
Nice, this Ramp stuff..
Now is in the msec range !
Thanks