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

len = round(size(A1,2)/lowdim);
dist1 = 0.0;
for i=1:len,
  B = A1(:,((i-1)*lowdim+1):(i*lowdim))'*A2(:,((i-1)*lowdim+1):(i*lowdim));
  S = svd(B);
  S_flag = (S < 1.0);
  dist1 = dist1 + sum(sum((acos(S).*S_flag).^(2)));
  %end
end
dist1 = sqrt(dist1/len);
return;
% keyboard;
    






