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 data question


From   Benjamin Allaire <[email protected]>
To   <[email protected]>
Subject   st: Mata data question
Date   Mon, 1 Aug 2011 13:25:49 -0400

Hi -

I am a bit confused about what exactly mata keeps in memory.  Why doesn't this code work? Why does G go away?

Thanks in advance!

Ben

. 
. mata:
------------------------------------------------- mata (type end to exit) ------------------------------------------------------------------------------------------------------------------------------
:         void blkdiag(real matrix gr, real matrix G_in, real matrix G_out) {
>                         if (G_in == .) G_out = gr
>                         else G_out = blockdiag(G_in, gr)        
>         }

: end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

. 
. 
. mata: blkdiag(J(3,3,1)-I(3),G=.,G)

. mata: blkdiag(J(2,2,1)-I(2),G,G)

. mata: blkdiag(J(4,4,1)-I(4),G,G)

. 
. mata: G
[symmetric]
       1   2   3   4   5   6   7   8   9
    +-------------------------------------+
  1 |  0                                  |
  2 |  1   0                              |
  3 |  1   1   0                          |
  4 |  0   0   0   0                      |
  5 |  0   0   0   1   0                  |
  6 |  0   0   0   0   0   0              |
  7 |  0   0   0   0   0   1   0          |
  8 |  0   0   0   0   0   1   1   0      |
  9 |  0   0   0   0   0   1   1   1   0  |
    +-------------------------------------+

. 
. spmat putmatrix G G, replace
                 <istmt>:  3499  G not found
r(3499);

 		 	   		  
*
*   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