Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Mata question: putting matrices along the diagonal


From   <[email protected]>
To   [email protected]
Subject   st: Mata question: putting matrices along the diagonal
Date   Thu, 27 May 2010 14:02:43 -0400 (EDT)

Dear Listers:

I am interested in making one large "diagonal" matrix out of a bunch of matrices in Mata. For example, suppose I have 3 2x2 matrices labeled m1, m2, and m3. I want to construct the matrix M, where M is something like:
M=
(m1[1,1],m1[1,2],     0,        0,           0, 0               \ 
 m1[2,1],m1[2,2],     0,        0,           0, 0               \
      0    ,   0,       m2[1,1],m2[1,2],     0, 0               \
      0    ,   0,       m2[2,1],m2[2,2],     0,  0              \
      0    ,   0,             0,        0,      m3[1,1],m3[1,2] \
      0    ,   0,             0,        0,      m3[2,1],m3[2,2] )

That is, I seek to place each of the individual matrices along the diagonal, zeros elsewhere. In my problem, both the number of matrices and the dimensions of each matrix may be rather large.

Thanks in advance!

Matt Baker 
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index