1
$\begingroup$

It seems to me Mathematica does not have an inbuilt matrix multiplication operator. The dot operator fails as such, as is even noted under "Possible Issues" in its documentation it inexplicably treats row vectors multiplied on the right as column vectors (similarly for column vectors multiplied on the left). The result of this bad behavior is that very reasonable expressions like:

OuterProd[x_,y_]:= x . ConjugateTranspose[y]

behave unexpectedly. The above should compute the outer product if $x$ and $y$ are column vectors, but instead we get the inner product of x and y, yikes! Can anyone explain to me why there is no inbuilt matrix multiplication in Mathematica for general $p\times q$ and $q\times r$ matrices?

$\endgroup$
5
  • 6
    $\begingroup$ MMA does not have the notion of raw/column vectors. Instead the rule for Dot is: Contract (sum) over the rightmost index of the left hand object and the leftmost index of the right object. $\endgroup$ Commented Feb 24, 2023 at 20:54
  • $\begingroup$ Try this outerprod[x_,y_]:=Outer[Times,x,Conjugate[y]]. $\endgroup$
    – mjw
    Commented Feb 24, 2023 at 21:21
  • $\begingroup$ My understanding is that built-in functions are capitalized, and (by convention) functions are best defined with lowercase letters. Probably so there is no confusion later. $\endgroup$
    – mjw
    Commented Feb 24, 2023 at 21:23
  • 3
    $\begingroup$ You want to use KroneckerProduct[x,Conjugate[y]]. $\endgroup$ Commented Feb 24, 2023 at 22:00
  • $\begingroup$ Actually Dot is exactly the function being asked for. $\endgroup$ Commented Feb 25, 2023 at 15:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.