[SS-3525] assigning element to matrix resets its size

[SS-3525] assigning element to matrix resets its size - matrix created artificially - Messages

#1 Posted: 3/21/2018 8:28:13 PM
m227

m227

4 likes in 29 posts.

Group: User

Hi, what am I doing wrong?
2018-03-22 00_22_13-SMath Studio - [error.sm_].png

m matrix looses it's contents and dimensions after I assigned a single element.

Edit: I found an ugly fix. First I have to create matrix of (2;1) instead (2;0) elements. After all augmenting I have to use submatrix to get rid of first column.

Michal
#2 Posted: 3/22/2018 1:04:56 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Just like this.

sub.PNG
#3 Posted: 3/22/2018 1:49:29 AM
CBG

CBG

77 likes in 312 posts.

Group: User

Something like this?


Ass_elem_Matrix.png


Ass_elem_Matrix.sm (4 KiB) downloaded 38 time(s).


Best regards


Carlos
#4 Posted: 3/22/2018 7:57:51 AM
m227

m227

4 likes in 29 posts.

Group: User

Ok, I probably did not clarify my real needs.

I have some matrices. I just exclude single column from each of them and then I glue them together.
So in my real sheet I never glue the same matrix twice.
Here comes another example where I try to augment some vectors to new matrix.
I have many vectors and they are indexed so I can use program to augment them in a loop.

2018-03-22 11_54_49-SMath Studio - [error.sm_].png
#5 Posted: 3/22/2018 8:08:01 AM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

The issue is in the type recognition on the left hand side.

m is a matrix-valued expression rather than a matrix (expression with mat() being the top level object). We had this already with index values being expressions instead of variables.

Thus, the existing m is not recognized as a matrix and therefore not modified but overwritten.

You need to make sure that m is actually stored as matrix, i.e. by applying eval() or by just evaluating numerically (you did symbolically)

I'd prefer SMath to actually check if m evaluates to a matrix and then deciding what to do.

Ass_elem_Matrix_Kr.sm (5 KiB) downloaded 41 time(s).
2018-03-22 12_06_51-SMath Studio - [Ass_elem_Matrix.sm_].png
2018-03-22 12_11_02-SMath Studio - [Ass_elem_Matrix_Kr.sm_].png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 users liked this post
Davide Carpi 3/22/2018 8:16:00 AM, sergio 3/22/2018 9:00:00 AM
#6 Posted: 3/22/2018 10:21:30 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Ok, I probably did not clarify my real needs.


That will handle your projects more conveniently.

AugmentMatrix.PNG

Poland.sm (15 KiB) downloaded 40 time(s).

#7 Posted: 3/24/2018 3:39:26 PM
m227

m227

4 likes in 29 posts.

Group: User

Thank you for both your answers. It clarified the situation.
However I think if something looks like matrix it should behave like one. But it is not.
The history of building a matrix affects it
And I treat it as a flaw.
2018-03-24 19_36_00-SMath Studio - [error.sm].png
error_matrices_notequal.sm (8 KiB) downloaded 36 time(s).
#8 Posted: 3/24/2018 7:01:20 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

The flaw is that m is not evaluated before applying the by-element assignment.
you can, however, enforce this by setting the previous two assignments to numeric optimization in the context menu.

This complies to the survival rule "never use symbolic optimization unless you know what you are doing".

Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#9 Posted: 3/25/2018 5:02:23 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

This complies to the survival rule "never use symbolic optimization unless you know what you are doing".



Can't be more right Martin !
I vote for default calculation Numeric, instead of Symbolic.
#10 Posted: 3/26/2018 5:10:28 AM
m227

m227

4 likes in 29 posts.

Group: User

Wrote

The flaw is that m is not evaluated before applying the by-element assignment.
you can, however, enforce this by setting the previous two assignments to numeric optimization in the context menu.



Your solution works, it was enough to set it for first assignment. I have to comment it in code at least. Thank you.
However I am programmer and for program to be clear everything shall be set in a visible manner (in code). So fiddling with some options in context menu instead of setting them by code is unacceptable.
#11 Posted: 3/26/2018 8:22:01 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

So fiddling with some options in context menu instead of setting them by code is unacceptable.


A collection is just a collection.
A matrix supports all matrix operation for concluding a project
Generally, a matrix results from the project itself
Smath works by itself, not from invented not compatible code.
Please be more specific about what you are attempting.

