Joseph,
From
http://www.nsc.liu.se/~boein/f77to90/a2.html
I found this on the IF statement:
? IF (numerical_expression) snr1, snr2, snr3
- arithmetical IF-statement, jumps to statement number
snr1 if the expression is negative,
snr2 if the expression is zero,
snr3 if the expression is positive
which would imply that your literal translation looks good to me as
!sm would imply a zero value and the program should skip the sm
calculation and continue from the bottom of the loop where you have
the goto label. I don't believe you want to use your B as you will
completely exit the loop. A looks correct to me assuming you do not
need any of the processing steps after sm = sm*b (consistent with your
example of putting the go to label at the end of the loop).
I cannot speak from experience as to why your proposed initial
solution does not work.
Sincerely,
Tom
On 10/17/07, Joseph Coveney <[email protected]> wrote:
> 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/
>
--
Thomas Jacobs
*
* 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/