MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / Integrate

Method Integrate

ngstd/bspline.cpp:44–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 }
43
44 BSpline BSpline :: Integrate () const
45 {
46 /*
47 Array<double> text(t.Size()+2);
48 text[0] = t[0];
49 text.Range(1, t.Size()+1) = t;
50 text[text.Size()-1] = text[text.Size()-2];
51
52 Array<double> ci(c.Size()+2);
53 ci = 0;
54 for (int j = 0; j < t.Size()-order; j++)
55 ci[j+1] = ci[j] + c[j] * (t[j+order] - t[j]) / order;
56 // better, but still not correct ...
57 int last = t.Size()-order-1;
58 for (int j = t.Size()-order; j < ci.Size()-1; j++)
59 ci[j+1] = ci[j] + c[last] * (t[last+order] - t[j]) / order;
60
61 cout << "integral, c = " << c << endl << "ci = " << ci << endl;
62 return BSpline (order+1, move(text), move(ci));
63 */
64
65 //we should create text and ci WITHOUT padding on the leftmost elements
66 const auto origsize = t.Size() - order;
67 Array<double> text(origsize+order+1);
68 text.Range(0, origsize) = t.Range(order,t.Size());
69 for (int j = origsize; j < text.Size(); j++)
70 text[j] = t[t.Size()-1];
71
72 Array<double> ci(origsize+1);
73 ci = 0;
74 double sum = 0;
75 for (int j = order; j < t.Size()-order; j++)
76 {
77 sum += c[j] * (t[j+order] - t[j]) / order;
78 ci[j-order] = sum;
79 }
80
81 for (int j = t.Size()-order; j < t.Size(); j++)
82 {
83 sum += c[t.Size()-order] * (t[t.Size()-1] - t[j]) / order;
84 ci[j-order] = sum;
85 }
86 ci[origsize] = ci[origsize-1];
87
88 // cout << "integral, c = " << c << endl << "ci = " << ci << endl;
89 return BSpline (order+1, std::move(text), std::move(ci));
90 }
91
92
93 double BSpline :: Evaluate (double x) const

Callers

nothing calls this directly

Calls 3

BSplineClass · 0.85
SizeMethod · 0.45
RangeMethod · 0.45

Tested by

no test coverage detected