      DOUBLE PRECISION FUNCTION DCHSUM(MODE,C,N,X)
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      DIMENSION C(0:N)

      IF(MODE .EQ. 1) THEN
       H=X
       F=H
       V=1
      ELSE IF(MODE .EQ. 2) THEN
       H=2*X**2-1
       F=H
       V=1
      ELSE IF(MODE .EQ. 3) THEN
       H=2*X**2-1
       F=1
       V=X
      ELSE IF(MODE .EQ. 4) THEN
       H=2*X-1
       F=H
       V=1
      END IF

      ALFA=H+H
      B1=0
      B2=0
      DO 1 I = N,0,-1
      B0=C(I)+ALFA*B1-B2
      B2=B1
    1 B1=B0
      DCHSUM=V*(B0-F*B2)
      RETURN
      END
