我写的一段机器学习的代码中添加了一些功能,其中涉及到了计算信息熵,其中计算信息熵需要计算log(x),然后代码执行起来非常慢,因为这段代码中涉及到了大量的对数运算,我想知道计算机在计算log(x)的时间复杂度是多少?
PHP中文网2017-04-17 13:48:07
http://stackoverflow.com/questions/7317414/what-is-the-complexity-of-the-log-function
TLDR: Modern processors have CPU instructions to directly calculate logarithms. Generally speaking, when we say time complexity, we actually refer to the number of CPU instructions, so it is O(1) (fixed number of instructions)