Replaced inappropriate std::abs() occurences with std::fabs() in C++ code.

This commit is contained in:
François Coppens 2021-05-12 16:10:27 +02:00 committed by Francois Coppens
parent 5693e177ba
commit 0e5bbbbffb
4 changed files with 12 additions and 12 deletions

View File

@ -119,9 +119,9 @@ template <typename T> T matDet(T **A, unsigned int M) {
template <typename T> bool is_identity(T *A, unsigned int M, double tolerance) {
for (unsigned int i = 0; i < M; i++) {
for (unsigned int j = 0; j < M; j++) {
if (i == j && fabs(A[i * M + j] - 1) > tolerance)
if (i == j && std::fabs(A[i * M + j] - 1) > tolerance)
return false;
if (i != j && fabs(A[i * M + j]) > tolerance)
if (i != j && std::fabs(A[i * M + j]) > tolerance)
return false;
}
}
@ -133,7 +133,7 @@ template <typename T> T norm_max(T *A, unsigned int Dim) {
for (unsigned int i = 0; i < Dim; i++) {
for (unsigned int j = 0; j < Dim; j++) {
T delta = A[i * Dim + j];
delta = fabs(delta);
delta = std::fabs(delta);
if (delta > res) {
res = delta;
}
@ -158,7 +158,7 @@ template <typename T> T residual_max(T *A, unsigned int Dim) {
for (unsigned int i = 0; i < Dim; i++) {
for (unsigned int j = 0; j < Dim; j++) {
T delta = A[i * Dim + j] - (i == j);
delta = fabs(delta);
delta = std::fabs(delta);
if (delta > res) {
res = delta;
}

View File

@ -25,10 +25,10 @@ void selectLargestDenominator(unsigned int l, unsigned int N_updates,
for (unsigned int j = lbar; j < N_updates + 1; j++) {
index = p[j];
component = Updates_index[index - 1];
breakdown = abs(1 + ylk[l][index][component]);
breakdown = std::fabs(1 + ylk[l][index][component]);
#ifdef DEBUG
std::cout << "Inside selectLargestDenominator()" << std::endl;
std::cout << "breakdown = abs(1 + ylk[" << l << "][" << index << "]["
std::cout << "breakdown = fabs(1 + ylk[" << l << "][" << index << "]["
<< component << "]) = " << breakdown << std::endl;
std::cout << std::endl;
#endif

View File

@ -76,7 +76,7 @@ void MaponiA3(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
<< "] = " << beta << std::endl;
std::cerr << std::endl;
#endif
if (fabs(beta) < threshold()) {
if (std::fabs(beta) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;
}
@ -208,7 +208,7 @@ void MaponiA3S(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
<< "] = " << beta << std::endl;
std::cerr << std::endl;
#endif
if (fabs(beta) < threshold()) {
if (std::fabs(beta) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;
for (unsigned int i = 1; i < Dim + 1; i++) {

View File

@ -23,7 +23,7 @@ void SM1(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
// Denominator
double den = 1 + C[Updates_index[l] - 1];
if (fabs(den) < threshold()) {
if (std::fabs(den) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;
}
@ -71,7 +71,7 @@ void SM2(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
// Denominator
double den = 1 + C[Updates_index[l] - 1];
if (fabs(den) < threshold()) {
if (std::fabs(den) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;
@ -131,7 +131,7 @@ void SM3(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
// Denominator
double den = 1 + C[Updates_index[l] - 1];
if (fabs(den) < threshold()) {
if (std::fabs(den) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;
@ -198,7 +198,7 @@ void SM4(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
// Denominator
double den = 1 + C[Updates_index[l] - 1];
if (fabs(den) < threshold()) {
if (std::fabs(den) < threshold()) {
std::cerr << "Breakdown condition triggered at " << Updates_index[l]
<< std::endl;