Skip to content

Commit

Permalink
Replace CoinAbs by std::abs
Browse files Browse the repository at this point in the history
  • Loading branch information
a-andre authored and svigerske committed Aug 16, 2024
1 parent 8596ee3 commit 49f9784
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 131 deletions.
2 changes: 1 addition & 1 deletion src/CbcOrClpParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ CbcOrClpParam::setIntParameterWithMessage(CbcModel &model, int value, int &retur
switch (type_) {
case CLP_PARAM_INT_LOGLEVEL:
oldValue = model.messageHandler()->logLevel();
model.messageHandler()->setLogLevel(CoinAbs(value));
model.messageHandler()->setLogLevel(std::abs(value));
break;
case CLP_PARAM_INT_SOLVERLOGLEVEL:
oldValue = model.solver()->messageHandler()->logLevel();
Expand Down
54 changes: 27 additions & 27 deletions src/ClpCholeskyBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ void ClpCholeskyBase::solveKKT(CoinWorkDouble *region1, CoinWorkDouble *region2,
solve(array);
int iRow;
for (iRow = 0; iRow < numberTotal; iRow++) {
if (rowsDropped_[iRow] && CoinAbs(array[iRow]) > 1.0e-8) {
if (rowsDropped_[iRow] && std::abs(array[iRow]) > 1.0e-8) {
COIN_DETAIL_PRINT(printf("row region1 %d dropped %g\n", iRow, array[iRow]));
}
}
for (; iRow < numberRows_; iRow++) {
if (rowsDropped_[iRow] && CoinAbs(array[iRow]) > 1.0e-8) {
if (rowsDropped_[iRow] && std::abs(array[iRow]) > 1.0e-8) {
COIN_DETAIL_PRINT(printf("row region2 %d dropped %g\n", iRow, array[iRow]));
}
}
Expand Down Expand Up @@ -2813,13 +2813,13 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
}
}
diagonal_[iRow] = work[iRow];
largest2 = std::max(largest2, CoinAbs(work[iRow]));
largest2 = std::max(largest2, std::abs(work[iRow]));
work[iRow] = 0.0;
int j;
for (j = 0; j < number; j++) {
int jRow = which[j];
put[j] = work[jRow];
largest2 = std::max(largest2, CoinAbs(work[jRow]));
largest2 = std::max(largest2, std::abs(work[jRow]));
work[jRow] = 0.0;
}
} else {
Expand Down Expand Up @@ -3009,9 +3009,9 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
if (iOriginalRow < numberColumns) {
iColumn = iOriginalRow;
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iRow] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
Expand All @@ -3020,17 +3020,17 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
kRow = permuteInverse_[kRow];
if (kRow > iRow) {
work[kRow] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
}
} else {
diagonal_[iRow] = -value;
}
} else if (iOriginalRow < numberTotal) {
CoinWorkDouble value = diagonal[iOriginalRow];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
} else {
value = 1.0e100;
}
Expand All @@ -3048,7 +3048,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
int jNewRow = permuteInverse_[jRow];
if (jNewRow > iRow) {
work[jNewRow] = elementByRow[j];
largest = std::max(largest, CoinAbs(elementByRow[j]));
largest = std::max(largest, std::abs(elementByRow[j]));
}
}
// slack - should it be permute
Expand Down Expand Up @@ -3078,7 +3078,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
CoinBigIndex j;
iColumn = iOriginalRow;
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
for (j = columnQuadraticStart[iColumn];
j < columnQuadraticStart[iColumn] + columnQuadraticLength[iColumn]; j++) {
Expand All @@ -3090,7 +3090,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
value += quadraticElement[j];
}
}
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iRow] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
Expand All @@ -3099,17 +3099,17 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
kRow = permuteInverse_[kRow];
if (kRow > iRow) {
work[kRow] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
}
} else {
diagonal_[iRow] = -value;
}
} else if (iOriginalRow < numberTotal) {
CoinWorkDouble value = diagonal[iOriginalRow];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
} else {
value = 1.0e100;
}
Expand All @@ -3127,7 +3127,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
int jNewRow = permuteInverse_[jRow];
if (jNewRow > iRow) {
work[jNewRow] = elementByRow[j];
largest = std::max(largest, CoinAbs(elementByRow[j]));
largest = std::max(largest, std::abs(elementByRow[j]));
}
}
// slack - should it be permute
Expand All @@ -3152,17 +3152,17 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
longDouble *put = sparseFactor_ + choleskyStart_[iColumn];
CoinBigIndex *which = choleskyRow_ + indexStart_[iColumn];
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iColumn] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
for (CoinBigIndex j = start; j < end; j++) {
//choleskyRow_[numberElements]=row[j]+numberTotal;
//sparseFactor_[numberElements++]=element[j];
work[row[j] + numberTotal] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
} else {
diagonal_[iColumn] = -value;
Expand All @@ -3187,7 +3187,7 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
int number = choleskyStart_[iColumn + 1] - choleskyStart_[iColumn];
CoinWorkDouble value = diagonal[iColumn];
CoinBigIndex j;
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
for (j = columnQuadraticStart[iColumn];
j < columnQuadraticStart[iColumn] + columnQuadraticLength[iColumn]; j++) {
Expand All @@ -3198,13 +3198,13 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
value += quadraticElement[j];
}
}
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iColumn] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
for (j = start; j < end; j++) {
work[row[j] + numberTotal] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
for (j = 0; j < number; j++) {
int jRow = which[j];
Expand All @@ -3226,9 +3226,9 @@ int ClpCholeskyBase::factorize(const CoinWorkDouble *diagonal, int *rowsDropped)
longDouble *put = sparseFactor_ + choleskyStart_[iColumn];
CoinBigIndex *which = choleskyRow_ + indexStart_[iColumn];
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
} else {
value = 1.0e100;
}
Expand Down Expand Up @@ -3839,7 +3839,7 @@ void ClpCholeskyBase::solve(CoinWorkDouble *region, int type)
int j;
double largestO = 0.0;
for (i = 0; i < numberRows_; i++) {
largestO = std::max(largestO, CoinAbs(regionX[i]));
largestO = std::max(largestO, std::abs(regionX[i]));
}
for (i = 0; i < numberRows_; i++) {
int iRow = permute_[i];
Expand Down Expand Up @@ -3880,8 +3880,8 @@ void ClpCholeskyBase::solve(CoinWorkDouble *region, int type)
double largest = 0.0;
double largestV = 0.0;
for (i = 0; i < numberRows_; i++) {
largest = std::max(largest, CoinAbs(region[i] - regionX[i]));
largestV = std::max(largestV, CoinAbs(region[i]));
largest = std::max(largest, std::abs(region[i] - regionX[i]));
largestV = std::max(largestV, std::abs(region[i]));
}
printf("largest difference %g, largest %g, largest original %g\n",
largest, largestV, largestO);
Expand Down
26 changes: 13 additions & 13 deletions src/ClpCholeskyDense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped
}
}
for (int j = iRow + 1; j < numberRows_; j++)
largest2 = std::max(largest2, CoinAbs(work[j]));
largest2 = std::max(largest2, std::abs(work[j]));
diagonal_[iRow] = diagonalValue;
largest2 = std::max(largest2, CoinAbs(diagonalValue));
largest2 = std::max(largest2, std::abs(diagonalValue));
} else {
/* dropped*/
diagonal_[iRow] = 1.0;
Expand Down Expand Up @@ -301,17 +301,17 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped
if (!quadratic) {
for (iColumn = 0; iColumn < numberColumns; iColumn++) {
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iColumn] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
for (CoinBigIndex j = start; j < end; j++) {
/*choleskyRow_[numberElements]=row[j]+numberTotal;*/
/*sparseFactor_[numberElements++]=element[j];*/
work[row[j] + numberTotal] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
} else {
diagonal_[iColumn] = -value;
Expand All @@ -328,7 +328,7 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped
for (iColumn = 0; iColumn < numberColumns; iColumn++) {
CoinWorkDouble value = diagonal[iColumn];
CoinBigIndex j;
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
for (j = columnQuadraticStart[iColumn];
j < columnQuadraticStart[iColumn] + columnQuadraticLength[iColumn]; j++) {
Expand All @@ -339,13 +339,13 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped
value += quadraticElement[j];
}
}
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
diagonal_[iColumn] = -value;
CoinBigIndex start = columnStart[iColumn];
CoinBigIndex end = columnStart[iColumn] + columnLength[iColumn];
for (j = start; j < end; j++) {
work[row[j] + numberTotal] = element[j];
largest = std::max(largest, CoinAbs(element[j]));
largest = std::max(largest, std::abs(element[j]));
}
} else {
value = 1.0e100;
Expand All @@ -358,9 +358,9 @@ int ClpCholeskyDense::factorize(const CoinWorkDouble *diagonal, int *rowsDropped
/* slacks*/
for (iColumn = numberColumns; iColumn < numberTotal; iColumn++) {
CoinWorkDouble value = diagonal[iColumn];
if (CoinAbs(value) > 1.0e-100) {
if (std::abs(value) > 1.0e-100) {
value = 1.0 / value;
largest = std::max(largest, CoinAbs(value));
largest = std::max(largest, std::abs(value));
} else {
value = 1.0e100;
}
Expand Down Expand Up @@ -656,8 +656,8 @@ void ClpCholeskyDense::factorizePart2(int *rowsDropped)
int numberDropped = 0;
for (int i = 0; i < numberRows_; i++) {
if (diagonal_[i]) {
largest = std::max(largest, CoinAbs(diagonal_[i]));
smallest = std::min(smallest, CoinAbs(diagonal_[i]));
largest = std::max(largest, std::abs(diagonal_[i]));
smallest = std::min(smallest, std::abs(diagonal_[i]));
} else {
numberDropped++;
}
Expand Down Expand Up @@ -1312,7 +1312,7 @@ void ClpCholeskyDense::solve(CoinWorkDouble *region)
#ifdef CHOL_COMPARE
if (numberRows_ < 200) {
for (int i = 0; i < numberRows_; i++) {
assert(CoinAbs(region[i] - region2[i]) < 1.0e-3);
assert(std::abs(region[i] - region2[i]) < 1.0e-3);
}
delete[] region2;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ClpHelperFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ maximumAbsElement(const CoinWorkDouble *region, int size)
int i;
CoinWorkDouble maxValue = 0.0;
for (i = 0; i < size; i++)
maxValue = std::max(maxValue, CoinAbs(region[i]));
maxValue = std::max(maxValue, std::abs(region[i]));
return maxValue;
}
void setElements(CoinWorkDouble *region, int size, CoinWorkDouble value)
Expand Down Expand Up @@ -222,7 +222,7 @@ void getNorms(const CoinWorkDouble *region, int size, CoinWorkDouble &norm1, Coi
int i;
for (i = 0; i < size; i++) {
norm2 += region[i] * region[i];
norm1 = std::max(norm1, CoinAbs(region[i]));
norm1 = std::max(norm1, std::abs(region[i]));
}
}
#endif
Expand Down
Loading

0 comments on commit 49f9784

Please sign in to comment.