1 Pages (2 items)
Array position - another approach - Messages
#1 Posted: 9/7/2023 12:34:24 PM
Hi,
I remember there were some useful posts to find the positions in an array
satisfying defined conditions.
Another approach is attached.
Array_Pos2.sm (15 KiB) downloaded 76 time(s).

I remember there were some useful posts to find the positions in an array
satisfying defined conditions.
Another approach is attached.
Array_Pos2.sm (15 KiB) downloaded 76 time(s).
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
5 users liked this post
Oscar Campo 9/7/2023 4:57:00 PM, oscar mauricio 4/7/2024 10:46:00 AM, francesco rapuano 1/8/2025 11:06:00 PM, sergio 9/7/2023 12:38:00 PM, Alvaro Diaz Falconi 9/8/2023 3:06:00 PM
#2 Posted: 9/8/2023 2:59:13 PM
To expand on this concept further, I generally avoid using augment/stack functions with vectors of indeterminate size. The reason being that there is generally quite a bit of overhead in using those functions when it comes to execution time. I propose an alternative method shown here. Firstly we perform the test on the input matrix to determine the size of the result vector and location of results in input matrix. Then we instantiate the result vector and fill it in. To demonstrate the difference in execution I've also created a 100x100 input vector and timed the execution of both algorithms. The execution time difference becomes more apparent the larger the input matrix becomes.
Array_Pos2.pdf (137 KiB) downloaded 65 time(s).
Array_Pos2.sm (44 KiB) downloaded 79 time(s).
Array_Pos2.pdf (137 KiB) downloaded 65 time(s).
Array_Pos2.sm (44 KiB) downloaded 79 time(s).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
4 users liked this post
francesco rapuano 1/8/2025 11:08:00 PM, Alvaro Diaz Falconi 9/8/2023 3:07:00 PM, NDTM Amarasekera 9/8/2023 4:37:00 PM, sergio 9/9/2023 5:57:00 AM
1 Pages (2 items)
-
New Posts
-
No New Posts