Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Re: Fwd: Linear indexing of matrices in Mata


From   "Joseph Coveney" <jcoveney@bigplanet.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Fwd: Linear indexing of matrices in Mata
Date   Tue, 24 Jul 2012 12:06:09 +0900

Joerg Luedicke wrote (excerpted):

. . . Especially if you have several of the same expressions that
need to be evaluated, the code gets messy and it probably slows things
down as the expression has to be evaluated every time instead of just
once if it would be possible to index elements.

--------------------------------------------------------------------------------

I don't understand what you mean here:  I don't understand how

    index=which(m1>2)
    m2[index]

would be less messy or less slowed down than

    index_which(M2, (M1 :> 2))

when you have several of the same expressions that need to be evaluated.  Are
you referring to vectorization or ?apply() or something?

Could you illustrate what you mean with an example?

Joseph Coveney


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index