Skip to content

Commit b7b6a7e

Browse files
committed
fix typo issue of util.h
1 parent e0e3924 commit b7b6a7e

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

.github/workflows/style_check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# cmake ..
5555
# make -j
5656
# sudo make install
57-
#
57+
5858
- name: Create Build Directory
5959
run: cmake -E make_directory ${{runner.workspace}}/build
6060

@@ -72,7 +72,7 @@ jobs:
7272
# shell: bash
7373
# working-directory: ${{github.workspace}}
7474
# run: ./scripts/run_cppcheck.sh ${{runner.workspace}}/build
75-
#
75+
7676
- name: Install clang-tidy
7777
run: |
7878
sudo apt-get install clang-tidy-9

k2/csrc/util.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef K2_CSRC_UTIL_H_
88
#define K2_CSRC_UTIL_H_
99

10+
#include <cfloat>
11+
#include <cmath>
1012
#include <functional>
1113
#include <utility>
1214

@@ -31,8 +33,8 @@ struct PairHash {
3133
}
3234
};
3335

34-
static const double kMinLogDiffDouble = Log(DBL_EPSILON); // negative!
35-
static const float kMinLogDiffFloat = Log(FLT_EPSILON); // negative!
36+
static const double kMinLogDiffDouble = log(DBL_EPSILON); // negative!
37+
static const float kMinLogDiffFloat = log(FLT_EPSILON); // negative!
3638

3739
// returns log(exp(x) + exp(y)).
3840
inline double LogAdd(double x, double y) {
@@ -48,14 +50,13 @@ inline double LogAdd(double x, double y) {
4850

4951
if (diff >= kMinLogDiffDouble) {
5052
double res;
51-
res = x + Log1p(Exp(diff));
53+
res = x + log1p(exp(diff));
5254
return res;
5355
} else {
5456
return x; // return the larger one.
5557
}
5658
}
5759

58-
5960
// returns log(exp(x) + exp(y)).
6061
inline float LogAdd(float x, float y) {
6162
float diff;
@@ -70,14 +71,12 @@ inline float LogAdd(float x, float y) {
7071

7172
if (diff >= kMinLogDiffFloat) {
7273
float res;
73-
res = x + Log1p(Exp(diff));
74+
res = x + log1p(exp(diff));
7475
return res;
7576
} else {
7677
return x; // return the larger one.
7778
}
7879
}
7980

80-
81-
8281
} // namespace k2
8382
#endif // K2_CSRC_UTIL_H_

0 commit comments

Comments
 (0)