Skip to content

Commit

Permalink
Fix off-by-one error in IkedaCarpenterModerator model.
Browse files Browse the repository at this point in the history
If the value from the sample table is nearer the last edge then simply
returns the last value.
Refs #7548
  • Loading branch information
martyngigg committed Oct 28, 2013
1 parent ae99fb0 commit 9069db1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Code/Mantid/Framework/API/src/IkedaCarpenterModerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ namespace Mantid
const unsigned int nsteps = (m_lookupSize - 1);
const unsigned int indexBelow = static_cast<unsigned int>(std::floor(area*nsteps));
const double step = area*nsteps - indexBelow;
return m_areaToTimeLookup[indexBelow]*(1.0 - step) + m_areaToTimeLookup[indexBelow + 1]*step;
if(indexBelow < nsteps )
return m_areaToTimeLookup[indexBelow]*(1.0 - step) + m_areaToTimeLookup[indexBelow + 1]*step;
else
return m_areaToTimeLookup[indexBelow]; // last edge value

}


Expand Down

0 comments on commit 9069db1

Please sign in to comment.