n = 512;

V = zeros(n);
V(:,1) = ones(n,1);
cur = 2;
for i=log2(n):-1:1
  period = 2^i;
  for j=1:n/2^i
	 offset = 1 + (j-1) * 2^i;
	 V(offset:offset+period/2-1,cur) = 1;
	 V(offset+period/2:offset+period-1,cur) = -1;
	 cur = cur + 1;
  end
end
[Q, R] = qr(V);
