Statalist


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

st: FORTRAN 77's GO TO <label> CONTINUE into Mata


From   "Joseph Coveney" <jcoveney@bigplanet.com>
To   "Statalist" <statalist@hsphsun2.harvard.edu>
Subject   st: FORTRAN 77's GO TO <label> CONTINUE into Mata
Date   Wed, 17 Oct 2007 02:37:37 -0700

A question about translating the following snippet of FORTRAN 77 into Mata:

         DO 120 J=1,NCV
. . .
         IF (SM) 100,120,100
 100     SM=SM*B
. . .
 120     CONTINUE

I currently have the following (perhaps-too-literal) translation:

   for (j=1; j<=ncv; j++) {
. . .
       if (!sm) goto L120
       sm = sm * b
. . .
L120: }

But in an aside exploration of Mata's behavior with an analogous probe
function, it seems that when a -goto- sends control to the continuation line
as above, it behaves like a -break- and not a -continue-.  Is it that I'm
misremembering things FORTRAN?  (The algorithm is still a little
difficult to follow at the moment, so the intention isn't obvious from the
context.)

Can someone with a more trustworthy memory clue me in, and recommend one of
the following as the replacement--or maybe suggest something better still?

A:
   for (j=1; j<=ncv; j++) {
. . .
       if (!sm) continue
       sm = sm * b
. . .
   }

B:
   for (j=1; j<=ncv; j++) {
. . .
       if (!sm) break
       sm = sm * b
. . .
   }

Joseph Coveney

www.stat.columbia.edu/~cook/movabletype/archives/2007/08/they_started_me.html
"In the case of Mata. goto? Really? In 2007? You sure about that?"
--Byron Ellis

http://kerneltrap.org/node/553/2131
"No, you've been brainwashed by CS people who thought that Niklaus Wirth
actually knew what he was talking about. He didn't. He doesn't have a
frigging clue."
--Linus [Torvalds]


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