topic the best way to get a "normalized" 2D vector in IntelĀ® Integrated Performance Primitives
https://community.intel.com/t5/Intel-Integrated-Performance/the-best-way-to-get-a-quot-normalized-quot-2D-vector/m-p/822084#M4828
Hello,<BR /><BR />I would like to speed up some MATLAB application by replacing a bottleneck section with a short C file.<BR /><BR />At some stage I have to "normalize" a long complex array z. In MATLAB, complex array are kept as two separate arrays storing the real and imaginary parts. Hence, the problem is equivalent to computing a unit length 2D vector from an arbitrary length one. <BR /><BR />Of course, it can be accomplished by the following simple code (MATLAB)<BR /><BR />z_unit = z./abs(z);<BR /><BR />This code is prone to problems when you get some zero vectors in your input. Hence, I use the following code<BR /><BR />phase = angle(z);<BR />z_unit = exp(i * phase);<BR /><BR />which is quite slow. <BR /><BR />I tried to replace the angle function with my own implementation (based on atan2 from IPP) which immediately provided some improvement, but the following exp() is still expensive to compute. <BR /><BR />I noticed there are Cartesian->polar conversion functions, however their precision is questionable. <BR />I tested 'phase' function which is faster than atan2 but its precision is worse. <BR /><BR />Will be glad to get any advice here. <BR />Thank you.<BR /><BR />P.S.<BR />Computing the absolute value abs(z) is also important.<BR />Tue, 11 May 2010 15:56:24 GMTeliosh2010-05-11T15:56:24Zthe best way to get a "normalized" 2D vector
https://community.intel.com/t5/Intel-Integrated-Performance/the-best-way-to-get-a-quot-normalized-quot-2D-vector/m-p/822084#M4828
Hello,<BR /><BR />I would like to speed up some MATLAB application by replacing a bottleneck section with a short C file.<BR /><BR />At some stage I have to "normalize" a long complex array z. In MATLAB, complex array are kept as two separate arrays storing the real and imaginary parts. Hence, the problem is equivalent to computing a unit length 2D vector from an arbitrary length one. <BR /><BR />Of course, it can be accomplished by the following simple code (MATLAB)<BR /><BR />z_unit = z./abs(z);<BR /><BR />This code is prone to problems when you get some zero vectors in your input. Hence, I use the following code<BR /><BR />phase = angle(z);<BR />z_unit = exp(i * phase);<BR /><BR />which is quite slow. <BR /><BR />I tried to replace the angle function with my own implementation (based on atan2 from IPP) which immediately provided some improvement, but the following exp() is still expensive to compute. <BR /><BR />I noticed there are Cartesian->polar conversion functions, however their precision is questionable. <BR />I tested 'phase' function which is faster than atan2 but its precision is worse. <BR /><BR />Will be glad to get any advice here. <BR />Thank you.<BR /><BR />P.S.<BR />Computing the absolute value abs(z) is also important.<BR />Tue, 11 May 2010 15:56:24 GMThttps://community.intel.com/t5/Intel-Integrated-Performance/the-best-way-to-get-a-quot-normalized-quot-2D-vector/m-p/822084#M4828eliosh2010-05-11T15:56:24Zthe best way to get a "normalized" 2D vector
https://community.intel.com/t5/Intel-Integrated-Performance/the-best-way-to-get-a-quot-normalized-quot-2D-vector/m-p/822085#M4829
Hello,<BR /><BR />IPP vector math domain library contains some transcedental math functions with specified (means guaranteed)accuracy, please check if that will helpful in your case. You can check ippvm.h file and IPP documentation, volume 1, signal processing.<BR /><BR />Regards,<BR /> VladimirThu, 13 May 2010 10:00:40 GMThttps://community.intel.com/t5/Intel-Integrated-Performance/the-best-way-to-get-a-quot-normalized-quot-2D-vector/m-p/822085#M4829Vladimir_Dudnik2010-05-13T10:00:40Z