Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Efficiency of the colon operator in Mata


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: Efficiency of the colon operator in Mata
Date   Mon, 22 May 2006 16:16:18 -0400

I find the same pattern in my AMD xp2700 chip -- admittedly fairly old, but certainly not by Intel. The colon operator takes twice as long as the scalar.

Michael Blasnik

----- Original Message ----- From: "William Gould, Stata" <[email protected]>
To: <[email protected]>
Sent: Monday, May 22, 2006 11:23 AM
Subject: Re: st: Efficiency of the colon operator in Mata



Ben Jann <[email protected]> did some speed tests in Mata
and diiscovered that

       if (length(k)==1) y = x * k
       else              y = x :* k

is faster than

       y = x :* k

(In Ben's code, k is a vector or scalar).

Ben wonders,

Can anyone confirm these results? Is it true that the colon operator
significantly slows down computations if used in situations where it is
not really needed or is this just an artifact produced by my local
machine?
I remind Ben, we have already discovered that Ben's computer is particularly
slow at running colon operators. Most computers are not, but a particular
older modern of the Intel chip is, and we have duplicated the behavior here.
We at StataCorp even know how to get around the problem, but our concern is
that the fix will cause modern computers to run colon operators slower. We
said we would test, but we have not completed that yet.

In any case, whenever Ben can avoid colon operators, he is going to observe
better performance. The rest of us, however, will not.

-- Bill
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index