function [p] = method2p(r)
k=size(r,1);
B = r.*(r');
for i=1:k, 
  B(i,i) =  sum(r(:,i).*r(:,i));
end
p = [B ones(k,1); ones(1,k) 0] \ [zeros(k,1); 1];
p = p(1:k,1);
