function W = dist_power_wts(L,k,b);

%DIST_POWER_WTS computes power weights of the form
% 
% a(dij) = [1 - (dij/b)^k]^k , dij <= b
%        = 0  ,  dij > b
% 
% for any integer k > 1, where b > Dmin = bandwidth. These weights are then row normalized as
%     
% wij = s(dij)/sum[a(dih): h = 1,..n]%

%Written by: TONY E. SMITH, 3/30/068

%INPUTS: L = (Nx2) coordinate matrix (Xi,Yi),i=1:N
%        k = integer > 1
%        b = bandwidth  
%            (NOTE: will get error message if b < Dmin)
%
%
%OUTPUTS: W = (NxN) weight matrix (in sparse form).                 

N = length(L(:,1)) ;

D = distance_mat(L);  %Make distance matrix

d = max(max(D));

d_pos = min(min(D + d*eye(N)));  %calculates min positive distance  

if b < d_pos        
    
    error(['bandwidth must be larger than smallest positive distance = ',num2str(d_pos)]);
    
end

U = ones(N); %Unit column vector

W = (U - (D/b).^k).^k;

Z = (D <= b);

W = W.*Z; %makes all wij's with dij > b equal to zero.

W = row_norm(W) ;






