Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Matrix-Multiplication w NonCommutative Entries?

520 views
Skip to first unread message

Thomas

unread,
Jan 7, 2009, 4:07:39 AM1/7/09
to
Hi there,
I want to multiply matrices with quaternionic entries in Mathematica. Dot (.) uses normal multiplication (*) for the entries. I need to change this to NonCommutativeMultiply (**) Then this would work with the Quaternions package.
Does anybody know, how to do this?

Thanks a lot,

Thomas

Jens-Peer Kuska

unread,
Jan 7, 2009, 7:10:33 AM1/7/09
to
Hi,

use Inner[] instead of Dot[] because:

Inner[f,list1,list2,g] is a generalization of Dot in which f plays the
role of multiplication and g of addition.

Regards
Jens

Jean-Marc Gulliet

unread,
Jan 7, 2009, 7:12:06 AM1/7/09
to
In article <gk1rcr$olc$1...@smc.vnet.net>, Thomas <t.i...@gmx.de> wrote:

> I want to multiply matrices with quaternionic entries in Mathematica. Dot (.)
> uses normal multiplication (*) for the entries. I need to change this to
> NonCommutativeMultiply (**) Then this would work with the Quaternions
> package.

Inner[NonCommutativeMultiply, m1, m2, Plus]

Say we have two matrices m1 and m2. There Dot[] product m1.m2 is
equivalent to the inner product Inner[Times, m1, m2, Plus]; therefore
Inner[NonCommutativeMultiply, m1, m2, Plus] should do want you are
looking for.


In[1]:= m1 = {{a1, b1}, {c1, d1}};
m2 = {{a2, b2}, {c2, d2}};
m1.m2

Out[3]= {{a1 a2 + b1 c2, a1 b2 + b1 d2}, {a2 c1 + c2 d1,
b2 c1 + d1 d2}}

In[4]:= Inner[Times, m1, m2, Plus]

Out[4]= {{a1 a2 + b1 c2, a1 b2 + b1 d2}, {a2 c1 + c2 d1,
b2 c1 + d1 d2}}

In[5]:= %% === %

Out[5]= True

In[6]:= Inner[NonCommutativeMultiply, m1, m2, Plus]

Out[6]= {{a1 ** a2 + b1 ** c2,
a1 ** b2 + b1 ** d2}, {c1 ** a2 + d1 ** c2, c1 ** b2 + d1 ** d2}}


Regards,
--Jean-Mac

0 new messages