{smcl} {bf:Mata course: Translating from FORTRAN} {hline} {title:FORTRAN code} {p 4 4 2} See {bf:{view balbak.f}} for complete code, with comments. {p 4 4 2} Code is one of the routines from the old EISPACK, a precurser of the LAPACK. {p 4 4 2} Here is balbak.f with comments removed: {hline}{cmd} subroutine balbak(nm,n,low,igh,scale,m,z) c integer i,j,k,m,n,ii,nm,igh,low double precision scale(n),z(nm,m) double precision s c c ------------------------------------------------------------------ c if (m .eq. 0) go to 200 if (igh .eq. low) go to 120 c do 110 i = low, igh s = scale(i) c .......... left hand eigenvectors are back transformed c if the foregoing statement is replaced by c s=1.0d0/scale(i). .......... do 100 j = 1, m 100 z(i,j) = z(i,j) * s c 110 continue c ......... for i=low-1 step -1 until 1, c igh+1 step 1 until n do -- .......... 120 do 140 ii = 1, n i = ii if (i .ge. low .and. i .le. igh) go to 140 if (i .lt. low) i = low - ii k = scale(i) if (k .eq. i) go to 140 c do 130 j = 1, m s = z(i,j) z(i,j) = z(k,j) z(k,j) = s 130 continue c 140 continue c 200 return end {txt}{hline} {title:Line-by-line translation} {hline}{cmd} subroutine balbak(nm,n,low,igh,scale,m,z) c integer i,j,k,m,n,ii,nm,igh,low double precision scale(n),z(nm,m) double precision s {txt}{hline} {p 4 4 2} becomes {hline}{cmd} void balbak(real scalar nm, real scalar n, real scalar low, real scalar igh, real vector scale, real scalar m, real matrix z) { real scalar i, j, k, ii real scalar s {txt}{hline} {p 4 4 2} FORTRAN code {hline}{cmd} if (m .eq. 0) go to 200 if (igh .eq. low) go to 120 {hline}{txt} {p 4 4 2} becomes {hline}{cmd} if (m==0) goto L200 if (igh==low) goto L120 {hline}{txt} {p 4 4 2} FORTRAN CODE {hline}{cmd} do 110 i = low, igh s = scale(i) do 100 j = 1, m 100 z(i,j) = z(i,j) * s c 110 continue {hline}{txt} {p 4 4 2} becomes {hline}{cmd} for (i=low; i<=igh; i++) {c -(} s = scale[i] for (j=1; j<=m; j++) z[i,j] = z[i,j] * s {c )-} {hline}{txt} {p 4 4 2} FORTRAN code {hline}{cmd} 120 do 140 ii = 1, n i = ii if (i .ge. low .and. i .le. igh) go to 140 if (i .lt. low) i = low - ii k = scale(i) if (k .eq. i) go to 140 c do 130 j = 1, m s = z(i,j) z(i,j) = z(k,j) z(k,j) = s 130 continue c 140 continue {hline}{txt} {p 4 4 2} becomes {hline}{cmd} L120: for(ii=1, ii<=n; ii++) { i = ii if (i>=low & i<=igh) goto L140 if (i=low & i<=igh) goto L140 if (i