MatrixCollection.PNG
#12 Posted: 3/26/2018 8:55:23 AM
m227

m227

4 likes in 29 posts.

Group: User

(...)
Wrote


Please be more specific about what you are attempting.



First of all, I want to say, that I like SMath Studio very much and I use it, whenever I have to prepare some calculations for students or in my projects. I once was co-author of book covering exercises in Mathcad. SMath studio is small, uncluttered and (mostly) does what is expected to do. And is free so I don't have to manage licenses, take care of keys and so on. I once paid some bucks to the author and gladly repeat it as program gets better.

But coming back to my being more specific: If I see matrix in the code (not necessarily mine) I expect it to behave like matrix and that's all.
Let's assume I got quite large project which can also reference to other files by include("..." ) add-in. So I have two matrices in front of me (see screenshot). I want to change a single element in each of them. Shall I go back and read all the code before to check if it can be done? The general question is: if we have two identical looking chairs shall we expect one of them not to be a chair but a briefcase with a chair in it?
2018-03-26 13_50_18-SMath Studio - [error_matrices_notequal.sm_].png
#13 Posted: 3/26/2018 11:23:55 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

So I have two matrices in front of me (see screenshot)



Your original 'm' is a matrix.
Your concluded 'm' is NOT a matrix, simply a collection.
You can't apply any matrix calculation.
Make it a matrix and continue the project.

MakeMatrix.PNG
#14 Posted: 3/26/2018 12:29:20 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

Wrote

[
However I am programmer and for program to be clear everything shall be set in a visible manner (in code). So fiddling with some options in context menu instead of setting them by code is unacceptable.


You might vote for https://smath.info/bts/Issues/IssueDetail.aspx?id=19. This feature request is exactly tailored to your need.
It is a long standing issue with second highest voter rate ever, yet no sign of hope out there...

Yet I encourage all users to file bug reports instead or at least in addition to forum posts on bugs, because forum discussions rapidly fade out of sight, whereas the bug tracking system is transparent and user friendly. I did that already for now, see SS 3525.

And SS-19 is not typical for the responsiveness of the developers, sometimes you get the fix within hours.
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
1 users liked this post
Davide Carpi 3/27/2018 6:15:00 AM
#15 Posted: 3/27/2018 6:06:23 AM
m227

m227

4 likes in 29 posts.

Group: User

Wrote

Wrote

So I have two matrices in front of me (see screenshot)


Your original 'm' is a matrix.
Your concluded 'm' is NOT a matrix, simply a collection.
(...)


Ok, but you probably agree that they look the same when displayed. So I think there is a problem that they are not distinguishable (by looking at them) as long as you don't make any operation on each one.
#16 Posted: 3/27/2018 8:17:35 AM
Ruben Sidranski

Ruben Sidranski

17 likes in 463 posts.

Group: User

I'm wondering, are you looking for an array to display differently than a matrix? I had an issue reviewing a sheet where this would have helped. In Mathcad, an array looks like an spreadsheet while a matrix looks just like it does now
#17 Posted: 3/27/2018 9:27:25 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Ok, but you probably agree that they look the same when displayed.



Sorry, but can't help more.
You must have projects that produce something.
#18 Posted: 3/27/2018 11:23:11 AM
m227

m227

4 likes in 29 posts.

Group: User

Wrote

I'm wondering, are you looking for an array to display differently than a matrix? I had an issue reviewing a sheet where this would have helped. In Mathcad, an array looks like an spreadsheet while a matrix looks just like it does now


I wouldn't care if they were the same thing. But they aren't.
Probably Mathcad approach would have helped.
#19 Posted: 3/27/2018 7:14:07 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I'm wondering, are you looking for an array to display differently than a matrix?I had an issue reviewing a sheet where this would have helped.In Mathcad, an array looks like an spreadsheet while a matrix looks just like it does now



I understand nothing w/o the problem sheet.

CellArray.sm (9 KiB) downloaded 40 time(s).
#20 Posted: 3/27/2018 7:42:24 PM
Ruben Sidranski

Ruben Sidranski

17 likes in 463 posts.

Group: User

Here you go Jean.
Is this a bug or a feature? Array or vector.sm (25 KiB) downloaded 43 time(s).
  • New Posts New Posts
  • No New Posts No New Posts