MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > power pf two fast computation? pow2 

Hi! 
Subject: power pf two fast computation? pow2 From: James Tursa Date: 3 Jan, 2010 20:50:05 Message: 2 of 9 
"Max " <nikitchmPublic@gmail.com> wrote in message <hhp9ab$f69$1@fred.mathworks.com>... 
Subject: power pf two fast computation? pow2 From: Matt J Date: 4 Jan, 2010 01:20:06 Message: 3 of 9 
"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hhqvtt$4r1$1@fred.mathworks.com>... 
Thank you for the response. My goal is to separate the modulus and the exponent of a number (y = m*b^e), and to do it in such a way, that the massive computation involving these numbers won't be too slow. Due to the expectation, that the barrel shift should be as fast as the summation, and should be realized at the same processing level, as Matt pointed out in his comment, I tried base=2, and was surprised to find out that it's much slower than the summation operation and only marginally faster than the case, when b=e (y=m*exp(e)). I tried, but couldn't find a prove for it to be otherwise. Also, in the comments to the realization of pow2 function in Matlab help, it is said, that for the same reasons I gave here, the operation should be really fast. But as I said, it's not much faster than taking the exponent. 
Subject: power pf two fast computation? pow2 From: James Tursa Date: 4 Jan, 2010 06:38:03 Message: 5 of 9 
"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hhrfo6$j6o$1@fred.mathworks.com>... 
Subject: power pf two fast computation? pow2 From: James Tursa Date: 4 Jan, 2010 08:18:03 Message: 6 of 9 
"Max " <nikitchmPublic@gmail.com> wrote in message <hhrvas$otg$1@fred.mathworks.com>... 
> But what basic computation are you really after? Are you trying to do x1 + x2 faster than the basic addition would do it by using fancy exponent calculations, or what? You seem to keep coming back to comparison to the addition operation. (Which, again, I would fail to see the relevance of trying to use pow2 for this per my example). 
Subject: power pf two fast computation? pow2 From: James Tursa Date: 4 Jan, 2010 21:35:07 Message: 8 of 9 
"Max " <nikitchmPublic@gmail.com> wrote in message <hhtj4u$i42$1@fred.mathworks.com>... 
All right, my friend located the cause for the pow2 apparent slowness. It's due to the loop optimization of Matlab. It doesn't work for the pow2. But if an array is fed to the function, it works even faster that the addition (as expected). Here are the results obtained in Linux (previous print outs were from Windows version): 
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.