      SUBROUTINE BALBAK(NM,N,LOW,IGH,SCALE,M,PZ)
c
      INTEGER I,J,K,M,N,II,NM,IGH,LOW
      REAL             SCALE(N),PZ(NM,M)
      REAL             S
c
c     this subroutine is a translation of the algol procedure balbak,
c     num. math. 13, 293-304(1969) by parlett and reinsch.
c     handbook for auto. comp., vol.ii-linear algebra, 315-326(1971).
c
c     this subroutine forms the eigenvectors of a real general
c     matrix by back transforming those of the corresponding
c     balanced matrix determined by  balanc.
c
c     on input
c
c        nm must be set to the row dimension of two-dimensional
c          array parameters as declared in the calling program
c          dimension statement.
c
c        n is the order of the matrix.
c
c        low and igh are integers determined by  balanc.
c
c        scale contains information determining the permutations
c          and scaling factors used by  balanc.
c
c        m is the number of columns of Pz to be back transformed.
c
c        Pz contains the real and imaginary parts of the eigen-
c          vectors to be back transformed in its first m columns.
c
c     on output
c
c        Pz contains the real and imaginary parts of the
c          transformed eigenvectors in its first m columns.
c
c     questions and comments should be directed to burton s. garbow,
c     mathematics and computer science div, argonne national laboratory
c
c     this version dated august 1983.
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    PZ(I,J) = PZ(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 = PZ(I,J)
            PZ(I,J) = PZ(K,J)
            PZ(K,J) = S
  130    CONTINUE
c
  140 CONTINUE
c
  200 RETURN
      END
