      SUBROUTINE GENAB(T,Y1,Y3,C1,A,B,WRK1,WRK2,M,MX,MXT2)
C
C     THIS SUBROUTINE GENERATES THE COEFFICEINTS OF THE OUTGOING
C     AND INGOING WAVES USING THE EQUATIONS: B=(T4*Y3+T3*Y1)*C1
C     AND A=(T2*Y3+T1*Y1)*C1
C
      IMPLICIT REAL*8 (A-H,O-Z)
      COMPLEX*16 T(MXT2,MXT2)
      COMPLEX*16 Y1(MX,MX),Y3(MX,MX),WRK1(MX,MX),WRK2(MX,MX)
      COMPLEX*16 A(MX),B(MX),C1(MX)
      COMPLEX*16 SUM1,SUM2,ZERO
C
      ZERO=DCMPLX(0.0,0.0)
C
      DO 300 II=1,M
      DO 200 I=1,M
C
      SUM1=ZERO
      SUM2=ZERO
C
      DO 100 K=1,M
C
      SUM1=SUM1+T(II,K)*Y3(K,I)+T(II,M+K)*Y1(K,I)
      SUM2=SUM2+T(M+II,K)*Y3(K,I)+T(M+II,M+K)*Y1(K,I)
C
  100 CONTINUE
C
      WRK1(II,I)=SUM1
      WRK2(II,I)=SUM2
C
  200 CONTINUE
  300 CONTINUE
C
      DO 600 II=1,M
C
      SUM1=ZERO
      SUM2=ZERO
C
      DO 500 I=1,M
C
      SUM1=SUM1+WRK1(II,I)*C1(I)
      SUM2=SUM2+WRK2(II,I)*C1(I)
C
  500 CONTINUE
C
      B(II)=SUM1
      A(II)=SUM2
C
  600 CONTINUE
C
      RETURN
      END
