OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
TestCubicSpline.cpp File Reference

Unit tests for CubicSpline interpolation (replacement for gsl_spline) More...

#include <gtest/gtest.h>
#include <cmath>
#include <vector>
#include "Utilities/CubicSpline.h"
#include "Utilities/GSLSpline.h"
Include dependency graph for TestCubicSpline.cpp:

Go to the source code of this file.

Classes

class  CubicSplineTest
 

Functions

 TEST_F (CubicSplineTest, BasicInterpolation)
 
 TEST_F (CubicSplineTest, Uninitialised)
 
 TEST_F (CubicSplineTest, Extrapolation)
 
 TEST_F (CubicSplineTest, Accelerator)
 
 TEST_F (CubicSplineTest, SinFunction)
 
 TEST_F (CubicSplineTest, InvalidInput)
 
 TEST_F (CubicSplineTest, Integration)
 
 TEST_F (CubicSplineTest, GSLCompatibleInterface)
 

Detailed Description

Unit tests for CubicSpline interpolation (replacement for gsl_spline)

This file contains comprehensive unit tests for the CubicSpline class, which implements cubic spline interpolation using natural boundary conditions. The implementation provides both a direct C++ interface and GSL-compatible wrapper functions.

Test:
CubicSplineTest::BasicInterpolation Tests basic cubic spline interpolation at data points and between points. Verifies that the spline exactly reproduces input data points and provides smooth interpolation between them. Uses test data \(y = x^2\).
Test:
CubicSplineTest::Extrapolation Tests extrapolation behavior beyond the data range. Verifies that the spline can extrapolate values to the left (before first data point) and right (after last data point) of the input data range.
Test:
CubicSplineTest::Accelerator Tests the accelerator optimization for repeated evaluations. The accelerator caches the last interval index to speed up subsequent evaluations in the same interval. Verifies correct behavior when evaluating in the same interval and when switching to different intervals.
Test:
CubicSplineTest::SinFunction Tests interpolation accuracy on a smooth function (sine). Creates a spline from sampled sine function data and verifies that interpolated values match the true function values within acceptable tolerance.
Test:
CubicSplineTest::InvalidInput Tests error handling for invalid input data. Verifies that exceptions are thrown when: (1) too few data points (< 2) are provided, and (2) x-values are not strictly increasing.
Test:
CubicSplineTest::GSLCompatibleInterface Tests the GSL-compatible wrapper functions (gsl_spline_alloc, gsl_spline_init, gsl_spline_eval, etc.). Verifies that the GSL API is correctly implemented and that the accelerator reset functionality works properly.

Definition in file TestCubicSpline.cpp.

Function Documentation

◆ TEST_F() [1/8]

TEST_F ( CubicSplineTest  ,
Accelerator   
)

Definition at line 97 of file TestCubicSpline.cpp.

References CubicSpline::eval().

Here is the call graph for this function:

◆ TEST_F() [2/8]

TEST_F ( CubicSplineTest  ,
BasicInterpolation   
)

Definition at line 60 of file TestCubicSpline.cpp.

References CubicSpline::eval().

Here is the call graph for this function:

◆ TEST_F() [3/8]

TEST_F ( CubicSplineTest  ,
Extrapolation   
)

Definition at line 84 of file TestCubicSpline.cpp.

References CubicSpline::eval().

Here is the call graph for this function:

◆ TEST_F() [4/8]

TEST_F ( CubicSplineTest  ,
GSLCompatibleInterface   
)

◆ TEST_F() [5/8]

TEST_F ( CubicSplineTest  ,
Integration   
)

Definition at line 145 of file TestCubicSpline.cpp.

References CubicSpline::evalIntegral(), and CubicSpline::init().

Here is the call graph for this function:

◆ TEST_F() [6/8]

TEST_F ( CubicSplineTest  ,
InvalidInput   
)

Definition at line 133 of file TestCubicSpline.cpp.

◆ TEST_F() [7/8]

TEST_F ( CubicSplineTest  ,
SinFunction   
)

Definition at line 116 of file TestCubicSpline.cpp.

References CubicSpline::eval().

Here is the call graph for this function:

◆ TEST_F() [8/8]

TEST_F ( CubicSplineTest  ,
Uninitialised   
)

Definition at line 77 of file TestCubicSpline.cpp.

References CubicSpline::eval().

Here is the call graph for this function: