Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline ndtma  
#1 Posted : 12 January 2020 12:09:32(UTC)
ndtma


Rank: Advanced Member

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

Was thanked: 75 time(s) in 52 post(s)
Observed errors with nested arrays as shown in SS 7251.
Vectorize Errors in Nested Arrays.sm (46kb) downloaded 17 time(s).

Vectorize Errors in Nested Arrays.png

Edited by user 12 January 2020 12:11:02(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
thanks 1 user thanked ndtma for this useful post.
on 12/01/2020(UTC)
Offline Jean Giraud  
#2 Posted : 12 January 2020 17:27:23(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,677
Canada

Was thanked: 792 time(s) in 628 post(s)
Originally Posted by: ndtma Go to Quoted Post
Observed errors with nested arrays as shown in SS 7251.

There is no error, as well SS 6179.
Smath native vectorize is superior to MCD, then more instructions.
Cheers ... Jean

Vectorize Errors in Nested Arrays Doctored.sm (10kb) downloaded 11 time(s).

VectorizeNest.PNG

Offline ndtma  
#3 Posted : 12 January 2020 20:13:45(UTC)
ndtma


Rank: Advanced Member

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

Was thanked: 75 time(s) in 52 post(s)
May be I have not properly understood the vectorize operator.
Thank you Jean.
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline mkraska  
#4 Posted : 12 January 2020 21:35:14(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,592
Germany

Was thanked: 870 time(s) in 552 post(s)
Originally Posted by: ndtma Go to Quoted Post
Observed errors with nested arrays as shown in SS 7251.


I think the observed behaviour matches the following hypothesis on how vectorize() operates:
- search for array-valued operators in the expression (before executing any part of the vectorized expression). in your case it is Z.
- Determine length of these operators. In your case length(Z)=4.
- If all non-scalar operators share the same length, then generate a loop for index = 1..length. Otherwise complain about length mismatch. In your case this iterates over the four sub-matrices.
- within the loop, apply the original expression, with the non-scalar expression replaced by the indexed one. In your case extraction of first element and subsequent rounding is applied to each of the four subvectors.
- return a vector with the stacked results of each iteration.

In the second case, the error results from failing to extract element number four from the last two vectors (having less than 4 elements).

The hypothesis doesn't, however, explain the last error "Result is above...".


Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 3 users thanked mkraska for this useful post.
on 12/01/2020(UTC),  on 13/01/2020(UTC),  on 13/01/2020(UTC)
Offline omorr  
#5 Posted : 12 January 2020 21:36:52(UTC)
omorr


Rank: Administration

Groups: Registered, Administrators, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,734
Man
Serbia

Was thanked: 312 time(s) in 266 post(s)
Hello,

For this case short answer will be that we have to use both/all indexes for the nested arrays.
As Martin explained, we have to be careful about how the things are going on with vectorize operator.

nested.png

Regarding the famous uninformative "Results is above max. allowed positive number." here is another example whit this error.

abovemaxi.png

Regards,
Radovan

Edited by user 12 January 2020 21:53:21(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 1 user thanked omorr for this useful post.
on 13/01/2020(UTC)
Offline mkraska  
#6 Posted : 12 January 2020 21:56:22(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,592
Germany

Was thanked: 870 time(s) in 552 post(s)
Originally Posted by: omorr Go to Quoted Post
Hello,

For this case short answer will be that we have to use both/all indexes for the nested arrays.
As Martin explained, we have to be careful about how the things are going on with vectorize operator.



Radovan, unfortunately your example isn't consistent with my hypothesis Sad
Single and double index el(Z,1) and el(Z,1,1) both return exactly the same result (first submatrix) if applied on the canvas.
So there is no hint why to expect different results when applying vectorize().

Can the developers please shed some light on this?
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://en.smath.info/wi...th%20with%20Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 12/01/2020(UTC)
Offline Jean Giraud  
#7 Posted : 12 January 2020 22:33:08(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,677
Canada

Was thanked: 792 time(s) in 628 post(s)
Originally Posted by: ndtma Go to Quoted Post
May be I have not properly understood the vectorize operator.
Thank you Jean.

Thank you as well NDTMA, very educative example.
You can have more otherwise ... Ah !
Cheers ... Jean

Vectorize Nest_Sub.sm (19kb) downloaded 17 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 13/01/2020(UTC)
Offline Jean Giraud  
#8 Posted : 12 January 2020 22:58:32(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,677
Canada

Was thanked: 792 time(s) in 628 post(s)
Originally Posted by: mkraska Go to Quoted Post
Can the developers please shed some light on this?

If you have red or not as demanded, IMHO: the bug is SS 7251.
Revisit the last attached Vectorize Nest_Sub.sm
Offline Jean Giraud  
#9 Posted : 12 January 2020 23:59:20(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,677
Canada

Was thanked: 792 time(s) in 628 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
If you have red or not as demanded, IMHO: the bug is SS 7251.
Revisit the last attached Vectorize Nest_Sub.sm


VectorizeNestMore.PNG

Offline ndtma  
#10 Posted : 13 January 2020 07:59:14(UTC)
ndtma


Rank: Advanced Member

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

Was thanked: 75 time(s) in 52 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: Jean Giraud [url=/forum/yaf_postsm60333_Vectorize-Errors-in-Nested-Arrays-in-SS-7251.aspx#post60333][/url]If you have red or not as demanded, IMHO: the bug is SS 7251.
Revisit the last attached Vectorize Nest_Sub.sm


Thank you Jean. No errors in 7251.
Vectorize_Ex_Jean_7251.png

Also many thanks to Martin and Omorr for your comments.
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Jean Giraud  
#11 Posted : 13 January 2020 17:18:48(UTC)
Jean Giraud


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 4,677
Canada

Was thanked: 792 time(s) in 628 post(s)
Originally Posted by: ndtma Go to Quoted Post
Thank you Jean. No errors in 7251

Hello Collab from so far away,
maybe, that's what you were after ?
Cheers ... Jean

roundNest.PNG

Vectorize Nest_Sub.sm (24kb) downloaded 11 time(s).
Offline ndtma  
#12 Posted : 13 January 2020 20:32:29(UTC)
ndtma


Rank: Advanced Member

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

Was thanked: 75 time(s) in 52 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Hello Collab from so far away,
maybe, that's what you were after ?
Cheers ... Jean


Yes. I also did it using a traditional loop method.
But yours is more elegant.
Thanks.
Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Users browsing this topic
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.