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

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline omorr  
#1 Posted : 08 September 2016 11:27:29(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
I do not believe such a feature would ever exits in SMath (it does not exit in Mathcad, Prime etc. as well) but I just had an urge to mention this (again). Actually, after such a long time I had to believe it is impossible to just make it real because it would have been made already. For example, if any of you have some time, just read the post from a Guest about 6 years ago (here)

This is very common in other math packages - to extract a matrix from a matrix by having vector indexes. See the picture,

submatrixaugmentstack.png

it is clear what we want, but there is an error message. Of course, we can do this by using submatrix(), augment(), stack() function, or by for loop - but it can be sometimes a night mare.

Regards,
Ra
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
thanks 3 users thanked omorr for this useful post.
on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC)

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

Offline Davide Carpi  
#2 Posted : 08 September 2016 13:45:48(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Very nice Radovan Good

something like this?

el_plus.sm (20kb) downloaded 214 time(s).

Edited by user 20 September 2016 11:31:31(UTC)  | Reason: marked as solved (implemented)

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 3 users thanked Davide Carpi for this useful post.
on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC)
Offline mkraska  
#3 Posted : 08 September 2016 15:38:41(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post

something like this?


Yes, that would be something like vector valued indices in matlab. I support this proposal.

This would be the little brother of Mathcad range variables (implicit iteration in assignments over vector valued indices, currently this requires for loops)

The availability of range variables mitigates the need for el_plus in Mathcad, because you can define your index vectors r and c, create range variables

i=1...length(r), j=1..length(c)

