Skip to content

Commit

Permalink
Replace Coin{Max,Min} by std::{max,min}
Browse files Browse the repository at this point in the history
  • Loading branch information
a-andre authored and tkralphs committed Aug 16, 2024
1 parent 6ca49c5 commit ea38a51
Show file tree
Hide file tree
Showing 31 changed files with 265 additions and 265 deletions.
2 changes: 1 addition & 1 deletion src/CoinDenseFactorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void CoinDenseFactorization::getAreas(int numberOfRows,

numberRows_ = numberOfRows;
numberColumns_ = numberOfColumns;
int size = numberRows_ * (numberRows_ + CoinMax(maximumPivots_, (numberRows_ + 1) >> 1));
int size = numberRows_ * (numberRows_ + std::max(maximumPivots_, (numberRows_ + 1) >> 1));
if (size > maximumSpace_) {
delete[] elements_;
elements_ = new CoinFactorizationDouble2[size];
Expand Down
2 changes: 1 addition & 1 deletion src/CoinDenseVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void CoinDenseVector< T >::resize(int newsize, T value)
if (newsize != nElements_) {
assert(newsize > 0);
T *newarray = new T[newsize];
int cpysize = CoinMin(newsize, nElements_);
int cpysize = std::min(newsize, nElements_);
CoinMemcpyN(elements_, cpysize, newarray);
delete[] elements_;
elements_ = newarray;
Expand Down
2 changes: 1 addition & 1 deletion src/CoinDenseVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class CoinDenseVector {
{
T norm = 0;
for (int i = 0; i < nElements_; i++)
norm = CoinMax(norm, CoinAbs(elements_[i]));
norm = std::max(norm, CoinAbs(elements_[i]));
return norm;
}
/// sum of vector elements
Expand Down
8 changes: 4 additions & 4 deletions src/CoinFactorization1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,12 +646,12 @@ void CoinFactorization::getAreas(int numberOfRows,
if (persistenceFlag_) {
// But we can use all we have if bigger
int length;
length = static_cast< int >(CoinMin(elementU_.getSize(), indexRowU_.getSize())) - lengthU;
length = static_cast< int >(std::min(elementU_.getSize(), indexRowU_.getSize())) - lengthU;
if (length > lengthAreaU_) {
lengthAreaU_ = length;
assert(indexColumnU_.getSize() == indexRowU_.getSize());
}
length = static_cast< int >(CoinMin(elementL_.getSize(), indexRowL_.getSize()));
length = static_cast< int >(std::min(elementL_.getSize(), indexRowL_.getSize()));
if (length > lengthAreaL_) {
lengthAreaL_ = length;
}
Expand Down Expand Up @@ -705,7 +705,7 @@ void CoinFactorization::getAreas(int numberOfRows,
} else {
biggerDimension_ = numberColumns_;
}
firstCount_.conditionalNew(CoinMax(biggerDimension_ + 2, maximumRowsExtra_ + 1));
firstCount_.conditionalNew(std::max(biggerDimension_ + 2, maximumRowsExtra_ + 1));
nextCount_.conditionalNew(numberRows_ + numberColumns_);
lastCount_.conditionalNew(numberRows_ + numberColumns_);
#ifdef ZEROFAULT
Expand Down Expand Up @@ -2512,7 +2512,7 @@ void CoinFactorization::setPersistenceFlag(int flag)
numberInRow_.setPersistence(flag, maximumRowsExtra_ + 1);
numberInColumn_.setPersistence(flag, maximumColumnsExtra_ + 1);
numberInColumnPlus_.setPersistence(flag, maximumColumnsExtra_ + 1);
firstCount_.setPersistence(flag, CoinMax(biggerDimension_ + 2, maximumRowsExtra_ + 1));
firstCount_.setPersistence(flag, std::max(biggerDimension_ + 2, maximumRowsExtra_ + 1));
nextCount_.setPersistence(flag, numberRows_ + numberColumns_);
lastCount_.setPersistence(flag, numberRows_ + numberColumns_);
nextColumn_.setPersistence(flag, maximumColumnsExtra_ + 1);
Expand Down
8 changes: 4 additions & 4 deletions src/CoinFactorization3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ void CoinFactorization::updateColumnLDensish(CoinIndexedVector *regionSparse,
for (int k = 0; k < number; k++) {
int iPivot = regionIndex[k];
if (iPivot >= baseL_)
smallestIndex = CoinMin(iPivot, smallestIndex);
smallestIndex = std::min(iPivot, smallestIndex);
else
regionIndex[numberNonZero++] = iPivot;
}
Expand Down Expand Up @@ -417,7 +417,7 @@ void CoinFactorization::updateColumnLSparsish(CoinIndexedVector *regionSparse,
if (iPivot < baseL_) {
regionIndex[numberNonZero++] = iPivot;
} else {
smallestIndex = CoinMin(iPivot, smallestIndex);
smallestIndex = std::min(iPivot, smallestIndex);
int iWord = iPivot >> CHECK_SHIFT;
int iBit = iPivot - (iWord << CHECK_SHIFT);
if (mark[iWord]) {
Expand All @@ -430,7 +430,7 @@ void CoinFactorization::updateColumnLSparsish(CoinIndexedVector *regionSparse,
// now others
// First do up to convenient power of 2
int jLast = (smallestIndex + BITS_PER_CHECK - 1) >> CHECK_SHIFT;
jLast = CoinMin((jLast << CHECK_SHIFT), last);
jLast = std::min((jLast << CHECK_SHIFT), last);
int i;
for (i = smallestIndex; i < jLast; i++) {
CoinFactorizationDouble pivotValue = region[i];
Expand Down Expand Up @@ -1448,7 +1448,7 @@ void CoinFactorization::updateColumnUSparsish(CoinIndexedVector *regionSparse,
numberNonZero = 0;
// First do down to convenient power of 2
int jLast = (numberU_ - 1) >> CHECK_SHIFT;
jLast = CoinMax((jLast << CHECK_SHIFT), static_cast< int >(numberSlacks_));
jLast = std::max((jLast << CHECK_SHIFT), static_cast< int >(numberSlacks_));
int i;
for (i = numberU_ - 1; i >= jLast; i--) {
CoinFactorizationDouble pivotValue = region[i];
Expand Down
72 changes: 36 additions & 36 deletions src/CoinFactorization4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool CoinFactorization::getColumnSpaceIterateR(int iColumn, double value,
indexRowR[put++] = iRow;
numberInColumnPlus[iColumn]++;
//add 4 for luck
startR[maximumColumnsExtra_] = CoinMin(static_cast< int >(put + 4), lengthAreaR_);
startR[maximumColumnsExtra_] = std::min(static_cast< int >(put + 4), lengthAreaR_);
return true;
}
int CoinFactorization::checkPivot(double saveFromU,
Expand Down Expand Up @@ -373,7 +373,7 @@ int CoinFactorization::replaceColumn(CoinIndexedVector *regionSparse,
for (int i = start; i < end; i++) {
int iColumn = indexColumn[i];
assert(iColumn < numberRowsExtra_);
smallestIndex = CoinMin(smallestIndex, iColumn);
smallestIndex = std::min(smallestIndex, iColumn);
int j = convertRowToColumn[i];

region[iColumn] = element[j];
Expand All @@ -387,7 +387,7 @@ int CoinFactorization::replaceColumn(CoinIndexedVector *regionSparse,
} else {
for (int i = start; i < end; i++) {
int iColumn = indexColumn[i];
smallestIndex = CoinMin(smallestIndex, iColumn);
smallestIndex = std::min(smallestIndex, iColumn);
int j = convertRowToColumn[i];

region[iColumn] = element[j];
Expand Down Expand Up @@ -657,7 +657,7 @@ int CoinFactorization::replaceColumn(CoinIndexedVector *regionSparse,
for (int i = 0; i < number; i++) {
elementU[i] *= pivotValue;
}
maximumU_ = CoinMax(maximumU_, startU + number);
maximumU_ = std::max(maximumU_, startU + number);
numberRowsExtra_++;
numberColumnsExtra_++;
numberGoodU_++;
Expand Down Expand Up @@ -710,7 +710,7 @@ int CoinFactorization::replaceColumn(CoinIndexedVector *regionSparse,
elementR[put] = region[iRow];
//add 4 for luck
if (next == maximumColumnsExtra_)
startR[maximumColumnsExtra_] = CoinMin(static_cast< int >(put + 4), lengthAreaR_);
startR[maximumColumnsExtra_] = std::min(static_cast< int >(put + 4), lengthAreaR_);
} else {
// no space - do we shuffle?
if (!getColumnSpaceIterateR(iRow, region[iRow], pivotRow)) {
Expand Down Expand Up @@ -781,7 +781,7 @@ void CoinFactorization::replaceColumn1(CoinIndexedVector *regionSparse,
for (int i = start; i < end; i++) {
int iColumn = indexColumn[i];
assert(iColumn < numberRowsExtra_);
smallestIndex = CoinMin(smallestIndex, iColumn);
smallestIndex = std::min(smallestIndex, iColumn);
int j = convertRowToColumn[i];

region[iColumn] = element[j];
Expand Down Expand Up @@ -1108,7 +1108,7 @@ int CoinFactorization::replaceColumn2(CoinIndexedVector *regionSparse,
for (int i = 0; i < number; i++) {
elementU[i] *= pivotValue;
}
maximumU_ = CoinMax(maximumU_, startU + number);
maximumU_ = std::max(maximumU_, startU + number);
numberRowsExtra_++;
numberColumnsExtra_++;
numberGoodU_++;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ int CoinFactorization::replaceColumn2(CoinIndexedVector *regionSparse,
elementR[put] = region[iRow];
//add 4 for luck
if (next == maximumColumnsExtra_)
startR[maximumColumnsExtra_] = CoinMin(static_cast< int >(put + 4), lengthAreaR_);
startR[maximumColumnsExtra_] = std::min(static_cast< int >(put + 4), lengthAreaR_);
} else {
// no space - do we shuffle?
if (!getColumnSpaceIterateR(iRow, region[iRow], pivotRow)) {
Expand Down Expand Up @@ -1242,7 +1242,7 @@ int CoinFactorization::updateColumnTranspose(CoinIndexedVector *regionSparse,
int smallestIndex = numberRowsExtra_;
for (int j = 0; j < numberNonZero; j++) {
int iRow = regionIndex[j];
smallestIndex = CoinMin(smallestIndex, iRow);
smallestIndex = std::min(smallestIndex, iRow);
region[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionSparse, smallestIndex);
Expand Down Expand Up @@ -1328,7 +1328,7 @@ void CoinFactorization::updateOneColumnTranspose(CoinIndexedVector *regionWork,
int smallestIndex = numberRowsExtra_;
for (int j = 0; j < numberNonZero; j++) {
int iRow = regionIndex[j];
smallestIndex = CoinMin(smallestIndex, iRow);
smallestIndex = std::min(smallestIndex, iRow);
region[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionWork, smallestIndex);
Expand Down Expand Up @@ -1450,7 +1450,7 @@ void CoinFactorization::updateTwoColumnsTranspose(CoinIndexedVector *regionSpars
int smallestIndexA = numberRowsExtra_;
for (int j = 0; j < numberNonZeroA; j++) {
int iRow = regionIndexA[j];
smallestIndexA = CoinMin(smallestIndexA, iRow);
smallestIndexA = std::min(smallestIndexA, iRow);
regionA[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionWorkA, smallestIndexA);
Expand All @@ -1471,7 +1471,7 @@ void CoinFactorization::updateTwoColumnsTranspose(CoinIndexedVector *regionSpars
int smallestIndexB = numberRowsExtra_;
for (int j = 0; j < numberNonZeroB; j++) {
int iRow = regionIndexB[j];
smallestIndexB = CoinMin(smallestIndexB, iRow);
smallestIndexB = std::min(smallestIndexB, iRow);
regionB[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionWorkB, smallestIndexB);
Expand Down Expand Up @@ -1510,13 +1510,13 @@ void CoinFactorization::updateTwoColumnsTranspose(CoinIndexedVector *regionSpars
int smallestIndexA = numberRowsExtra_;
for (int j = 0; j < numberNonZeroA; j++) {
int iRow = regionIndexA[j];
smallestIndexA = CoinMin(smallestIndexA, iRow);
smallestIndexA = std::min(smallestIndexA, iRow);
regionA[iRow] *= pivotRegion[iRow];
}
int smallestIndexB = numberRowsExtra_;
for (int j = 0; j < numberNonZeroB; j++) {
int iRow = regionIndexB[j];
smallestIndexB = CoinMin(smallestIndexB, iRow);
smallestIndexB = std::min(smallestIndexB, iRow);
regionB[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionWorkA, smallestIndexA);
Expand Down Expand Up @@ -1556,13 +1556,13 @@ void CoinFactorization::updateTwoColumnsTranspose(CoinIndexedVector *regionSpars
int smallestIndexA = numberRowsExtra_;
for (int j = 0; j < numberNonZeroA; j++) {
int iRow = regionIndexA[j];
smallestIndexA = CoinMin(smallestIndexA, iRow);
smallestIndexA = std::min(smallestIndexA, iRow);
regionA[iRow] *= pivotRegion[iRow];
}
int smallestIndexB = numberRowsExtra_;
for (int j = 0; j < numberNonZeroB; j++) {
int iRow = regionIndexB[j];
smallestIndexB = CoinMin(smallestIndexB, iRow);
smallestIndexB = std::min(smallestIndexB, iRow);
regionB[iRow] *= pivotRegion[iRow];
}
updateColumnTransposeU(regionWorkA, smallestIndexA);
Expand Down Expand Up @@ -2411,7 +2411,7 @@ void CoinFactorization::replaceColumnU(CoinIndexedVector *regionSparse,
deleted++;
}
int nPut = 0;
for (int i = CoinMax(numberSlacks_, internalPivotRow);
for (int i = std::max(numberSlacks_, internalPivotRow);
i < numberU_; i++) {
assert(!region[i]);
CoinFactorizationDouble pivotValue = 0.0; //region[i]*pivotRegion[i];
Expand Down Expand Up @@ -2474,7 +2474,7 @@ void CoinFactorization::updateColumnTransposeUByColumn(CoinIndexedVector *region
region[i] = 0.0;
}
}
for (int i = CoinMax(numberSlacks_, smallestIndex);
for (int i = std::max(numberSlacks_, smallestIndex);
i < numberU_; i++) {
CoinFactorizationDouble pivotValue = region[i] * pivotRegion[i];
//printf("pv %g reg %g pr %g\n",
Expand Down Expand Up @@ -2614,7 +2614,7 @@ void CoinFactorization::updateColumnTransposeR(CoinIndexedVector *regionSparse)
// we have lost indices
// make sure won't try and go sparse again
if (collectStatistics_)
btranCountAfterR_ += CoinMin((numberNonZero << 1), numberRows_);
btranCountAfterR_ += std::min((numberNonZero << 1), numberRows_);
regionSparse->setNumElements(numberRows_ + 1);
}
}
Expand All @@ -2630,13 +2630,13 @@ void CoinFactorization::goSparse()
if (numberRows_ > setSparseSmall) {
if (numberRows_ < 10000) {
sparseThreshold_ =
CoinMin(numberRows_ / setSparseDivMedium, setSparseMinMedium);
std::min(numberRows_ / setSparseDivMedium, setSparseMinMedium);
sparseThreshold2_ = numberRows_/setSparseThresh2;
} else {
sparseThreshold_ = 1000;
sparseThreshold2_ = numberRows_ >> 2;
sparseThreshold_ = 500;
sparseThreshold2_ = CoinMax(sparseThreshold_, numberRows_ >> 3);
sparseThreshold2_ = std::max(sparseThreshold_, numberRows_ >> 3);
}
//printf("sparseThreshold %d threshold2 %d - numberDense %d\n",
// sparseThreshold_,sparseThreshold2_,numberDense_);
Expand All @@ -2646,7 +2646,7 @@ void CoinFactorization::goSparse()
}
} else {
if (!sparseThreshold_ && numberRows_ > 400) {
sparseThreshold_ = CoinMin((numberRows_ - 300) / 9, 1000);
sparseThreshold_ = std::min((numberRows_ - 300) / 9, 1000);
}
sparseThreshold2_ = sparseThreshold_;
}
Expand Down Expand Up @@ -2947,7 +2947,7 @@ int CoinFactorization::getColumnSpaceIterate(int iColumn, double value,
indexRowU[put] = iRow;
numberInColumn[iColumn]++;
//add 4 for luck
startColumnU[maximumColumnsExtra_] = CoinMin(static_cast< int >(put + 4), lengthAreaU_);
startColumnU[maximumColumnsExtra_] = std::min(static_cast< int >(put + 4), lengthAreaU_);
} else {
// no room
put = -1;
Expand Down Expand Up @@ -3506,7 +3506,7 @@ void CoinFactorization::gutsOfCopy(const CoinFactorization &other)
for (int iRow = 0; iRow < numberRowsExtra_; iRow++) {
int start = startColumnU[iRow];
int numberIn = numberInColumn[iRow];
maxU = CoinMax(maxU, start + numberIn);
maxU = std::max(maxU, start + numberIn);
}
assert(maximumU_ >= maxU);
#endif
Expand Down Expand Up @@ -3553,14 +3553,14 @@ void CoinFactorization::checkSparse()
{
// See if worth going sparse and when
if (numberFtranCounts_ > 100) {
ftranCountInput_ = CoinMax(ftranCountInput_, 1.0);
ftranAverageAfterL_ = CoinMax(ftranCountAfterL_ / ftranCountInput_, 1.0);
ftranAverageAfterR_ = CoinMax(ftranCountAfterR_ / ftranCountAfterL_, 1.0);
ftranAverageAfterU_ = CoinMax(ftranCountAfterU_ / ftranCountAfterR_, 1.0);
ftranCountInput_ = std::max(ftranCountInput_, 1.0);
ftranAverageAfterL_ = std::max(ftranCountAfterL_ / ftranCountInput_, 1.0);
ftranAverageAfterR_ = std::max(ftranCountAfterR_ / ftranCountAfterL_, 1.0);
ftranAverageAfterU_ = std::max(ftranCountAfterU_ / ftranCountAfterR_, 1.0);
if (btranCountInput_ && btranCountAfterU_ && btranCountAfterR_) {
btranAverageAfterU_ = CoinMax(btranCountAfterU_ / btranCountInput_, 1.0);
btranAverageAfterR_ = CoinMax(btranCountAfterR_ / btranCountAfterU_, 1.0);
btranAverageAfterL_ = CoinMax(btranCountAfterL_ / btranCountAfterR_, 1.0);
btranAverageAfterU_ = std::max(btranCountAfterU_ / btranCountInput_, 1.0);
btranAverageAfterR_ = std::max(btranCountAfterR_ / btranCountAfterU_, 1.0);
btranAverageAfterL_ = std::max(btranCountAfterL_ / btranCountAfterR_, 1.0);
} else {
// we have not done any useful btrans (values pass?)
btranAverageAfterU_ = 1.0;
Expand Down Expand Up @@ -3588,7 +3588,7 @@ CoinFactorization::conditionNumber() const
for (int i = 0; i < numberRows_; i++) {
condition *= pivotRegion[i];
}
condition = CoinMax(fabs(condition), 1.0e-50);
condition = std::max(fabs(condition), 1.0e-50);
return 1.0 / condition;
}
#ifdef ABC_USE_COIN_FACTORIZATION
Expand Down Expand Up @@ -3627,7 +3627,7 @@ CoinFactorization::checkReplacePart1(CoinIndexedVector *regionSparse,
int smallestIndex = numberRowsExtra_;
for (int i = start; i < end; i++) {
int iColumn = indexColumn[i];
smallestIndex = CoinMin(smallestIndex, iColumn);
smallestIndex = std::min(smallestIndex, iColumn);
int j = convertRowToColumn[i];

region[iColumn] = element[j];
Expand Down Expand Up @@ -3690,7 +3690,7 @@ CoinFactorization::checkReplacePart1(CoinIndexedVector *regionSparse,
int smallestIndex = numberRowsExtra_;
for (int i = start; i < end; i++) {
int iColumn = indexColumn[i];
smallestIndex = CoinMin(smallestIndex, iColumn);
smallestIndex = std::min(smallestIndex, iColumn);
int j = convertRowToColumn[i];

region[iColumn] = element[j];
Expand Down Expand Up @@ -3918,7 +3918,7 @@ void CoinFactorization::replaceColumnPart3(CoinIndexedVector *regionSparse,
for (int i = 0; i < number; i++) {
elementU[i] *= pivotValue;
}
maximumU_ = CoinMax(maximumU_, startU + number);
maximumU_ = std::max(maximumU_, startU + number);
numberRowsExtra_++;
numberColumnsExtra_++;
numberGoodU_++;
Expand Down Expand Up @@ -3970,7 +3970,7 @@ void CoinFactorization::replaceColumnPart3(CoinIndexedVector *regionSparse,
elementR[put] = region[iRow];
//add 4 for luck
if (next == maximumColumnsExtra_)
startR[maximumColumnsExtra_] = CoinMin(static_cast< int >(put + 4), lengthAreaR_);
startR[maximumColumnsExtra_] = std::min(static_cast< int >(put + 4), lengthAreaR_);
} else {
// no space - do we shuffle?
if (!getColumnSpaceIterateR(iRow, region[iRow], pivotRowNew)) {
Expand Down
2 changes: 1 addition & 1 deletion src/CoinFloatEqual.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class COINUTILSLIB_EXPORT CoinAbsFltEq
/*! \brief Equality to a scaled tolerance
Operands are considered equal if their difference is within a scaled
epsilon calculated as epsilon_*(1+CoinMax(|f1|,|f2|)).
epsilon calculated as epsilon_*(1+std::max(|f1|,|f2|)).
*/

class COINUTILSLIB_EXPORT CoinRelFltEq
Expand Down
Loading

0 comments on commit ea38a51

Please sign in to comment.