# Matrix operations in "Inertia Versus Gravity in 3d" Demonstration

GROUPS:
 I have been deconstructing Michael Schreiber's Inertia Versus Gravity In 3D author.nb from the Demo project.  The main work is done in the inertiaversusgravity3D function which I have "exploded" below. inertiaversusgravity3D[m1_, m2_] := Module[    {tt}, {-m2 + 2 m1 + (       Plus @@ # & /@ Map[         With[           {tt = (#[[1]]^2 + #[[2]]^2 + #[[3]]^2)},           If[tt > 0., #/tt, {0., 0., 0.}]           ]          &,         (1 - IdentityMatrix[Length[m1]]) Outer[Plus, -m1, m1,1], {2}]) , m1}   ];{m = N[pts RandomReal[{-1, 1}, {pts, 3}]]}(* The first call would be *){m1,m2}=inertiaversusgravity3D[m, m]My question is in the line:(1 - IdentityMatrix[Length[m1]]) Outer[Plus, -m1, m1,1], {2}])This looks like it is going to multiply two matricies but there is not a default multiplication operation either the dot or cross product must be specified.  When I , define m1 manually and look at the results of this line I get  Outer[Plus, -m1, m1,1], {2}] unchanged.My question is should the matricies be dotted together and is the operation Matrix1  Matrix2 (Matrix1 * Matrix2) defined?  If so what is the definition.Any insight would be appreciated.Mark
4 years ago
5 Replies
 Daniel Lichtblau 2 Votes If m1 is a vector of length n, the Outer makes it an nxn matrix. The multiplication is coordinate-wise. The matrix on the left is in effect a mask that makes diagonal elements of the one on the right zero and leaves others alone.
4 years ago
 Doesn't the Outer[Plus,-m1,m1,1] guarntee that the diagonal will be 0? Thanks,Mark