Thanks a lot,
Thomas
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
> 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