matrix row function

matrix row function - Messages

#1 Posted: 10/25/2010 4:55:02 AM
flyback

flyback

0 likes in 5 posts.

Group: User

If I try to square a row-function-element I get an error:

[LIVE width=322 height=265]http://smath.info/live/?file=1734[/LIVE]
#2 Posted: 10/25/2010 5:39:19 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello,

SMath uses column matrix as a vector. Therefore:
[MATH=eng]mat(4,5,6,3,1)^2=77[/MATH]
[MATH=eng]mat(4,5,6,3,1)*mat(4,5,6,3,1)=77[/MATH]
[MATH=eng]4*4+5*5+6*6=77[/MATH]
represents scalar products of two vectors, resulting in scalar.
However, row matrix can not be used this way
[MATH=eng]mat(4,5,6,1,3)^2=#@#[/MATH]
It is regarded as matrix product of two matrices, resulting in matrix.
[MATH=eng]mat(4,5,6,1,3)*mat(4,5,6,1,3)=#@#[/MATH]
Of course, it is not possible - wrong numbers of rows/columns. You can do only this:
[MATH=eng]mat(4,5,6,1,3)*mat(4,5,6,3,1)=mat(77,1,1)[/MATH]
[MATH=eng]mat(4,5,6,3,1)*mat(4,5,6,1,3)=mat(16,20,24,20,25,30,24,30,36,3,3)[/MATH]

Regards,
Radovan


When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 10/25/2010 6:14:43 AM
flyback

flyback

0 likes in 5 posts.

Group: User

Thanks a lot for the fast response.
In my case the matix is used as a table. Every column is a dataset.
With one row I can calculate the results for every dataset. Is there any other option to solve my problem?
#4 Posted: 10/25/2010 6:31:26 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

You are welcome,

If I understood you well, you need the element-wise matrix operations.
These operations need to be done with loops and specific matrix elements.
For instance:
[MATH=eng]A←5[/MATH]
[MATH=eng]B←4[/MATH]
[MATH=eng]C←mat(4,5,6,1,3)[/MATH]
[MATH=eng]for(i,range(1,length(C)),el(E2,1,i)←{(A-el(C,1,i))^2}/[/MATH]
[MATH=eng]E2=mat(0.25,0,0.25,1,3)[/MATH]

I hope this helped. If not, just be more specific please.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#5 Posted: 10/25/2010 6:54:47 AM
flyback

flyback

0 likes in 5 posts.

Group: User

Well done, I'm happy...
  • New Posts New Posts
  • No New Posts No New Posts