提交 1f8c2197 编写于 作者: L liaogang

replace fabsf() using std::abs

上级 8a379fce
...@@ -124,8 +124,8 @@ void checkSMatrixErr(const CpuSparseMatrixPtr& a, ...@@ -124,8 +124,8 @@ void checkSMatrixErr(const CpuSparseMatrixPtr& a,
if (a->getValueType() == FLOAT_VALUE) { if (a->getValueType() == FLOAT_VALUE) {
real aVal = a->getValue()[r]; real aVal = a->getValue()[r];
real bVal = b->getValue()[r]; real bVal = b->getValue()[r];
if (fabs(aVal - bVal) > err) { if (std::abs(aVal - bVal) > err) {
if ((fabsf(aVal - bVal) / fabsf(aVal)) > (err / 10.0f)) { if ((std::abs(aVal - bVal) / std::abs(aVal)) > (err / 10.0f)) {
LOG(INFO) << "a=" << aVal << "\t" << "b=" << bVal; LOG(INFO) << "a=" << aVal << "\t" << "b=" << bVal;
count++; count++;
} }
...@@ -141,8 +141,8 @@ void checkSMatrixErr(const CpuSparseMatrixPtr& a, ...@@ -141,8 +141,8 @@ void checkSMatrixErr(const CpuSparseMatrixPtr& a,
if (a->getValueType() == FLOAT_VALUE) { if (a->getValueType() == FLOAT_VALUE) {
real aVal = a->getValue()[r]; real aVal = a->getValue()[r];
real bVal = b->getValue()[r]; real bVal = b->getValue()[r];
if (fabs(aVal - bVal) > err) { if (std::abs(aVal - bVal) > err) {
if ((fabsf(aVal - bVal) / fabsf(aVal)) > (err / 10.0f)) { if ((std::abs(aVal - bVal) / std::abs(aVal)) > (err / 10.0f)) {
count++; count++;
} }
} }
...@@ -173,8 +173,8 @@ void checkMatrixErr(const Matrix& matrix1, const Matrix& matrix2) { ...@@ -173,8 +173,8 @@ void checkMatrixErr(const Matrix& matrix1, const Matrix& matrix2) {
for (int j = 0; j < width; j++) { for (int j = 0; j < width; j++) {
real a = data1[i * width + j]; real a = data1[i * width + j];
real b = data2[i * width + j]; real b = data2[i * width + j];
if (fabs(a - b) > err) { if (std::abs(a - b) > err) {
if ((fabsf(a - b) / fabsf(a)) > (err / 10.0f)) { if ((std::abs(a - b) / std::abs(a)) > (err / 10.0f)) {
count++; count++;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册