Extracting matrix from a matrix - Extract a matrix from an existing matrix - "slicing" - Messages
This is very common in other math packages - to extract a matrix from a matrix by having vector indexes. See the picture,
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
Wrote
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)
WroteVery nice Radovan
something like this?
el_plus.sm (19 KiB) downloaded 263 time(s).
Just like that, very nice Davide


Regards,
Radovan
WroteWrote
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
WroteImplemented (will be available in new build).
You are very welcome Andrey, and I am really surprised about this very fast reaction of yours

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

BTW, I consider this as a rather important feature.
Best Regards,
Radovan
WroteImplemented (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.
Moreover, my greedy mind

I hope I made my point. The primer goal is to define a symbolic vector or matrix by this shorthand notation
Regards,
Ra
Here is my sandbox to play: http://smath.info/cloud/worksheet/gYFgZBnd.
Best regards, Andrey Ivashov.
SS-14 could be closed.
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
Utilities Matrix RemToDo [select row_col].sm (5 KiB) downloaded 59 time(s).
WroteIf 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
WroteSorry 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
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).
Regards,
Ra
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
Utilities Matrix RemToDo [select row_col].sm (24 KiB) downloaded 68 time(s).
Wrotewe 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...
WroteWrotewe 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
WroteYou 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)
-
New Posts
-
No New Posts