03-14-2025 04:17 AM - edited 03-14-2025 04:18 AM
I have a two-dimensional array.
I understand that using Array Split / Replace Subarrays is recommended for this task. My questions are:
Thanks in advance!
03-14-2025 05:43 AM
Hi Max,
@maxnoder1995 wrote:
- At the top, I want to replace the values in the eleventh column with the lowercase version of the corresponding values from the fifth column.
- At the bottom, I want to replace the values in the eleventh column with the lowercase version of the corresponding values from the fifth column, but only if the value in the fifth column is 'A'.
03-14-2025 08:04 AM
Thank you for your feedback!
IPE modifies the array directly in memory, it avoids unnecessary data copies and improves efficiency, especially for large datasets.
What do you think about using IPE for this situation? Would it be a better choice than your suggested method?
Regarding my "bottom" task, I see where the confusion comes from. My intent is:
Given this requirement, what do you think is the best way to implement it efficiently?
03-14-2025 08:12 AM - edited 03-14-2025 08:13 AM
Hi Max,
@maxnoder1995 wrote:
Given this requirement, what do you think is the best way to implement it efficiently?
Please define "efficiently": execution speed, memory consumption, code size, code readability, …
(Usually you cannot get them all together.)
What is your typical array size?
Do your array elements contain just a single char or larger strings?
03-14-2025 08:23 AM
By "efficiently," I primarily mean execution speed and memory consumption, as I want to avoid unnecessary copies of the array. Code readability is also important, but performance is my main concern.
My typical array size is 10,000 × 12 (10,000 rows, 12 columns).
Each element contains a single character.
03-14-2025 08:27 AM
Hi Max,
@maxnoder1995 wrote:
My typical array size is 10,000 × 12 (10,000 rows, 12 columns).
Each element contains a single character.
So your data are 120000 chars, kept in a 2D array of strings of one char each!?
To make it more efficient you might keep your data in a 1D array of U8…
03-14-2025 08:32 AM
I understand your point about optimizing data storage, but my question is not about how to store the data more efficiently. The array size I mentioned was just an example to illustrate a large dataset.
My main question is about the use of Array Split / Replace Subarrays inside the In-Place Element Structure (IPE). Based on the image I shared, do you think this is the correct way to implement what I described? Or is there a better way to achieve this using IPE?
03-14-2025 08:36 AM
I think that for a modern PC, 10,000 rows is nothing; it will take just a few milliseconds to execute. You could potentially make it faster in theory if you wrapped this code into a C DLL (perhaps twice as fast), but you would introduce additional dependencies. Additionally, you could perform parallel processing with the help of a parallel for loop, but this would not make it much faster because there isn't much computation involved here. My recommendation is: don't worry too much, do it as most convenient for you. Or do you have very strict timing requirements and here is the bottleneck?
03-14-2025 08:40 AM
Hi Max,
@maxnoder1995 wrote:
My main question is about the use of Array Split / Replace Subarrays inside the In-Place Element Structure (IPE). Based on the image I shared, do you think this is the correct way to implement what I described? Or is there a better way to achieve this using IPE?
The compiler most often is smart enough to handle pairs of IndexArray/ReplaceArraySubset nicely. Using the IPE most often makes no difference…
@maxnoder1995 wrote:
I understand your point about optimizing data storage, but my question is not about how to store the data more efficiently. The array size I mentioned was just an example to illustrate a large dataset.
It's not about data storage alone!
So when it comes to "efficiency of code execution" it often helps to (re-)organize the data to allow more efficient data handling!
03-14-2025 08:52 AM - edited 03-14-2025 08:52 AM
Just one more thing — if you can reorganize the data to 12x10000 (12 rows, 10000 columns), then read/replacing characters in one row instead of a column will be definitely faster, because you will not get massive cache misses on access to the chars.