subroutine lininv(t,x,y,n) c c*** Solves the linear system C*x=y, where C is a matrix with elements c*** c*** C(i,j)=abs(t(i)-t(j)), i,j=1,...,n c*** c*** Here the array t(i) is assumed to be sorted in ascending order, c*** c*** t(1) < t(2) < ..... < t(n) c*** c*** A modification of the fast method of Rybicki and Press (1995, c*** Phys. Rev. Lett., 74, 1060-1063) is used. c*** c*** G. Rybicki, 4 March 1998 c INTEGER i,j,n,n1,NDIM PARAMETER (NDIM=100) REAL t(*),x(*),y(*) REAL e(NDIM),d(NDIM),corner,HALF PARAMETER (HALF=0.5) c if(NDIM.lt.n)then stop 'lininv: NDIM too small' endif n1=n-1 c do i=1,n1 e(i)=HALF/(t(i+1)-t(i)) enddo c corner=HALF/(t(n)-t(1)) d(1)=corner-e(1) do i=2,n1 d(i)=-e(i-1)-e(i) enddo d(n)=corner-e(n1) c x(1)=d(1)*y(1)+e(1)*y(2)+corner*y(n) do i=2,n1 x(i)=e(i-1)*y(i-1)+d(i)*y(i)+e(i)*y(i+1) enddo x(n)=corner*y(1)+e(n1)*y(n1)+d(n)*y(n) return end