% demonstrate low-rank approximation property of distant 2D laplace kernel
% barnett 12/2/08

N = 100;
y = rand(2,N); z = rand(2,N);
%z = 10*z;                           % targets in larger square (comment out)
z(1,:) = z(1,:) + 2;                % targets in displaced square (comment)
figure; plot(y(1,:), y(2,:), '.'); hold on; plot(z(1,:), z(2,:), 'k.');
axis equal; title('sources and targets');

y = y(1,:) + 1i*y(2,:); z = z(1,:) + 1i*z(2,:);   % make pts in complex plane
d = repmat(y, [N 1]) - repmat(z.', [1 N]);        % displacement matrix
A = -log(abs(d));
rank(A)
svd(A)
