C
C     ..................................................................
C
C        SUBROUTINE PVSUB
C
C        PURPOSE
C           SUBSTITUTE VARIABLE OF A POLYNOMIAL BY ANOTHER POLYNOMIAL
C
C        USAGE
C           CALL PVSUB(Z,IDIMZ,X,IDIMX,Y,IDIMY,WORK1,WORK2)
C
C        DESCRIPTION OF PARAMETERS
C           Z     - VECTOR OF COEFFICIENTS FOR RESULTANT POLYNOMIAL,
C                   ORDERED FROM SMALLEST TO LARGEST POWER
C           IDIMZ - DIMENSION OF Z
C           X     - VECTOR OF COEFFICIENTS FOR ORIGINAL POLYNOMIAL,
C                   ORDERED FROM SMALLEST TO LARGEST POWER
C           IDIMX - DIMENSION OF X
C           Y     - VECTOR OF COEFFICIENTS FOR POLYNOMIAL WHICH IS
C                   SUBSTITUTED FOR VARIABLE, ORDERED FROM SMALLEST TO
C                   LARGEST POWER
C           IDIMY - DIMENSION OF Y
C           WORK1 - WORKING STORAGE ARRAY (SAME DIMENSION AS Z)
C           WORK2 - WORKING STORAGE ARRAY (SAME DIMENSION AS Z)
C
C        REMARKS
C           NONE
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           PMPY
C           PADDM
C           PCLA
C
C        METHOD
C           VARIABLE OF POLYNOMIAL X IS SUBSTITUTED BY POLYNOMIAL Y
C           TO FORM POLYNOMIAL Z. DIMENSION OF NEW POLYNOMIAL IS
C           (IDIMX-1)*(IDIMY-1)+1. SUBROUTINE REQUIRES TWO WORK AREAS
C
C     ..................................................................
C
      SUBROUTINE PVSUB(Z,IDIMZ,X,IDIMX,Y,IDIMY,WORK1,WORK2)
      DIMENSION Z(1),X(1),Y(1),WORK1(1),WORK2(1)
C
C     TEST OF DIMENSIONS
C
      IF (IDIMX-1) 1,3,3
    1 IDIMZ=0
    2 RETURN
C
    3 IDIMZ=1
      Z(1)=X(1)
      IF (IDIMY*IDIMX-IDIMY) 2,2,4
    4 IW1=1
      WORK1(1)=1.
C
      DO 5 I=2,IDIMX
      CALL PMPY(WORK2,IW2,Y,IDIMY,WORK1,IW1)
      CALL PCLA(WORK1,IW1,WORK2,IW2)
      FACT=X(I)
      CALL PADDM(Z,IDIMR,Z,IDIMZ,FACT,WORK1,IW1)
      IDIMZ=IDIMR
    5 CONTINUE
      GO TO 2
      END
