c++ - log(x)的时间复杂度是多少?
迷茫
迷茫 2017-04-17 13:46:07
0
3
689

我写的一段机器学习的代码中添加了一些功能,其中涉及到了计算信息熵,其中计算信息熵需要计算log(x),然后代码执行起来非常慢,因为这段代码中涉及到了大量的对数运算,我想知道计算机在计算log(x)的时间复杂度是多少?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(3)
Ty80

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)

PHPzhong

Isn’t it O(1)?

PHPzhong

O(1), but the constant is slightly larger

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template