Skip to content
Snippets Groups Projects
Commit af5981ee authored by Jonathan Youett's avatar Jonathan Youett
Browse files

Use operator 'at' to make code prettier

parent d2e2cc51
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,8 @@ preprocess()
typedef ProjectedBlockGSStep<MatrixType, VectorType> SmootherType;
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->hasObstacle_ = &(*hasObstacle_)[0];
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->obstacles_ = &(*obstacles_)[0];
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->hasObstacle_ = &hasObstacle_->at(0);
dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->obstacles_ = &obstacles_->at(0);
  • Contributor

    While this is certainly more readable, it's not equivalent to the original code. at() performs bounds checking and is, therefore, slower.

  • Developer

    I know that it is slower, but it shouldn't make any difference if it is only called in the preprocessor step.

  • Please register or sign in to reply
#if HAVE_IPOPT
} else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<MatrixType,VectorType>)) {
......@@ -146,7 +146,7 @@ void MonotoneMGStep<MatrixType, VectorType>::iterate()
std::vector<BoxConstraint<field_type,dim> > obstacleBackup = obstacles[level];
// Compute defect obstacles
for (size_t i=0; i<(*obstacles_)[level].size(); i++)
for (size_t i=0; i<obstacles[level].size(); i++)
obstacles[level][i] -= (*x[level])[i];
// ///////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment