function [d,b]=digit(k) % Given a positive integer k in decimal form, find vectors d, b, % whose entries are the digits of the decimal or binary representation, % respectively, of k. This function can be useful, for example, in % building all kxk permutation matrices. % Caution: for integer >= 10^18 round-off errors occur! k=abs(k); if k-fix(k)>0 'input is not an integer', break, end if (k==0) d(1)=0; end % create d(ecimal) m=1; help=0; l=k; while(help