From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Alternative to matrix inverse?
Date: Wed, 22 Feb 2012 03:09:11 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <ji1m8n$di6$>
References: <jhvcv1$j70$> <ji0bpa$m1k$> <ji0ehf$28d$> <ji19ng$7jm$> <ji1c6a$eng$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1329880151 13894 (22 Feb 2012 03:09:11 GMT)
NNTP-Posting-Date: Wed, 22 Feb 2012 03:09:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:758450

"Jean-Philippe" wrote in message <ji1c6a$eng$>...
> Thank you for your suggestion on how to multiply repeatedly P as a 9 bands matrix. But, I am not sure how I can do this exactly.
- - - - - - - - - -
  You can multiply M by the k-th level diagonal of P above its main diagonal this way:

 M2 = [zeros(N,k),bsxfun(@times,M(:,1:N-k),diag(P,k).')];

or for diagonals below the main diagonal, indicated by negative k, this way:

 M2 = [bsxfun(@times,M(:,1-k:N),diag(P,k).'),zeros(N,-k)];

(You could use this single line for either kind of k:

 M2 = [zeros(N,k),bsxfun(@times,M(:,max(1,1-k):min(N-k,N)),...

but it would probably be a little slower in action.)  It would then be necessary to add all nine of these for the nine values of k for various diagonals in P.  The net effect of this would be the equivalent of the ordinary matrix multiplication M*P but with far fewer operations.

  Note: It would probably be best to precompute the quantities diag(P,k).' and zeros(N,k) or zeros(N,-k) so that they would not have to be repeatedly computed for each iteration step.

Roger Stafford