C.hr DGMABA
C@
C....*...1.........2.........3.........4.........5.........6.........7.*
C     DGMABA  6/20/87 (ANNIVERSARY)
C
C     PURPOSE
C     COMPUTE THE QUADRATIC FORM: R = A'BA.
C
C     USAGE
C     CALL DGMABA(A,B,R,N,M)
C
C     ARGUMENTS
C     A - INPUT N BY M MATRIX STORED COLUMNWISE (STORAGE MODE 0)
C         REAL*8
C     B - INPUT N BY N MATRIX STORED COLUMNWISE (STORAGE MODE 0)
C         REAL*8
C     R - OUTPUT M BY M MATRIX STORED COLUMNWISE (STORAGE MODE 0)
C         REAL*8
C     N - NUMBER OF ROWS IN A
C         INTEGER*4
C     M - NUMBER OF COLUMNS IN A
C         INTEGER*4
C
      SUBROUTINE DGMABA(A,B,R,N,M)
      implicit real*8 (a-h,o-z)
      save
C     REAL*8 A(1),B(1),R(1),ACC
      REAL*8 A(N*M),B(N*N),R(M*M)
      DO 20 JJ=1,M
      DO 20 II=1,JJ
      ACC=0.D0
      DO 10 J=1,N
      DO 10 I=1,N
10    ACC=ACC+A(N*(JJ-1)+I)*A(N*(II-1)+J)*B(N*(J-1)+I)
      R(M*(II-1)+JJ)=ACC
20    R(M*(JJ-1)+II)=ACC
      RETURN
      END
