Skip to content
Snippets Groups Projects
Commit d8aa6c00 authored by Elias Pipping's avatar Elias Pipping
Browse files

Replace std::min/max with std::fmin/fmax for NaNs

parent 9a911ec4
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -114,28 +114,19 @@ solveLocalSystem(const Dune::BTDMatrix<typename MatrixType::block_type>& matrix,
for (size_t i=0; i<linearCorrection.size(); i++) {
for (int j=0; j<BlockSize; j++) {
// fmin and fmax ignore NAN values
if (linearCorrection[i][j] > 0) {
// This division can cause nan on some platforms...
if (!isnan( (localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]) )
lineSearchObs.lower(0) = std::max(lineSearchObs.lower(0),
(localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]);
if (!isnan( (localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]) )
lineSearchObs.upper(0) = std::min(lineSearchObs.upper(0),
(localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]);
lineSearchObs.lower(0) = std::fmax(lineSearchObs.lower(0),
(localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]);
lineSearchObs.upper(0) = std::fmin(lineSearchObs.upper(0),
(localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]);
}
if (linearCorrection[i][j] < 0) {
if (!isnan( (localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]) )
lineSearchObs.lower(0) = std::max(lineSearchObs.lower(0),
(localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]);
if (!isnan( (localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]) )
lineSearchObs.upper(0) = std::min(lineSearchObs.upper(0),
(localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]);
lineSearchObs.lower(0) = std::fmax(lineSearchObs.lower(0),
(localObstacles[i].upper(j)-x[i][j]) / linearCorrection[i][j]);
lineSearchObs.upper(0) = std::fmin(lineSearchObs.upper(0),
(localObstacles[i].lower(j)-x[i][j]) / linearCorrection[i][j]);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment