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

Unit tests for GSL special functions compatibility. More...

#include <gtest/gtest.h>
#include <cmath>
#include <limits>
#include "Utilities/GSLCompat.h"
Include dependency graph for TestGSLCompat.cpp:

Go to the source code of this file.

Classes

class  GSLCompatTest
 

Functions

 TEST_F (GSLCompatTest, ErfFunction)
 
 TEST_F (GSLCompatTest, PowInt)
 
 TEST_F (GSLCompatTest, GammaFunction)
 
 TEST_F (GSLCompatTest, Factorial)
 
 TEST_F (GSLCompatTest, FactorialLarge)
 
 TEST_F (GSLCompatTest, BinomialCoefficient)
 
 TEST_F (GSLCompatTest, BinomialCoefficientEdgeCases)
 
 TEST_F (GSLCompatTest, Hypot)
 
 TEST_F (GSLCompatTest, ErrorHandler)
 

Detailed Description

Unit tests for GSL special functions compatibility.

This file contains unit tests for GSL-compatible special function wrappers. These functions provide compatibility with GSL's special function API while using C++ standard library implementations where possible.

Test:
GSLCompatTest::ErfFunction Tests the error function \(\text{erf}(x)\) implementation. Verifies that gsl_sf_erf() matches std::erf() for various input values, including zero, positive, negative, and large values approaching the asymptotic limit of 1.
Test:
GSLCompatTest::PowInt Tests integer power function \(x^n\) for both positive and negative integer exponents. Verifies correct computation of powers including edge cases: \(x^0 = 1\), \(x^1 = x\), and negative powers \(x^{-n} = 1/x^n\).
Test:
GSLCompatTest::GammaFunction Tests the gamma function \(\Gamma(x)\) implementation. Verifies that gsl_sf_gamma() matches std::tgamma() for integer values (factorial property: \(\Gamma(n+1) = n!\)) and half-integer values ( \(\Gamma(1/2) = \sqrt{\pi}\)).
Test:
GSLCompatTest::Factorial Tests factorial function \(n!\) for small integer values. Verifies correct computation of factorials from 0 to 10, including the special case \(0! = 1\).
Test:
GSLCompatTest::FactorialLarge Tests factorial function for larger values (e.g., 20!). For large factorials, the implementation uses the gamma function to avoid overflow. Verifies that large factorials are computed correctly within numerical precision limits.
Test:
GSLCompatTest::BinomialCoefficient Tests binomial coefficient \(\binom{n}{m} = \frac{n!}{m!(n-m)!}\). Verifies correct computation including symmetry property \(\binom{n}{m} = \binom{n}{n-m}\) and edge cases: \(\binom{n}{0} = \binom{n}{n} = 1\).
Test:
GSLCompatTest::BinomialCoefficientEdgeCases Tests edge cases for binomial coefficients: when \(m > n\) (should return 0), and when \(n = 0\) or \(n = 1\) with various \(m\) values.
Test:
GSLCompatTest::Hypot Tests the hypotenuse function \(\text{hypot}(x, y) = \sqrt{x^2 + y^2}\). Verifies correct computation for Pythagorean triples (e.g., 3-4-5, 5-12-13) and edge cases with zero values.
Test:
GSLCompatTest::ErrorHandler Tests GSL error handler functions. Verifies that error handlers can be set and disabled without causing crashes or exceptions.

Definition in file TestGSLCompat.cpp.

Function Documentation

◆ TEST_F() [1/9]

TEST_F ( GSLCompatTest  ,
BinomialCoefficient   
)

Definition at line 113 of file TestGSLCompat.cpp.

References gsl_sf_choose().

Here is the call graph for this function:

◆ TEST_F() [2/9]

TEST_F ( GSLCompatTest  ,
BinomialCoefficientEdgeCases   
)

Definition at line 125 of file TestGSLCompat.cpp.

References gsl_sf_choose().

Here is the call graph for this function:

◆ TEST_F() [3/9]

TEST_F ( GSLCompatTest  ,
ErfFunction   
)

Definition at line 66 of file TestGSLCompat.cpp.

References gsl_sf_erf().

Here is the call graph for this function:

◆ TEST_F() [4/9]

TEST_F ( GSLCompatTest  ,
ErrorHandler   
)

Definition at line 140 of file TestGSLCompat.cpp.

References gsl_set_error_handler(), and gsl_set_error_handler_off().

Here is the call graph for this function:

◆ TEST_F() [5/9]

TEST_F ( GSLCompatTest  ,
Factorial   
)

Definition at line 96 of file TestGSLCompat.cpp.

References gsl_sf_fact().

Here is the call graph for this function:

◆ TEST_F() [6/9]

TEST_F ( GSLCompatTest  ,
FactorialLarge   
)

Definition at line 106 of file TestGSLCompat.cpp.

References gsl_sf_fact().

Here is the call graph for this function:

◆ TEST_F() [7/9]

TEST_F ( GSLCompatTest  ,
GammaFunction   
)

Definition at line 88 of file TestGSLCompat.cpp.

References gsl_sf_gamma().

Here is the call graph for this function:

◆ TEST_F() [8/9]

TEST_F ( GSLCompatTest  ,
Hypot   
)

Definition at line 132 of file TestGSLCompat.cpp.

References gsl_hypot().

Here is the call graph for this function:

◆ TEST_F() [9/9]

TEST_F ( GSLCompatTest  ,
PowInt   
)

Definition at line 76 of file TestGSLCompat.cpp.

References gsl_sf_pow_int().

Here is the call graph for this function: