Interpolation: Fix "trend" extrapolation for value outside of range on high end.

This commit is contained in:
Kristian Bendiksen committed 2024-04-05 14:39:46 +02:00
1 parent bce4dcfe54
commit bebf59c309
3 files changed
+31 -1

No files matched your search

@@ -117,6 +117,19 @@ TEST( RiaInterpolationToolsTest, ValidIntervalValueTooLowExtrapolationTrend )
EXPECT_DOUBLE_EQ( -2.0, res );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST( RiaInterpolationToolsTest, ValidIntervalValueTooHighExtrapolationTrend )
{
std::vector<double> x = { 0.0, 1.0, 2.0, 3.0 };
std::vector<double> y = { 0.0, 1.0, 10.0, 20.0 };
// Outside interval on low side
double res = RiaInterpolationTools::linear( x, y, 4.0, RiaInterpolationTools::ExtrapolationMode::TREND );
EXPECT_DOUBLE_EQ( 30.0, res );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------