Result[(i,j) = M[(r[i,c[j)



Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 08/09/2016(UTC)
Offline omorr  
#4 Posted : 08 September 2016 16:21:03(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Very nice Radovan Good

something like this?

el_plus.sm (20kb) downloaded 214 time(s).


Just like that, very nice Davide Good . If you could make operators from these functions like el(M, that would be amazing OK

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#5 Posted : 08 September 2016 16:26:13(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Implemented (will be available in new build).

submatrix_via_el_1.png

Thank you, Radovan.
thanks 5 users thanked Andrey Ivashov for this useful post.
on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC)
Offline omorr  
#6 Posted : 08 September 2016 16:31:46(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: mkraska Go to Quoted Post
Originally Posted by: Davide Carpi Go to Quoted Post

something like this?


Yes, that would be something like vector valued indices in matlab. I support this proposal....


Exactly Martin, not just in Matlab but just in many other software where this kind of vector valued indices is a rather common (and an elegant) feature.

Regards,
Radovan

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#7 Posted : 08 September 2016 16:37:51(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
Implemented (will be available in new build).


You are very welcome Andrey, and I am really surprised about this very fast reaction of yours Oh my

I really do not know why this was not implemented earlier, and that is why I thought it was not possible.

I am glad that I was wrong Good

BTW, I consider this as a rather important feature.

Best Regards,
Radovan

Edited by user 08 September 2016 16:49:09(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#8 Posted : 08 September 2016 17:21:33(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
Implemented (will be available in new build).


Great. I assume that the feature isn't limited to range()-generated index vectors but can use arbitrary integer vectors.

Might be useful to have some shorthand for using all elements in a given dimension, perhaps an empty placeholder or "all" would do.

This would make the examples even more compact without adding problems for the reader.

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Andrey Ivashov  
#9 Posted : 08 September 2016 18:00:02(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Originally Posted by: mkraska Go to Quoted Post
I assume that the feature isn't limited to range()-generated index vectors but can use arbitrary integer vectors.

I did afraid someone may ask this question. Yes, I didn't introduce any limits there, you can even use matrices:

submatrix_via_el_3.png

Not sure what it means, but it works Crazy

He-he...

submatrix_via_el_4.png

Edited by user 08 September 2016 18:20:51(UTC)  | Reason: Not specified

thanks 4 users thanked Andrey Ivashov for this useful post.
on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC),  on 08/09/2016(UTC)
Offline omorr  
#10 Posted : 08 September 2016 19:18:29(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
This would be very appreciated and would give some new opportunities (and unexpected behavior).

Moreover, my greedy mind Wallbash does not let me go and bothers me with vector (matrix) indices for undefined variables. Here is the picture

symvecmat.PNG

I hope I made my point. The primer goal is to define a symbolic vector or matrix by this shorthand notation

Regards,
Ra
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#11 Posted : 08 September 2016 19:42:17(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
submatrix_via_el_5.png
thanks 1 user thanked Andrey Ivashov for this useful post.
on 08/09/2016(UTC)
Offline Andrey Ivashov  
#12 Posted : 08 September 2016 19:50:23(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
You can test new functionality in SMath Studio in the Cloud.

Here is my sandbox to play: http://smath.info/cloud/worksheet/gYFgZBnd.

Best regards, Andrey Ivashov.
thanks 1 user thanked Andrey Ivashov for this useful post.
on 08/09/2016(UTC)
Offline mkraska  
#13 Posted : 08 September 2016 20:07:38(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
If we could use the array valued indices on the left hand side of assignments, this would be close to having range variables like in Mathcad.

SS-14 could be closed.


Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 08/09/2016(UTC)
Offline Jean Giraud  
#14 Posted : 08 September 2016 20:19:18(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Sorry for "Mathcaders Primes", Mathcad 11 did it simple because
it supported index [indices] as argment. Smath does not.
Though submatrix look alike between Smath/Mathcad, except for
the indexing, they are not the same ...
Explain: In Mathcad, if you want to mirror a matrix [think of
an image], you just need to reverse the cols order. Smath does
not support the reverse cols order.

If you think others do something useful: YES, but useless for
practical Engineering works involving specific search in matrix
unless the software has been designed for.

When working with matrices [Smath, Mathcad ...] you need a
"Matrix Treasury" of utilities. You will have more than expected
in the attached document.

Thanks Radovan, most interesting subject.

Jean

Forum ForLoopList.gif

Utilities Matrix RemToDo [select row_col].sm (6kb) downloaded 41 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 08/09/2016(UTC)
Offline omorr  
#15 Posted : 08 September 2016 20:40:01(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: mkraska Go to Quoted Post
If we could use the array valued indices on the left hand side of assignments, this would be close to having range variables like in Mathcad.

SS-14 could be closed.




Sorry, Martin but it seems to me that at the moment we could use the array valued indices on the left hand side for the numerical or symbolical equal to, only. Not on the left hand side of the assignment operator. I hope I am(not) right.

Regards,
Ra
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#16 Posted : 08 September 2016 21:04:58(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Sorry for "Mathcaders Primes", Mathcad 11 did it simple because
it supported index [indices] as argment. Smath does not.
Though submatrix look alike between Smath/Mathcad, except for
the indexing, they are not the same ...
Explain: In Mathcad, if you want to mirror a matrix [think of
an image], you just need to reverse the cols order. Smath does
not support the reverse cols order.

If you think others do something useful: YES, but useless for
practical Engineering works involving specific search in matrix
unless the software has been designed for.

When working with matrices [Smath, Mathcad ...] you need a
"Matrix Treasury" of utilities. You will have more than expected
in the attached document.

Thanks Radovan, most interesting subject.

Jean

Forum ForLoopList.gif


Thank you Jean for the comment, and you are very welcome as always.

As Andrey introduced this new feature, you can just use intrinsic SS possibilities rather than writing new functions like your own, or as Davide wrote few ones in the post above, for extracting the values from a matrix in the way you want. I also mentioned, as you did, that this feature do not have neither Mathcad nor Prime(I think).

jean4.PNG

Regards,
Ra
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Jean Giraud  
#17 Posted : 09 September 2016 03:30:05(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
The snipet does it nice, does not work in 5346, and very glad it
does not work. What I need is a function, and designed as such
fully flexible rather than a local result. There is a bit of story
behind "MatrixBlocUser". Mathcad 11.2a [2003] came with the Excel
read function ++++, how many have used/exchanged work in the forum ?
NONE !!! except during the stage of designing DAEP, the collab had
to read "SunSpot" from his own Excel file.

The 3 functions [matrix utilities] have been vital to me, let's see:
The Project Team constructs the pipe data ... so many cols wide, so
many rows long. The piping designer needs certain cols by the rows
of pipe sizes wrt the project. The purchasing department needs other
set of columns, the transport trucker other set of cols ...
and Jean [the Instrument man] needs his own set of cols/rows.
So, everybody is happy with the "MatrixBlocUser".

Jean

MatrixBlocUser.gif

Utilities Matrix RemToDo [select row_col].sm (25kb) downloaded 51 time(s).
thanks 1 user thanked Jean Giraud for this useful post.
on 09/09/2016(UTC)
Offline mikekaganski  
#18 Posted : 10 September 2016 08:24:19(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
we cannot generate symb vector here
because in SS we support definition after usage


Hm. I just don't seem to understand...
Why isn't possible to re-interpret el(X,range(1,5)) as mat(el(X,1),el(X,2),el(X,3),el(X,4),el(X,5),5,1)? Aren't these expressions equivalent in any case? If value of X is undefined, this doesn't seem to change the situation...
Best regards,
Mike Kaganski
Offline omorr  
#19 Posted : 10 September 2016 11:34:07(UTC)
omorr


Rank: Administration

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

Was thanked: 318 time(s) in 268 post(s)
Originally Posted by: mikekaganski Go to Quoted Post
Originally Posted by: Andrey Ivashov Go to Quoted Post
we cannot generate symb vector here
because in SS we support definition after usage


Hm. I just don't seem to understand...
Why isn't possible to re-interpret el(X,range(1,5)) as mat(el(X,1),el(X,2),el(X,3),el(X,4),el(X,5),5,1)? Aren't these expressions equivalent in any case? If value of X is undefined, this doesn't seem to change the situation...


Thank you for your comment Mike. I did not understand this as well but had to accept what Andrey explained about it for granted.
BTW, this gave me headache many times when I had to define a symbolic vector, matrix (having the elements in standard notation like mat(el(X,1),el(X,2),el(X,3)...) with more than few variables. I hoped this might be the most simplest way.

There must be something simpler than this, or I just forgot how to perform this in as simpler way

Symbolic vector matrix

Regards,
Radovan

Edited by user 10 September 2016 12:34:57(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#20 Posted : 10 September 2016 12:36:15(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: Andrey Ivashov Go to Quoted Post
You can test new functionality in SMath Studio in the Cloud.

Here is my sandbox to play: http://smath.info/cloud/worksheet/gYFgZBnd.

Best regards, Andrey Ivashov.


The sandbox example shows the use of matrices as indices. The question is, how the rules for such indices are.

A straightforward rule would be that whatever you provide as index structure, it is accessed by linear indexing from 1..length() of the index structure.

The following example shows that the actual behaviour is different. The index matrices are indexed column-wise and not row-wise as the usual linear indexing works.

I propose to change this in order to be consistent with general linear indexing.


Example (cloud)

linind.PNG

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 4 users thanked mkraska for this useful post.
on 10/09/2016(UTC),  on 10/09/2016(UTC),  on 19/09/2016(UTC),  on 20/09/2016(UTC)
Users browsing this topic
Guest
2 Pages12>
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.