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 cneily  
#1 Posted : 17 February 2011 18:46:32(UTC)
cneily

Rank: Newbie

Groups: Registered
Joined: 01/02/2011(UTC)
Posts: 5
Location: Allston MA, USA

I have a calculation which involves dividing an expression which is the dot product of two 2-D column vectors (arrays) by another expression of the same kind. This quotient expression directly displays a correct result; however, if I try to store the quotient expression into a new variable it does not work, and displays the error message "Matrix must be square". I'm running version .89 (Build 8). This type of calculation is extremely common in mechanics problems so this is a serious issue.

Edited by moderator 21 May 2016 02:25:50(UTC)  | Reason: marked as solved

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

Offline omorr  
#2 Posted : 17 February 2011 20:31:59(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)
Hello,

I hope I understood you well. Here is an example:
A←mat(1,2,3,3,1)B←mat(6,5,6,3,1)C←mat(6,7,5,3,1)D←mat(6,1,-2,3,1)
This gives you the result:
{A*B}/{C*D}=1.03
This will give an arror of "Matrix must be square" if you do not supress Symbolic optimization:
C←{A*B}/{C*D}
If you right click on it and choose Optimization|Numeric or None you will have the numerical result:
C=1.03

Symbolic engine of SMath is going to interpred the dividing of two arrays A/B as A*inverse( B ). Therefore the array B must be a square matrix. You can avoid this by suppressing the Symbolic optimization. I hope I am right about it.

Regards,
Radovan


When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline TheWizEd  
#3 Posted : 19 February 2011 19:46:40(UTC)
TheWizEd


Rank: Advanced Member

Groups: Registered
Joined: 04/07/2010(UTC)
Posts: 178
Man
United States

Was thanked: 19 time(s) in 13 post(s)
Subtle SMath difference in the multiplication of two vectors.

For two column vectors A and B, A*B is the dot product, and equal 34 in the example above.

More rigorously AT*B ( A transpose times B ) is the dot product.

If A were a row vector A*B would return a matrix (34) using the values for A and B above.

Doesn't solve the problem but interesting.
Ed
Offline omorr  
#4 Posted : 19 February 2011 20:32:38(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)
Thank you Ed for the comment Good
TheWizEd wrote:

For two column vectors A and B, A*B is the dot product, and equal 34 in the example above.

More rigorously AT*B ( A transpose times B ) is the dot product.

If A were a row vector A*B would return a matrix (34) using the values for A and B above.

It seems you are right:
A*B=34
transpose(A)*B=mat(34,1,1)
I am in doubt now, as well as you are, that these two expressions should be the same and both should give a scalar. I am not quite sure about it. One explanation could be that the dot product is defined as the product of two vectors (column matrix). The second one might be ragarded as a matrix operation giving a matrix. However, I am also puzzled here:
{transpose(A)*B}/{transpose(C)*D}=1.03
I think this should be considered as a matrix expression and to give a matrix - but, surprisingly, it gives a scalar Sad ???

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline cneily  
#5 Posted : 19 February 2011 23:39:08(UTC)
cneily

Rank: Newbie

Groups: Registered
Joined: 01/02/2011(UTC)
Posts: 5
Location: Allston MA, USA

Fala mnogu Radovan. Your first post solved my problem. Clark N.
Offline omorr  
#6 Posted : 20 February 2011 09:56: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)
cneily wrote:
Fala mnogu Radovan. Your first post solved my problem. Clark N.

You are welcome Clark Good
Just do not hesitate to ask whatever you need. Someone will help you here.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Jean Giraud  
#7 Posted : 22 December 2015 18:56:19(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)
Originally Posted by: cneily Go to Quoted Post
if I try to store the quotient expression into a new variable it does not work, and displays the error message "Matrix must be square".


_________________ Few more ... "Matrix must be square" __________________

You can try using "Local variable definition"

I have 3 examples of compulsory "Local var def"
1. De Boor spline
2. Quadratic spline coeficients
3. Cubic l_p_c_splinecoefficients

Work sheet would help.

Jean

Users browsing this topic
Guest
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.