0001 function A = genAmat(M,N,in);
0002
0003 switch in.type
0004 case 'randn'
0005
0006 A = (randn(M,N))/sqrt(M);
0007
0008 case 'hadamard'
0009
0010 H = hadamard(N);
0011 q = randperm(N);
0012 A = H(q(1:M),:)/sqrt(M);
0013 case 'sign'
0014
0015 A = sign(randn(M,N))/sqrt(M);
0016 case 'orth'
0017
0018 A = (randn(M,N))/sqrt(M);
0019 A = orth(A')';
0020 case 'rdct'
0021
0022 D = dct(eye(N));
0023 q = randperm(N);
0024 A = D(q(1:M),:);
0025 case 'inc'
0026 case {'noiselets','rsample'}
0027 q = randperm(N);
0028 OMEGA = q(1:M);
0029 P = 1:N;
0030 P = P(:); OMEGA = OMEGA(:);
0031 A = @(x,mode) Afun(x,mode,N, OMEGA, P,in.type);
0032 case 'subsample'
0033 q = randperm(N);
0034 OMEGA = q(1:M);
0035 A = eye(N);
0036 A = A(OMEGA,:);
0037 case 'streaming'
0038 parts = in.parts;
0039 Mp = round(M/parts);
0040 Np = round(N/parts);
0041 A = zeros(M,N);
0042 for ii = 1:parts
0043 A((ii-1)*Mp+1:ii*Mp,(ii-1)*Np+1:ii*Np) = sign(randn(Mp,Np))/sqrt(Mp);
0044 end
0045 case 'rnd-demod'
0046 case 'rnd-conv'
0047 end
0048
0049 function y = Afun(x,mode, N, OMEGA,P,mtype)
0050 if mode == 1
0051 switch mtype
0052 case 'noiselets'
0053 y = A_n(x,OMEGA,P);
0054 case 'rsample'
0055 y = x(OMEGA);
0056 end
0057 end
0058 if mode == 2
0059 switch mtype
0060 case 'noiselets'
0061 y = At_n(x, N, OMEGA,P);
0062 case 'rsample'
0063 y = zeros(N,1);
0064 y(OMEGA) = x;
0065 end
0066 end