function  G=hypo_gradient(m0,xr)
% function  hypo_gradient
% Input: - Vector m0 with source doordinates and origin time, AND VELOCITY
%        - Matrix xr with dimensions nr x 3, nr is number of receivers
%          times three space coordinates
% Output: matrix G with partial derivatives w.r.t. model parameters
% 
nr=length(xr(:,1));

for i=1:nr,
    for j=1:5,
        if j<4, 
        G(i,j)= (m0(j)-xr(i,j))/m0(5)*( (xr(i,1)-m0(1))^2 + (xr(i,2)-m0(2))^2 + (xr(i,3)-m0(3))^2 )^(-1/2);
        elseif j == 4
        G(i,j)= 1;
        else
        G(i,j)=-1/m0(5)^2*sqrt( (xr(i,1)-m0(1))^2 + (xr(i,2)-m0(2))^2 + (xr(i,3)-m0(3))^2 );        
        end
    end
end

% end