      subroutine mulvvvvdx(a,b,d,e,aa1,aa2)
      use module
      use mod_ena
      use mod_mula
      use mod_mulatp
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      integer a,b,d,e,corr1,corr2
      character(31) elmat(81)
      !
      if(w)print*,'entree mulvvvvdx a,b,d,e',a,b,d,e
      ysp1=itest(21)==1
      ysp0=itest(21)==0
      !ysp1=.false.
      !ysp0=.true.
      !
      !
      !////////////////////////////////////////////////////
      if(w)print*,'mulvvvvdx on n''ajoute rien'
      !////////////////////////////////////////////////////
      !
      call caldfc(idist,0,2)
      if(all(ilc1((/a,b,d,e/))/=0)) then
         ii1=ilc1(a)
         ii2=ilc1(b)
         ii3=ilc1(d)
         ii4=ilc1(e)
         elmat(1)='      ->       |       ->      '
         ! Adresse de la partie tp
         jsgn=1
         if(ii1<ii2) then
            itp1(1)=num1(ii2)+ii1
            elmat(1)(10:14)='A+ B+'
            jsgn=-jsgn
         else if(ii1==ii2) then
            itp1(1)=ii1
            elmat(1)(10:14)='A+=B+'
         else if(ii1>ii2) then
            itp1(1)=num1(ii1)+ii2
            elmat(1)(10:14)='B+ A+'
         endif
         if(ii3<ii4) then
            itp2(1)=num1(ii4)+ii3
            elmat(1)(27:31)='D+ E+'
            jsgn=-jsgn
         else if(ii3==ii4) then
            itp2(1)=ii3
            elmat(1)(27:31)='D+=E+'
         else if(ii3>ii4) then
            itp2(1)=num1(ii3)+ii4
            elmat(1)(27:31)='E+ D+'
         endif
         nntp(1)=1
         ltp1(1)=1
         if(w)print'(a,20i3)','ITP',itp1(1)
         if(w)print'(a,20i3)','ITP',itp2(1)
         !
         if(a/=d.or.b/=e) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,1,1,1,'B-','E-')
            if(ysp0.and.(a/=b.or.d/=e))
     *      call mulatp(aa3,elmat,1,1,1,'A-','D-')
            !
            !============
            !
            if(a/=b.and.d/=e) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas2',jsgn
               call mulatp(aa3,elmat,1,1,jsgn)
               if(ysp0)
     *         call mulatp(aa3,elmat,1,1,jsgn,'A-','D-','B-','E-')
            endif
         endif
         !
         !============
         !
         if(a/=e.or.d/=b) then
            if(a/=b.and.d/=e) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas3'
               call mulatp(aa3,elmat,1,1,1,'B-','D-')
               if(ysp0.and.(a/=d.or.b/=e))
     *         call mulatp(aa3,elmat,1,1,1,'A-','E-')
               !
            endif
         endif
      endif
      !
      !////////////////////////////////////////////////////
      if(w)print*,'mulvvvvdx on ajoute un trou  a,b,d,e',a,b,d,e
      !////////////////////////////////////////////////////
      !
      if(igener<3) return
      n=0
      nntp=0
      call caldfc(idist,1,2)
      do iipaird=idebliscond(d),ifinliscond(d)
         ipair2=liscond(iipaird)
         if(ilc1(e)/=0) then
            icc2=ilc1(e)+nlco
         else
            cycle
         endif
         i=ilpair(1,ipair2)
         if(ilc1(a)/=0.and.ilp(i,b)/=0) then
            icc1=ilc1(a)+nlco
            ipair1=ilp(i,b)
         else if(ilc1(b)/=0.and.ilp(i,a)/=0) then
            icc1=ilc1(b)+nlco
            ipair1=ilp(i,a)
         else
            cycle
         endif
         if(ipc(ipair1,icc1)==0) cycle
         if(ipc(ipair2,icc2)==0) cycle
         n=n+1
         itp1(n)=abs(ipc(ipair1,icc1))
         itp2(n)=abs(ipc(ipair2,icc2))
         ltp1(n)=1
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','a,b,d,e,i',a,b,d,e,i,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
         !
      enddo
      do iipaird=idebliscond(e),ifinliscond(e)
         ipair2=liscond(iipaird)
         i=ilpair(1,ipair2)
         if(ilc1(d)/=0.and.(ilc1(e)==0.or.ilp(i,d)==0)) then
            icc2=ilc1(d)+nlco
         else
            cycle
         endif
         if(ilc1(a)/=0.and.ilp(i,b)/=0) then
            icc1=ilc1(a)+nlco
            ipair1=ilp(i,b)
         else if(ilc1(b)/=0.and.ilp(i,a)/=0) then
            icc1=ilc1(b)+nlco
            ipair1=ilp(i,a)
         else
            cycle
         endif
         if(ipc(ipair1,icc1)==0) cycle
         if(ipc(ipair2,icc2)==0) cycle
         n=n+1
         itp1(n)=abs(ipc(ipair1,icc1))
         itp2(n)=abs(ipc(ipair2,icc2))
         ltp1(n)=1
         nntp(ltp1(n))=nntp(ltp1(n))+1
         if(w)print'(a,30i3)','A,b,d,e,i',a,b,d,e,i,n,
     *   ltp1(n),nntp(ltp1(n)),
     *   itp1(n),itp2(n)
         !
      enddo
      if(w)print'(a,20i3)','ITP',itp1(1:n)
      if(w)print'(a,20i3)','ITP',itp2(1:n)
      if(w)print*,'nntp',nntp(1:n)
      if(n>0) then
         ltp1(1)=n
         elmat(1)='i+    ->       | i+    ->      '
         jsgn=1
         if(a<b) then
            elmat(1)(10:14)='A+ B+'
            jsgn=-jsgn
         else if(a==b) then
            elmat(1)(10:14)='A+=B+'
         else if(a>b) then
            elmat(1)(10:14)='B+ A+'
         endif
         if(d<e) then
            elmat(1)(27:31)='D+ E+'
            jsgn=-jsgn
         else if(d==e) then
            elmat(1)(27:31)='D+=E+'
         else if(d>e) then
            elmat(1)(27:31)='E+ D+'
         endif
         !
         if(a/=d.or.b/=e) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,1,'B-','E-')
            if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-','i-')
            !
            if((a/=b.or.d/=e).and.(a/=e.or.d/=b)) then
               if(w)print*,'icas2'
               call mulatp(aa3,elmat,n,1,1,'B-','E-','i-')
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-')
            endif
            !
            !============
            !
            if(a/=b.and.d/=e) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas3',jsgn
               call mulatp(aa3,elmat,n,1,jsgn)
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,jsgn,'A-','D-','B-','E-','i-')
               !
               if(w)print*,'icas4',jsgn
               call mulatp(aa3,elmat,n,1,jsgn,'i-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,jsgn,'A-','D-','B-','E-')
            endif
         endif
         !
         !============
         !
         if(a/=e.or.d/=b) then
            if(a/=b.and.d/=e) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               if(w)print*,'icas5'
               call mulatp(aa3,elmat,n,1,1,'B-','D-')
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','E-','i-')
               !
               if((a/=d.or.b/=e).and.(a/=b.or.d/=e)) then
                  if(w)print*,'icas6'
                  call mulatp(aa3,elmat,n,1,1,'B-','D-','i-')
                  if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','E-')
               endif
               !
            endif
         endif
      endif
      !
      !////////////////////////////////////////////////////
      if(w)print*,'mulvvvvdx on ajoute 2 trous  a,b,d,e',a,b,d,e
      !////////////////////////////////////////////////////
      !
      if(igener<4) return
      call caldfc(idist,2,2)
      n=0
      nntp=0
      do iipaird=idebliscond(d),ifinliscond(d)
         ipair2=liscond(iipaird)
         i=ilpair(1,ipair2)
         do jjpaire=idebliscond(e),ifinliscond(e)
            jpair2=liscond(jjpaire)
            j=ilpair(1,jpair2)
            if(ilp(i,e)/=0.and.ilp(j,d)/=0.and.i>j) cycle
            if(ilp(i,a)/=0.and.ilp(j,b)/=0) then
               ipair1=ilp(i,a)
               jpair1=ilp(j,b)
            elseif(ilp(i,b)/=0.and.ilp(j,a)/=0) then
               ipair1=ilp(i,b)
               jpair1=ilp(j,a)
            else
               cycle
            endif
            iimax1=max(ipair1,jpair1)
            iimin1=min(ipair1,jpair1)
            iimax2=max(ipair2,jpair2)
            iimin2=min(ipair2,jpair2)
            ii1=iimax1*(iimax1-1)/2+iimin1
            ii2=iimax2*(iimax2-1)/2+iimin2
            if(ipp(ii1)==0) cycle
            if(ipp(ii2)==0) cycle
            n=n+1
            itp1(n)=abs(ipp(ii1))
            itp2(n)=abs(ipp(ii2))
            if(i==j) then
               ltp1(n)=2
            else
               ltp1(n)=1
            endif
            nntp(ltp1(n))=nntp(ltp1(n))+1
            if(w)print'(a,30i3)','A,b,d,e,i,j',a,b,d,e,i,j,n,
     *      ltp1(n),nntp(ltp1(n)),
     *      itp1(n),itp2(n)
         enddo
      enddo
      if(n>0) then
         call reoitp(n,2,nntp)
         if(w)print'(a,20i3)','ITP',itp1(1:n)
         if(w)print'(a,20i3)','ITP',itp2(1:n)
         !
         elmat(1:2)=(/'i+ j+ ->       | i+ j+ ->      ',
     *                'i+=j+ ->       | i+=j+ ->      '/)
         jsgn=1
         if(a<b) then
            elmat(1:2)(10:14)='A+ B+'
            jsgn=-jsgn
         else if(a==b) then
            elmat(1:2)(10:14)='A+=B+'
         else if(a>b) then
            elmat(1:2)(10:14)='B+ A+'
         endif
         if(d<e) then
            elmat(1:2)(27:31)='D+ E+'
            jsgn=-jsgn
         else if(d==e) then
            elmat(1:2)(27:31)='D+=E+'
         else if(d>e) then
            elmat(1:2)(27:31)='E+ D+'
         endif
         !
         if(a/=d.or.b/=e) then
            aa3=aa1
            if(ysp1) aa3=aa3*2
            !
            if(w)print*,'icas1'
            call mulatp(aa3,elmat,n,1,1,'B-','E-')
            if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-','i-','j-')
            !
            if(w)print*,'icas2'
            call mulatp(aa3,elmat,n,2,1,'B-','E-','j-')
            if(a/=b.or.d/=e) then
               if(ysp0)call mulatp(aa3,elmat,n,2,1,'A-','D-','i-')
            else
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-','i-')
            endif
            !
            if((a/=b.or.d/=e).and.(a/=e.or.d/=b)) then
               if(w)print*,'icas3'
               call mulatp(aa3,elmat,n,1,1,'B-','E-','i-')
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-','j-')
               !
               if(w)print*,'icas4'
               call mulatp(aa3,elmat,n,1,1,'B-','E-','i-','j-')
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','D-')
            endif
            !
            !============
            !
            if(a/=b.and.d/=e) then
               aa3=aa1-aa2
               if(ysp1) aa3=aa3*2
               !
               if(w)print*,'icas5',jsgn
               call mulatp(aa3,elmat,n,1,jsgn)
               if(ysp0)call mulatp(aa3,elmat,n,1,jsgn,
     *         'A-','D-','B-','E-','i-','j-')
               !
               if(w)print*,'icas6'
               call mulatp(aa3,elmat,n,2,jsgn,'j-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,2,jsgn,'A-','D-','B-','E-','i-')
               !
               if(w)print*,'icas7'
               call mulatp(aa3,elmat,n,1,jsgn,'i-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,jsgn,'A-','D-','B-','E-','j-')
               !
               if(w)print*,'icas8'
               call mulatp(aa3,elmat,n,1,jsgn,'i-','j-')
               if(ysp0)
     *         call mulatp(aa3,elmat,n,1,jsgn,'A-','D-','B-','E-')
            endif
         endif
         !
         !============
         !
         if(a/=e.or.d/=b) then
            if(a/=b.and.d/=e) then
               aa3=aa2
               if(ysp1) aa3=aa3*2
               !
               if(w)print*,'icas9'
               call mulatp(aa3,elmat,n,1,1,'B-','D-')
               if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','E-','i-','j-')
               !
               if(w)print*,'icasa'
               call mulatp(aa3,elmat,n,2,1,'B-','D-','j-')
               if(a/=d.or.b/=e) then
                  if(ysp0)
     *            call mulatp(aa3,elmat,n,2,1,'A-','E-','i-')
               else
                  if(ysp0)
     *            call mulatp(aa3,elmat,n,1,1,'A-','E-','i-')
               endif
               !
               if(a/=d.or.b/=e.and.(a/=b.or.d/=e)) then
                  if(w)print*,'icasb',a,b,d,e
                  call mulatp(aa3,elmat,n,1,1,'B-','D-','i-')
                  if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','E-','j-')
                  !
                  if(w)print*,'icasc'
                  call mulatp(aa3,elmat,n,1,1,'B-','D-','i-','j-')
                  if(ysp0)call mulatp(aa3,elmat,n,1,1,'A-','E-')
               endif
               !
            endif
         endif
      endif
      !
      return
      end
 
 
 
 
