subroutine uscalfor(valstore,vidxstore,prox,n,nsum) integer nsum,i,n,j,index,k,nfirst,mtc,m2,nh,idxcomp integer nk,jone,ione,idxtmp,jj integer nsub(n),nsubcomp(n) real*8 bigneg,zero,rowsum,sum,xincre,temp,comp real*8 valstore(nsum),prox(n,n),vidxstore(nsum) bigneg = -1.0E20 nsum = (2**n) - 1 zero = 0.0 do i = 1,nsum valstore(i) = bigneg vidxstore(i) = zero end do do i = 1,n nsub(i) = 0 nsubcomp(i) = 0 end do do i = 1,n rowsum = 0 do j = 1,n rowsum = rowsum + prox(i,j) end do index = 2**(i-1) valstore(index) = rowsum**2 vidxstore(index) = i end do mtc = 0 do k = 1,n-1 nfirst = 0 if(mtc.eq.0) then m2 = 0 nh = k do j = 1,nh nsub(k+j-nh) = m2 + j end do if(nsub(1).ne.(n-k+1)) then mtc = 1 end if end if do while(mtc.eq.1) if(nfirst.eq.1) then if(m2.lt.(n-nh)) then nh = 0 end if nh = nh + 1 m2 = nsub(k+1-nh) do j = 1,nh nsub(k+j-nh) = m2 + j end do if(nsub(1).ne.(n-k+1)) then mtc = 1 else mtc = 0 end if end if if(nfirst.eq.0) then nfirst = 1 end if index = 0 do i = 1,k index = index + 2**(nsub(i)-1) end do jj = 1 do i =1,n nsubcomp(i) = 0 end do do i = 1,n idxcomp = 1 do j = 1,k if(nsub(j).eq.i) then idxcomp = 0 end if end do if(idxcomp.eq.1) then nsubcomp(jj) = i jj = jj + 1 end if end do nk = n - k do jj = 1,nk jone = nsubcomp(jj) sum = zero do i = 1,k ione = nsub(i) sum = sum + prox(jone,ione) end do do i = 1,nk ione = nsubcomp(i) if(ione.ne.jone) then sum = sum - prox(jone,ione) end if end do xincre = sum**2 temp = valstore(index) + xincre idxtmp = index + 2**(jone-1) comp = valstore(idxtmp) if(temp.gt.comp) then valstore(idxtmp) = temp vidxstore(idxtmp) = jone end if end do end do end do return end