MCPcopy Create free account
hub / github.com/bgrimstad/splinter / testKnotInsertion

Function testKnotInsertion

test/bsplinetestingutilities.cpp:44–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44bool testKnotInsertion()
45{
46 DataTable samples = sampleTestFunction();
47
48 // Build B-splines that interpolate the samples
49 BSpline bspline1 = BSpline::Builder(samples).degree(1).build();
50 BSpline bspline2 = BSpline::Builder(samples).degree(2).build();
51 BSpline bspline3 = BSpline::Builder(samples).degree(3).build();
52
53 BSpline bspline1_copy(bspline1);
54 BSpline bspline2_copy(bspline2);
55 BSpline bspline3_copy(bspline3);
56
57 bspline1.insertKnots(0.83, 0);
58 bspline1.insertKnots(1.37, 1);
59 bspline2.insertKnots(0.83, 1);
60 bspline2.insertKnots(1.37, 0);
61 bspline3.insertKnots(0.83, 1);
62 bspline3.insertKnots(1.37, 1);
63
64 // Sample function
65 auto x0_vec = linspace(0, 2, 200);
66 auto x1_vec = linspace(0, 2, 200);
67 DenseVector x(2);
68
69 for (auto x0 : x0_vec)
70 {
71 for (auto x1 : x1_vec)
72 {
73 // Sample function at x
74 x(0) = x0;
75 x(1) = x1;
76
77 double y1 = bspline1.eval(x);
78 double y1_copy = bspline1_copy.eval(x);
79
80 if (!assertNear(y1, y1_copy, 1e-10))
81 return false;
82
83 double y2 = bspline2.eval(x);
84 double y2_copy = bspline2_copy.eval(x);
85
86 if (!assertNear(y2, y2_copy, 1e-10))
87 return false;
88
89 double y3 = bspline3.eval(x);
90 double y3_copy = bspline3_copy.eval(x);
91
92 if (!assertNear(y3, y3_copy, 1e-10))
93 return false;
94 }
95 }
96
97 return true;
98}
99
100bool domainReductionTest(BSpline &bs, const BSpline &bs_orig)
101{

Callers 1

bspline.cppFile · 0.85

Calls 8

sampleTestFunctionFunction · 0.85
BuilderClass · 0.85
assertNearFunction · 0.85
degreeMethod · 0.80
linspaceFunction · 0.70
buildMethod · 0.45
insertKnotsMethod · 0.45
evalMethod · 0.45

Tested by

no test coverage detected