Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline ndtma  
#1 Posted : 07 September 2023 18:34:24(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
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 (16kb) downloaded 13 time(s).

Array_Pos2.png

Edited by user 07 September 2023 18:36:31(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 4 users thanked ndtma for this useful post.
on 07/09/2023(UTC),  on 07/09/2023(UTC),  on 08/09/2023(UTC),  on 07/04/2024(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline alyles  
#2 Posted : 08 September 2023 20:59:13(UTC)
alyles


Rank: Advanced Member

Groups: Registered
Joined: 23/03/2016(UTC)
Posts: 277
United States

Was thanked: 91 time(s) in 57 post(s)
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 (138kb) downloaded 6 time(s).
Array_Pos2.sm (45kb) downloaded 17 time(s).
Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
thanks 3 users thanked alyles for this useful post.
on 08/09/2023(UTC),  on 08/09/2023(UTC),  on 09/09/2023(UTC)
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.