function [dist1] = calc_pairwise_dist_front_proj(A1, A2, lowdim); 

len = round(size(A1,2)/lowdim);
dist1 = 0.0;
i = len;
A11= A1(:,((i-1)*lowdim+1):(i*lowdim));
A21 = A2(:,((i-1)*lowdim+1):(i*lowdim));
P11 =  A11 * ((A11'*A11)^(-1))*A11';
P21 =  A21 * ((A21'*A21)^(-1))*A21';
for i=1:len,
  A11= A1(:,((i-1)*lowdim+1):(i*lowdim));
  A21 = A2(:,((i-1)*lowdim+1):(i*lowdim));
  P12 =  A11 * ((A11'*A11)^(-1))*A11';
  P22 =  A21 * ((A21'*A21)^(-1))*A21';
  dist1 = dist1 + (norm((P12-P11)-(P22-P21),'fro')).^2;
  P11 = P12;
  P21 = P22;
  %end
end
dist1 = sqrt(dist1/len);
return;
% keyboard;
    






