Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Efficiently computing large numbers of vector norms
Replies: 16   Last Post: Nov 15, 2012 8:32 AM

 Messages: [ Previous | Next ]
 Harry Commin Posts: 11 Registered: 10/8/10
Re: Efficiently computing large numbers of vector norms
Posted: Nov 13, 2012 2:23 PM

I cannot repeat your test, as I get an "Out of Memory" error. Furthermore, I require that A1 and A2 change on each iteration. Therefore, the KronProd() operation must also go inside the tic/toc.

Perhaps you could copy and paste my code (for which I get comparable performance using a simple loop):

Ntrials = 100;

% Data Dimensions
N1 = 9; N2 = 7;
Q1 = 180; Q2 = 63;

% Data
A1 = randn(N1,Q1) + 1j*randn(N1,Q1);
A2 = randn(N2,Q2) + 1j*randn(N2,Q2);
X2 = randn(N1*N2,N1*N2) + 1j*randn(N1*N2,N1*N2);

tic
Z2b = zeros(Q1,Q2);
for trial = 1:Ntrials
for j = 1:Q2
Z2b(:,j) = sum(abs(kron(A1,A2(:,j))'*X2).^2,2);
end
end
t = toc;
disp(['Single Loop = ',num2str(t), ' secs'])

tic
for trial = 1:Ntrials
Z2c = reshape(sum(abs(kron(A1,A2)'*X2).^2,2),Q2,Q1).';
end
t = toc;
disp(['No Loop = ',num2str(t), ' secs'])

tic
for trial = 1:Ntrials
Z2d = reshape(sum(abs(KronProd({A2',A1'})*X2).^2,2),Q2,Q1).';
end
t = toc;
disp(['Fast KronProd = ',num2str(t), ' secs'])

Date Subject Author
11/7/12 Harry Commin
11/7/12 Harry Commin
11/8/12 Teja Muppirala
11/8/12 Teja Muppirala
11/8/12 Bruno Luong
11/8/12 Matt J
11/9/12 Matt J
11/12/12 Harry Commin
11/12/12 Harry Commin
11/13/12 Matt J
11/13/12 Harry Commin
11/13/12 Matt J
11/13/12 Harry Commin
11/13/12 Matt J
11/14/12 Harry Commin
11/15/12 Harry Commin
11/15/12 Matt J