问题
I have trying to multipy a column matrix and a row matrix in mathematica. But mathematica gives row matrix as a column matrix. so multipy function doesnt work. My codes are
`Y = Inverse[S];
Print["Y=", MatrixForm[Y]];
For[i = 1, i <= n, i++,
Subscript[P, i] = MatrixForm[S[[All, i]].Y[[i]]];
Print["CarpimS=", MatrixForm[S[[All, i]]]];
Print["CarpimY=", MatrixForm[Y[[i]]]];
Print["P=", Subscript[P, i]];
];
If anyone know this situation please answer
回答1:
This is a badly written question, so I'm going to have to make some guesses. Your code does not seem relevant to your question, with this exception: S[[All, i]].Y[[i]]
. Given your description, I'm guessing we can say that S
is k by k and so is Y
. If your goal is to Dot
the i-th column of S
by the i-th row of its inverse Y
, then what you have is fine: you produce each as a 1-d vector, and then produce a scalar product. But you say you're not getting what you want, so I'm guessing you want the outer product instead.
mS = IdentityMatrix[5];
mS[[3, 3]] = 99;
mY = Inverse[mS];
mS[[All, 3]].mY[[3]] (* scalar product *)
Outer[Times, mS[[All, 3]], mY[[3]]] (* outer product *)
If I guessed wrong, you will have to work on improving your question.
来源:https://stackoverflow.com/questions/28568343/finding-i-th-row-in-a-matrix-in-wolfram-mathematica