Must use std::function because a capturing alpha cannot be converted to a function pointer
| 890 | |
| 891 | // Must use std::function because a capturing alpha cannot be converted to a function pointer |
| 892 | void testApproximation(std::vector<TestFunction *> funcs, |
| 893 | std::function<Function *(const DataTable &table)> approx_gen_func, |
| 894 | TestType type, size_t numSamplePoints, size_t numEvalPoints, |
| 895 | double one_eps, double two_eps, double inf_eps) |
| 896 | { |
| 897 | for(auto &exact : funcs) { |
| 898 | |
| 899 | auto dim = exact->getNumVariables(); |
| 900 | CHECK(dim > 0); |
| 901 | if(dim > 0) { |
| 902 | auto samplePoints = linspace(dim, -5, 5, std::pow(numSamplePoints, 1.0/dim)); |
| 903 | auto evalPoints = linspace(dim, -4.95, 4.95, std::pow(numEvalPoints, 1.0/dim)); |
| 904 | |
| 905 | DataTable table = sample(exact, samplePoints); |
| 906 | |
| 907 | Function *approx = approx_gen_func(table); |
| 908 | |
| 909 | INFO("Function: " << exact->getFunctionStr()); |
| 910 | INFO("Approximant: " << approx->getDescription()); |
| 911 | |
| 912 | DenseMatrix errorNorms = getErrorNorms(exact, approx, evalPoints); |
| 913 | |
| 914 | checkNorm(errorNorms, type, evalPoints.size(), one_eps, two_eps, inf_eps); |
| 915 | |
| 916 | delete approx; |
| 917 | } |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | DenseMatrix centralDifference(const Function &approx, const DenseVector &x) |
| 922 | { |
nothing calls this directly
no test coverage detected