mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/proba] Test about hypergeometric function
This commit is contained in:
@@ -53,7 +53,8 @@ tests_src += $(addprefix apps/probability/law/,\
|
||||
)
|
||||
tests_src += $(addprefix apps/probability/test/,\
|
||||
erf_inv.cpp\
|
||||
regularized_gamma.cpp\
|
||||
hypergeometric_function.cpp\
|
||||
regularized_gamma.cpp \
|
||||
)
|
||||
|
||||
# Image dependencies
|
||||
|
||||
24
apps/probability/test/hypergeometric_function.cpp
Normal file
24
apps/probability/test/hypergeometric_function.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <quiz.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <cmath>
|
||||
#include "../law/student_law.h"
|
||||
#include "../law/hypergeometric_function.h"
|
||||
|
||||
void assert_hypergeometric_is(double a, double b, double c, double z, double result) {
|
||||
double r = 0.0;
|
||||
const double precision = Probability::StudentLaw::k_hypergeometricFunctionPrecision;
|
||||
quiz_assert(hypergeometricFunction(a, b, c, z, precision, Probability::StudentLaw::k_maxHypergeometricFunctionIterations, &r));
|
||||
quiz_assert(std::abs(r - result)/result <= 100 * precision); // Multiply by 100 because precision is too strict
|
||||
}
|
||||
|
||||
QUIZ_CASE(hypergeometric_function) {
|
||||
assert_hypergeometric_is(1.0, 2.0, 3.0, 0.5, 1.545177444479562475337856971665412544604001074882042032965);
|
||||
assert_hypergeometric_is(0.5, 0.6, 0.9, 0.2, 1.076590925287316818209663064430201685162648800967441005164);
|
||||
assert_hypergeometric_is(1.4, 0.72, 3.56, 0.9, 1.496490448634238403792101320605116555747748144140465947806);
|
||||
assert_hypergeometric_is(10.0, 0.2, 13.3, 0.12, 1.019119266590223428068941990750518046484840980662175905693);
|
||||
assert_hypergeometric_is(0.1, 0.2, 56.0, 0.21, 1.000075183394368041565539149267931545331418014779591403758);
|
||||
assert_hypergeometric_is(33.0, 0.3, 0.5678, 0.765, 85766460438444348287.386477193902261907533508044855870);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user