Dear All, I was trying to make some simple experiments regarding computational speed of several functions and operations and some results puzzled me. To perform the tests I used massive data to minimize the effect of idle time due to priority handling by the operating system or whatever.
--> tic, u = rand(1,1e7); toc ans = 0.4948326 This creates ten million random numbers in half a second. Very decent performance. Then --> tic, v = sqrt(u); toc ans = 0.282802 The algorithm for square root seems quite fast. Multiplication --> tic, v = u.*u; toc ans = 0.1218028 --> tic, v = u.*%pi; toc ans = 0.119245 is really fast. But when it comes to power or exponentiation: --> tic, v = u.^2; toc ans = 1.9633435 --> tic, v = u.^%pi; toc ans = 1.958321 it is quite slow. Logarithm is much faster: --> tic, v = log(u); toc ans = 0.5166959 Even the exponential function with base e is much faster: --> tic, v = exp(u); toc ans = 0.5451482 I wonder why special cases such as small integer powers are not dealt with by simple multiplication. Particularly the square is very frequently used on large vectors representing discrete signals (for instance to get energy measures) and no warning is issued in the documentation. I also notice that computing the square using this formula (a cannon to kill a mosquito!) --> tic, v = exp(2*log(u)); toc ans = 1.2789763 is faster than using the power operator ^. This seems to be an inconsistent approach, since many special functions are painstakingly tailored to be very efficient, yet one of the simplest of all operations, raising to power 2, is sluggishly slow... Regards, Federico Miyara [https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Libre de virus.www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged. If you are not one of the named recipients or have received this email in error, (i) you should not read, disclose, or copy it, (ii) please notify sender of your receipt by reply email and delete this email and all attachments, (iii) Dassault Systèmes does not accept or assume any liability or responsibility for any use of or reliance on this email. Please be informed that your personal data are processed according to our data privacy policy as described on our website. Should you have any questions related to personal data protection, please contact 3DS Data Protection Officer https://www.3ds.com/privacy-policy/contact/
_______________________________________________ users mailing list - users@lists.scilab.org Click here to unsubscribe: <mailto:users-unsubscr...@lists.scilab.org> https://lists.scilab.org/mailman/listinfo/users