math - C++ Exp vs. Log: Which is faster? -
I have a C ++ application in which I need to compare two values and make as many decisions as possible. The only complication is that a number is represented in the log-space, not the other. For example:
double log_num_1 = log (1.23); Double number_2 = 1.24; If I want to compare num_1 and num_2 , then let me use the log Or exp () , and I am thinking that it is easy to compare with one another (i.e. runs in less time in normal time). You can assume that I am using the standard cmath library.
In other words, the following meanings are equivalent, which is faster:
if (exp (log_num_1)> num_2)) cout & lt; & Lt; "Num_1 is big";
or
if (log_num_1 & gt; log (num_2)) cout & lt; & Lt; "Num_1 is big"; APIAL algorithm, complexity is the same, the only difference should be (
Hopefully negligible ) Continued due to this, I have exp (a) & gt; B , because it does not break on invalid input.
Comments
Post a Comment