MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayNew to MATLAB?
MATLAB Central > MATLAB Newsreader > Efficiently computing large numbers of vector norm... 

Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 7 Nov, 2012 21:58:11 Message: 1 of 17 
I am frequently faced with problems where I need to find the norm (squared) of row vectors having the following structure: 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 7 Nov, 2012 22:03:14 Message: 2 of 17 
I should add that X is always square complex. 
Subject: Efficiently computing large numbers of vector norms From: Teja Muppirala Date: 8 Nov, 2012 06:11:13 Message: 3 of 17 
I believe that instead of taking absolute values of complex numbers and squaring, it is faster to multiply by the conjugate. 
Subject: Efficiently computing large numbers of vector norms From: Teja Muppirala Date: 8 Nov, 2012 06:17:24 Message: 4 of 17 
In fact I think this might even be better: 
Subject: Efficiently computing large numbers of vector norms From: Bruno Luong Date: 8 Nov, 2012 12:55:09 Message: 5 of 17 
"Harry Commin" wrote in message <k7elhj$as1$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 9 Nov, 2012 01:05:20 Message: 6 of 17 
"Harry Commin" wrote in message <k7elhj$as1$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 9 Nov, 2012 14:49:18 Message: 7 of 17 
"Matt J" wrote in message <k7hksg$etp$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 12 Nov, 2012 19:48:21 Message: 8 of 17 
Thanks very much for these suggestions. Perhaps I am doing something wrong  while I am getting the correct results numerically, I am not getting the speed boost I had hoped for. 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 12 Nov, 2012 21:32:05 Message: 9 of 17 
Sorry, please disregard my last post. I repeated for 1000 iterations instead of 1 and I now get: 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 13 Nov, 2012 16:28:13 Message: 10 of 17 
"Harry Commin" wrote in message <k7rpsl$ohp$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 13 Nov, 2012 18:22:15 Message: 11 of 17 
> It would be interesting to know the data dimensions you're working with. 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 13 Nov, 2012 18:45:14 Message: 12 of 17 
"Harry Commin" wrote in message <k7u34n$7fs$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 13 Nov, 2012 19:23:10 Message: 13 of 17 
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. 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 14 Nov, 2012 00:03:15 Message: 14 of 17 
"Harry Commin" wrote in message <k7u6mu$ltc$1@newscl01ah.mathworks.com>... 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 14 Nov, 2012 11:49:19 Message: 15 of 17 
> Note that I removed all of the ctranspose operations from the loops, because in reality they are avoidable and contribute unnecessary overhead. 
Subject: Efficiently computing large numbers of vector norms From: Harry Commin Date: 15 Nov, 2012 12:11:16 Message: 16 of 17 
I copied and pasted your code (but had to remove the *5 on the dimensions to avoid Out of Memory errors) and KronProd performs slower than the simple loop. 
Subject: Efficiently computing large numbers of vector norms From: Matt J Date: 15 Nov, 2012 13:32:19 Message: 17 of 17 
"Harry Commin" wrote in message <k82m54$9m2$1@newscl01ah.mathworks.com>... 
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.