You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently there are some lines with similar code to the following in StrawL1Algorithm.cpp:
int j=(floor) (i/2);
(int) floor((i%8)/2.0);
The usage of floor in these cases does not change the result but only takes CPU time. To understand this you need to know some basics in integer arithmetics. In a few words this is:
If a, b are integers, a/b is the integer with the largest absolute value which is smaller or equal to (a/(float)b): 3/2==1, -3/2==-1
If f is a double or float, floor(f) is the largest integer (I'm not talking about the c type int) smaller or equal to f, stored in a double or float: floor(1.5)==1, floor(-1.5)==-2
So this means that i/2 is already an integer equal to (int)floor(i/2) because floor(j)==j for every j of type int.
Additionally i/2==(int)floor(i/2.0) if i>=0 (please note the 2.0 is now a double so i/2.0 is also a double). So using floor here is useless and only consumes about a factor of 10 times more CPU time:
int j = i/2; // faster version of int j=(floor) (i/2);
(i%8)/2; // faster version of (int) floor((i%8)/2.0);
The text was updated successfully, but these errors were encountered:
Currently there are some lines with similar code to the following in StrawL1Algorithm.cpp:
The usage of
floor
in these cases does not change the result but only takes CPU time. To understand this you need to know some basics in integer arithmetics. In a few words this is:So this means that
i/2
is already an integer equal to(int)floor(i/2)
becausefloor(j)==j
for everyj
of typeint
.Additionally
i/2==(int)floor(i/2.0)
ifi>=0
(please note the 2.0 is now a double so i/2.0 is also a double). So using floor here is useless and only consumes about a factor of 10 times more CPU time:The text was updated successfully, but these errors were encountered: