subroutine qrback(Q,R,n,nmax,b,x,w)
dimension Q(nmax,nmax),R(nmax,nmax),b(nmax),x(nmax),w(nmax)

do i=1,n
	w(i)=dot(Q(1,i),b,n)
end do
	
do i=n,1,-1
	sum=0
	do k=i+1,n
		sum=sum+R(i,k)*x(k)
	end do
		x(i)=(w(i)-sum)/R(i,i)
   	end do
return
end
