input n = size of matrix (2^n x 2^n) outputs a transformation matrix for changing from forward to reverse order. order 1 (Jennie's) 000, 001, 010, 011, 100, 101, 110, 111 order 2 (mine) 000, 100, 010, 110, 001, 101, 011, 111
0001 function [out] = idv2idv(n) 0002 % input n = size of matrix (2^n x 2^n) 0003 % outputs a transformation matrix for changing from forward to reverse 0004 % order. 0005 % order 1 (Jennie's) 0006 % 000, 001, 010, 011, 100, 101, 110, 111 0007 % order 2 (mine) 0008 % 000, 100, 010, 110, 001, 101, 011, 111 0009 % 0010 warning('are you sure you want to call this function?'); 0011 0012 if n <= 0 0013 out = 1; 0014 return; 0015 end 0016 0017 out = sparse(2^n,2^n); 0018 for i = 0:(2^n-1) 0019 t = dec2bin(i,n); 0020 t2 = t(end:-1:1); 0021 i2 = bin2dec(t2); 0022 out(i+1,i2+1) = 1; 0023 end