Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % code to calculate bit-permutations, here matrix M of size 120x32
- % below calculations for OEIS A195665
- num = 5 ;
- fnum = factorial(num) ;
- pnum = 2^num ;
- Powtwo = zeros(1,num) ;
- for m=1:num
- Powtwo(m) = 2^(m-1) ;
- end
- Perms = perms(Powtwo) ; % all permutations
- Perms = horz(sortrows(horz(Perms))) ; % reverse colex
- % matrix
- M = zeros( fnum , pnum ) ;
- for m=1:fnum
- M(m,1:pnum) = cv2wp( Perms(m,:) ) ; % compression vector to Walsh permutation
- end
- % sequence
- Fact = 1 ; % when m reaches this factorial, the current row length will be applied the last time, than doubled
- Count = 2 ; % used to calculate the next Fact
- Length = 2 ; % current row length
- S = [] ;
- for m=1:fnum
- S = [ S M(m,1:Length) ] ;
- if m == Fact
- Fact = Fact * Count ;
- Count = Count + 1 ;
- Length = 2 * Length ;
- end
- end
- % b-file
- B = '' ;
- for m=1:length(S)
- B = [ B num2str(m-1) ' ' num2str(S(m)) '\n' ] ;
- end
- fid = fopen('bfile','wt');
- fprintf(fid,char(B));
- fclose(fid);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement