MathGroup Archive 2001

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

Search the Archive

Re: Element-by-element Matrix Multiplication

  • To: mathgroup at
  • Subject: [mg30085] Re: [mg30070] Element-by-element Matrix Multiplication
  • From: Rob Pratt <rpratt at>
  • Date: Fri, 27 Jul 2001 03:52:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


I don't think you really mean element-by-element or non-square.  For
Markov chains, you want the kth power of the matrix, where the usual
matrix multiplication is used.  Also, the Markov matrix has rows and
columns indexed by the same set (the state space), so it will be square.
Note that for the usual matrix multiplication X*X to even be defined, X
must be a square matrix.

I think MatrixPower[X, 25] is what you want.  But X^25 (whose FullForm is
Power[X, 25]) will take the element-by-element powers (even for non-square
matrices), since Power is Listable.  That is, the new matrix will have
entries x[i,j]^25, where x[i,j] is the (i,j) entry of the original matrix

Rob Pratt
Department of Operations Research
The University of North Carolina at Chapel Hill

rpratt at

On Thu, 26 Jul 2001, Mark Coleman wrote:

> Greetings,
> I'm searching for an efficient way to calculate and element-by-element
> matrix multiplication for non-square matrices such that when I pass the
> module an integer 'k', it multplies the matrix by itself 'k' times. For
> instance, if k=25, then
>      matMult[k,X] multiplies X*X*X..... 25 times.
> Note that this problem comes about in calculating k-step Marvok transition
> matrices. For my application, this function call is embedded in a Monte
> Carlo simulation, so efficiency is important. The methods I've used to date
> seem "too slow" and I was hoping that some of the Mathematica gurus on this list
> might offer me suggestions on speeding things up.
> Thanks in advance for your assistance!
> Best regards,
> Mark

  • Prev by Date: Re: Memory Leak -- From Jon@mtheory
  • Next by Date: Re: Re: Re: [Q] Generalized Partitions
  • Previous by thread: Re: Element-by-element Matrix Multiplication
  • Next by thread: Re: Button Evaluate ?? -- From Jon