c	file inv2.f
c	Solves the inverse resistor problem.
c	Takes lambda, produces gamma.

	implicit double precision (a-h,o-z)
	dimension glam(80,80),v(20,20),gh(20,21),gv(21,20)
	dimension alph(20),c(20,20),work(20),iwork(20)
	dimension tarray(2)

	lda=20
	read(3,*)n
	n2=2*n
	n3=3*n
	n4=4*n
	no2=n/2
	do 5 j=1,n4
	  do 6 i=1,n4
	    read(3,*)glam(i,j)
6	  continue
5	continue
	do 10 j=1,no2
	  do 11 i=1,n
	    c(i,j)=glam(n3+i,j+1)
11	  continue
10	continue
	do 12 j=1,no2
	  do 13 i=1,n
	    c(i,no2+j)=glam(n3+i,n+no2+j)
13	  continue
12	continue
	do 14 i=1,n
	 alph(i)=-glam(n3+i,1)
14	continue
	tm=dtime(tarray)
	print *,'set up time = ',tm
	itask=1
	call dgefs(c,lda,n,alph,itask,ind,work,iwork)
	tm=dtime(tarray)
	print *,'compute time = ',tm
	write(9,*)ind
	write(9,*)
	do 15 i=1,n
	  write(9,*)alph(i)
15	continue
	stop
	end
