MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Working with lists of matrices.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22781] Re: Working with lists of matrices.
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 25 Mar 2000 03:58:19 -0500 (EST)
  • References: <8bfbjg$i3h@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Jordan,
Let's use

m := Table[Random[], {2}, {2}]
V = m
r = Table[m, {3}]

The following does not evaluate and, as  found, warns abour incompatible
shapes.
Inverse[V].r.V]

Below  is OK ( Evaluation gets Inverse[V] evaluated once, before the
function is applied instead of each time the Dot is evaluated)

Evaluate[Inverse[V].#.V] & /@ r

Using MatrixForm as below is OK

MatrixForm /@ %

But the MatrixForm is invisiblely wrapped around the matrices and provevets
some evaluation:

Evaluate[Inverse[V].#.V] & /@ %


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



"Jordan Rosenthal" <jr at ece.gatech.edu> wrote in message
news:8bfbjg$i3h at smc.vnet.net...
> Hi all,
>
> Does anybody have any pointers about how to work with lists of matrices.
> For example,  I have created the following function:
>
> %--------------------
> In[3]:=
> reflectionMatrix::usage =
>     "reflectionMatrix[theta] creates the matrix to reflect a point in a
line
> \
> oriented at theta radians.";
> reflectionMatrix[theta_] := Module[
>       {u = {{Cos[theta]}, {Sin[theta]}}},
>       IdentityMatrix[2] - 2u.Transpose[u]
>       ];
> SetAttributes[reflectionMatrix, Listable]
> %--------------------
>
> Notice that I set the attributes to Listable so that I can use it like:
>
> %--------------------
> In[29]:=
> r = reflectionMatrix[2*Pi/{12, 8, 6, 4, 3, 2}]
>
> Out[29]=
> {{{-(1/2), -(Sqrt[3]/2)}, {-(Sqrt[3]/2), 1/2}}, {{0, -1}, {-1, 0}},
> {{1/2, -(Sqrt[3]/2)}, {-(Sqrt[3]/2), -(1/2)}},
>   {{1, 0}, {0, -1}}, {{1/2, Sqrt[3]/2}, {Sqrt[3]/2, -(1/2)}}, {{-1, 0},
{0,
> 1}}}
> %--------------------
>
> Now lets say I want to form a list of the matrices Inverse[V].Ak.V where
the
> matrices Ak are taken from the above list and V is an arbitrary matrix.  I
> tried
>
>    V = {{1,0},{0,1}}
>    Inverse[V].r.V
>
> but I get errors about incompatible tensor shapes.  So how do I do this?
>
> Also, any tips on using MatrixForm in this situation to format the
results?
> I am using MatrixForm /@ r which works fairly well, but wasn't sure if
this
> is the right technique.
>
> Thanks ahead of time,
>
> Jordan
>
>
>
>
>




  • Prev by Date: Re: Mathematica 4.0.1 and XFree86 4.0
  • Next by Date: Re: Mathlink for Java
  • Previous by thread: Re: Working with lists of matrices.
  • Next by thread: Exporting formulae as GIFs