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

Unit tests for GSL numerical integration routines. More...

#include <gtest/gtest.h>
#include <cmath>
#include "Utilities/GSLIntegration.h"
Include dependency graph for TestGSLIntegration.cpp:

Go to the source code of this file.

Classes

class  GSLIntegrationTest
 

Functions

double linear_func (double x, void *)
 
double quadratic_func (double x, void *)
 
double sin_func (double x, void *)
 
double exp_func (double x, void *)
 
 TEST_F (GSLIntegrationTest, LinearFunction)
 
 TEST_F (GSLIntegrationTest, QuadraticFunction)
 
 TEST_F (GSLIntegrationTest, SinFunction)
 
 TEST_F (GSLIntegrationTest, ExpFunction)
 
 TEST_F (GSLIntegrationTest, NegativeRange)
 
 TEST_F (GSLIntegrationTest, SmallRange)
 

Detailed Description

Unit tests for GSL numerical integration routines.

This file contains unit tests for GSL-compatible numerical integration routines. The implementation uses adaptive Simpson's rule for computing definite integrals with specified error tolerances.

Test:
GSLIntegrationTest::LinearFunction Tests integration of a linear function \(f(x) = x\) over the interval \([0, 1]\). Verifies that \(\int_0^1 x \, dx = \frac{1}{2}\) is computed correctly within the specified tolerance.
Test:
GSLIntegrationTest::QuadraticFunction Tests integration of a quadratic function \(f(x) = x^2\) over the interval \([0, 2]\). Verifies that \(\int_0^2 x^2 \, dx = \frac{8}{3}\) is computed correctly.
Test:
GSLIntegrationTest::SinFunction Tests integration of the sine function \(f(x) = \sin(x)\) over the interval \([0, \pi]\). Verifies that \(\int_0^{\pi} \sin(x) \, dx = 2\) is computed correctly, confirming proper handling of oscillatory functions.
Test:
GSLIntegrationTest::ExpFunction Tests integration of the exponential function \(f(x) = e^x\) over the interval \([0, 1]\). Verifies that \(\int_0^1 e^x \, dx = e - 1\) is computed correctly.
Test:
GSLIntegrationTest::NegativeRange Tests integration over a range that includes negative values. Verifies that \(\int_{-1}^1 x \, dx = 0\) (odd function over symmetric interval) is computed correctly.
Test:
GSLIntegrationTest::SmallRange Tests integration over a small interval. Verifies that the adaptive algorithm works correctly for narrow integration ranges and maintains accuracy.

Definition in file TestGSLIntegration.cpp.

Function Documentation

◆ exp_func()

double exp_func ( double  x,
void *   
)

Definition at line 60 of file TestGSLIntegration.cpp.

Referenced by TEST_F().

◆ linear_func()

double linear_func ( double  x,
void *   
)

Definition at line 51 of file TestGSLIntegration.cpp.

Referenced by TEST_F(), and TEST_F().

◆ quadratic_func()

double quadratic_func ( double  x,
void *   
)

Definition at line 54 of file TestGSLIntegration.cpp.

Referenced by TEST_F(), and TEST_F().

◆ sin_func()

double sin_func ( double  x,
void *   
)

Definition at line 57 of file TestGSLIntegration.cpp.

Referenced by TEST_F().

◆ TEST_F() [1/6]

TEST_F ( GSLIntegrationTest  ,
ExpFunction   
)

◆ TEST_F() [2/6]

TEST_F ( GSLIntegrationTest  ,
LinearFunction   
)

◆ TEST_F() [3/6]

TEST_F ( GSLIntegrationTest  ,
NegativeRange   
)

◆ TEST_F() [4/6]

TEST_F ( GSLIntegrationTest  ,
QuadraticFunction   
)

◆ TEST_F() [5/6]

TEST_F ( GSLIntegrationTest  ,
SinFunction   
)

◆ TEST_F() [6/6]