MathGroup Archive 1998

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

Search the Archive

Re: Please help: How to assert that an object is a matrix ???


  • To: mathgroup@smc.vnet.net
  • Subject: [mg12175] Re: Please help: How to assert that an object is a matrix ???
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Fri, 1 May 1998 03:08:27 -0400
  • Organization: University of Western Australia
  • References: <6hp8o5$cjl@smc.vnet.net>

jmt wrote:

> I'm trying to analyse the block structure of a matrix in Mathematica to
> figure out the best way to solve a system with this matrix.
> 
> For example I write
> 
>         A := {{GL,0,0,0,IL[1]},
>                 {GT,0,0,0,0},
>                 {0,GL,0,0, IL[2]},
>                 {0,GT,0,0,0},
>                 {0,0,GL,0,IL[3]},
>                 {0,0, GT,0,0},
>                 {0,0,0,GL,IL[4]},
>                 {0,0,0,GT,0}}
>         X := {XP1,XP2,XP3,XP4,XL}
>         B := {0,PT[1],0,PT[2],0,PT[3],0,PT[4]}
> 
> where GL, GT, IL, etc., are not elements but (sub-)matrices themself. I
> want to perform algebraic transformations on A, but I want element
> multiplication to be non-commutative and inversion to use Inverse
> rather than 1/element.
> 
> Can I somehow trick Mathematica to assume that elements are matrices?

What you want is _not_ built-in and MatrixQ (suggested by some other
respondents) only tests whether an object is a matrix.  Since I
understand that you want to keep objects such as GL as unspecified
symbolic objects, you need to build an appropriate non-commutative
algebra (there are packages at MathSource for non-commutative algebra).


As you noted, using Dot does not work:

In[4]:= B . A . X
Out[4]= GT XP1 PT(1)+GT XP2 PT(2)+GT XP3 PT(3)+GT XP4 PT(4)

since the term order is wrong (and the multiplication of these objects
should be matrix multiplication not ordinary Times).

Here is one way to get (implied) matrix multiplication to work (I'm
using the infix operator CircleDot).  Defining rules for a zero matrix
(0):

In[5]:= 0 \[CircleDot] (a_) = 0; (a_) \[CircleDot] 0 = 0; 

(typesetting is clumsy in ASCII -- this looks much better in a
Mathematica Notebook) and identity matrix (1):

In[6]:= 1 \[CircleDot] (a_) = a; (a_) \[CircleDot] 1 = a; 

we use the Inner product instead of Dot as follows.  Defining

In[8]:= (a_) \[CircleTimes] (b_) := Inner[CircleDot, a, b, Plus]

(using the infix operator CircleTimes) the correct result for the above
matrix product is

In[9]:= B \[CircleTimes] (A \[CircleTimes] X) Out[9]= PT[1] \[CircleDot]
GT \[CircleDot] XP1 + 
  PT[2] \[CircleDot] GT \[CircleDot] XP2 + 
  PT[3] \[CircleDot] GT \[CircleDot] XP3 + 
  PT[4] \[CircleDot] GT \[CircleDot] XP4

To get inversion to use Inverse rather than 1/element you will need to
add some more rules (perhaps using co... :-)

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: Sqrt problem - restated
  • Next by Date: [correction] Pattern matching more than once
  • Prev by thread: Re: Re: Pattern matching more than once
  • Next by thread: [correction] Pattern matching more than once