Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed calculation of interpolated value at upper limit #16

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/Interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Kernel

if ( at >= m_x[N-1] )
{
return m_y[N-1]+(at-m_y[N-1])*(m_y[N-1]-m_y[N-2])/(m_x[N-1]-m_x[N-2]);
return m_y[N-1]+(at-m_x[N-1])*(m_y[N-1]-m_y[N-2])/(m_x[N-1]-m_x[N-2]);
}

// otherwise
Expand Down
9 changes: 5 additions & 4 deletions Code/Mantid/Framework/Kernel/test/InterpolationTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ class InterpolationTest : public CxxTest::TestSuite

// Test that all the base class member variables are correctly assigned to
TS_ASSERT_DELTA( interpolation.value(100), -950.0 ,0.000000001);
TS_ASSERT_DELTA( interpolation.value(3000), 260400.0 ,0.000000001);
TS_ASSERT_DELTA( interpolation.value(3000), 280000.0 ,0.000000001);
TS_ASSERT_DELTA( interpolation.value(200.5), 55.0 ,0.000000001);
TS_ASSERT_DELTA( interpolation.value(201.25), 70.0 ,0.000000001);
TS_ASSERT_DELTA( interpolation.value(203.5), 350.0 ,0.000000001);

TS_ASSERT_EQUALS(interpolation.value(204.0), 400.0);

interpolation.setXUnit("Wavelength");
interpolation.setYUnit("dSpacing");
Expand All @@ -49,11 +50,11 @@ class InterpolationTest : public CxxTest::TestSuite

// Test that all the base class member variables are correctly assigned to
TS_ASSERT_DELTA( readIn.value(100), -950.0 ,0.000000001);
TS_ASSERT_DELTA( readIn.value(3000), 260400.0 ,0.000000001);
TS_ASSERT_DELTA( readIn.value(3000), 280000.0 ,0.000000001);
TS_ASSERT_DELTA( readIn.value(200.5), 55.0 ,0.000000001);
TS_ASSERT_DELTA( readIn.value(201.25), 70.0 ,0.000000001);
TS_ASSERT_DELTA( readIn.value(203.5), 350.0 ,0.000000001);
}
TS_ASSERT_DELTA( readIn.value(203.5), 350.0 ,0.000000001);
}

void testEmpty()
{
Expand Down