MathGroup Archive 2006

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

Search the Archive

Re: Matrix Multiplication (with a twist)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69000] Re: Matrix Multiplication (with a twist)
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sat, 26 Aug 2006 02:04:43 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <ecmhcp$9kl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Bruce Colletti wrote:
> For matrix A = {{e,f},{g,h}} and B = {{a,b},{c,d}}, Mathematica returns their product 
> 
> A.B = {{ae+cf,be+df},{ag+ch,bg+dh}}
> 
> However, I want to treat multiplication of numeric variables as noncommutative in order to instead obtain the result
> 
> {{ea+fc, eb+fd},{ga+hc,gb+hd}}
> 
> How would this be done in v5.2?  Thanks.
> 
> Bruce
> 
Hi Bruce,

You could clear temporarily the attribute Orderless from the list of 
attributes of the built-in function Times. For instance,

A= { { e, f}, { g, h} };
B= { { a, b}, { c, d} };
Attributes[Times]
--> {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}

ClearAttributes[Times, Orderless]
Attributes[Times]
--> {Flat, Listable, NumericFunction, OneIdentity, Protected}

A . B
--> {{e*a + f*c, e*b + f*d}, {g*a + h*c, g*b + h*d}}

SetAttributes[Times, Orderless]
Attributes[Times]
--> {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected}

HTH,
Jean-Marc


  • Prev by Date: Re: Where Style Sheets are located
  • Next by Date: General--IF condition in Plot3D
  • Previous by thread: RE: Matrix Multiplication (with a twist)
  • Next by thread: Re: Matrix Multiplication (with a twist)