Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: variable help
Date: Fri, 9 May 2008 19:39:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 67
Message-ID: <g0298n$dta$1@fred.mathworks.com>
References: <g01snh$q9j$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210361943 14250 172.30.248.35 (9 May 2008 19:39:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 9 May 2008 19:39:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:467636


"Katie " <kmcdon03@uoguelph.ca> wrote in message <g01snh$q9j
$1@fred.mathworks.com>...
> This is my first time using MATLAB,
> I am using this formula to compute sign patterns of 4x4 
> nilpotent matrices;
> A(n+1)=P*A(n)*inv(P) for n=1,2,3,4, where P is a random 
> matrix and A(1) is the 4x4 jordan. (This formula can be 
> repeated up to n=4 before sign patterns are duplicated, n 
> is the number of times that the random matrix (P) can be 
> used- just a subscript to define the variables). so what I 
> did was:
> A2=P*A1*inv(P)  
> A3=P*A2*inv(P)
> A4=P*A3*inv(P)
> A5=P*A4*inv(P)
> 
> I want to loop this until all the possible sign patterns 
> for nilpotent matrices are obtained, changing the random 
> matrix every 4 times. BUT obviously if I were to loop this 
> set of equations, for each new P the variables would just 
> be replaced each time since they are named the same. I have 
> tried using A(i) or A(n) like in the original equation, but 
> it is read as multiplication. How do I solve this problem? 
> or create some sort of subscript system so that the 
> subscript of the variables change each time. 
> THANK YOU! 
-----------
  What kind of "sign pattern" are you looking for?  Granted that each of the 
matrices A2, A3, A4, A5, etc. you generate from a given P will be nilpotent if 
A1 is, but I don't seen any repeating patterns of signs in them.

  However, to answer your question, you could always store your results in a 
four-dimensional array as follows.  Let nilpotent A and the number of 
repetitions N be given.

 P = randn(4,4,N);
 M = zeros(4,4,4,N);
 for k = 1:N
  p = P(:,:,k);
  for m = 1:4
   A = p*A*inv(p);
   M(:,:,m,k) = A;
  end
 end

  Alternatively you could place each 4 x 4 matrix A in a 16 x 1 arrangement in 
a three-dimensional 16 x 4 x N array.

 P = randn(4,4,N);
 M = zeros(16,4,N);
 for k = 1:N
  p = P(:,:,k);
  for m = 1:4
   A = p*A*inv(p);
   M(:,m,k) = A(:);
  end
 end

  Note that you should not do this for too large a value of N, because 
cumulative round-off errors will gradually erode the condition of A being 
nilpotent.  That is, the size of elements in A^4 would gradually increase in 
size due to accumulating round-off errors.  Note also that by chance some of 
the p matrices may be nearly singular which will no doubt make the round-
off error situation worse.

Roger Stafford