G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsQuasiInterpolate< T > Struct Template Reference

Detailed Description

template<class T>
struct gismo::gsQuasiInterpolate< T >

Quasi-interpolation operators.

The struct gsQuasiInterpolate has three public member functions to use. These functions are implementations of different quasi interpolation methods, described in "Spline methods (Lyche Morken)" [10]. They take a function and approximate it via a B-Spline function, whose basis you have to provide. More details can be found in the description of the respective implementations and in [10].

Template Parameters
Tcoefficient type

Static Public Member Functions

static void EvalBased (const gsBasis< T > &bb, const gsFunction< T > &fun, const bool specialCase, gsMatrix< T > &result)
 A quasi-interpolation scheme based on the evaluation of the function at certain points. See sections 8.2.1, 8.2.2, 8.2.3 and Theorem 8.7 or Lemma 9.7 of "Spline methods (Lyche Morken)". The formulas for the special cases (degrees 1, 2 and 3) look like this:

\[ P_{deg}~f(x) = \sum_{j=1}^n {\lambda_j(f) B_j(x)} \]

where the coefficients \( \lambda_j\) for \( j=1,\dots,n\) are given as:

\[ \lambda_j(f) = f(\tau_{j+1}) \]

for degree 1,

\[ \lambda_j(f) = \begin{cases} f(\tau_1) &\mbox{if } j=1; \\ \frac{1}{2} (-f(x_{j,0}) + 4f(x_{j,1}) - f(x_{j,2}) ), &\mbox{if } 1<j<n; \\ f(\tau_{n+1}) &\mbox{if } j=n; \end{cases} \]

where \( x_{j,0} = \tau_{j+1}, \quad x_{j,1} = \frac{\tau_{j+1}+\tau_{j+2}}{2}, \quad x_{j,2} = \tau_{j+2} \). More...

 
static void Schoenberg (const gsBasis< T > &b, const gsFunction< T > &fun, gsMatrix< T > &result)
 A quasi-interpolation scheme based on Schoenberg Variation Diminishing Spline Approximation. See Exercise 9.1 of "Spline methods (Lyche Morken)". More...
 
static void Taylor (const gsBasis< T > &bb, const gsFunction< T > &fun, const int &r, gsMatrix< T > &result)
 A quasi-interpolation scheme based on the tayor expansion of the function to approximate. See Theorem 8.5 of "Spline methods (Lyche Morken)" Theorem: (Lyche, Morken: Thm 8.5, page 178) Let \(p\) and \(\boldsymbol{\tau}\) be the degree and knotvector of the quasi-interpolant, respectively. Futhermore let \(r\) be an integer with \( 0 \le r \le p \) and let \(x_j\) be a number in \([\tau_j, \tau_{j+p+1}]\) for \(j=1,\dots,n\). Consider the quasi-interpolant

\[ Q_{p,r}~f=\sum\limits_{j=1}^n{\lambda_j(f)B_{j,p}}, \quad \text{where} \quad \lambda_j(f) = \frac{1}{p!}\sum\limits_{k=0}^r{(-1)^kD^{p-k}\rho_{j,p}(x_j)D^kf(x_j)} \]

and \(\rho_{j,p}(y) = (y-\tau_{j+1}) \cdots (y - \tau_{j+p})\). Then \(Q_{p,r}\) reproduces all polynomials of degree \(r\) and \(Q_{p,p}\) reproduces all splines in \(\mathbb{S}_{p,\tau}\). More...

 

Static Protected Member Functions

static gsMatrix< T > computeControlPoints (const gsMatrix< T > &weights, const gsFunction< T > &fun, const gsMatrix< T > &xik)
 The quasi-interpolant is a spline function, in particular a linear combination of some controlpoints and the B-spline basis functions. \(Q_p~f(x) = \sum\limits_{i=1}^n{\lambda_i(f)B_{i,p(x)}}\) where the controlpoints can be computed as \(\lambda_i(f) = \sum\limits_{k=0}^p{\omega_{i,k}f(x_i,k)}\). The points \(x_{i,k}\) are equally distributed points in the largest subinterval of \([\tau_{i+1}, \tau_{i+p}]\). More...
 
static void computeWeights (const gsMatrix< T > &points, const gsKnotVector< T > &knots, const int &pos, gsMatrix< T > &weights)
 To compute the control points \( \lambda_i(f) = \sum\limits_{k=0}^p{\omega_{i,k}f(x_{i,k})} \) of the quasi-interpolant one uses the function computeControlPoints. The weights \( \omega_{i,k} \) can be computed as \(\omega_{i,k} = \gamma_i(p_{i,k})\), for \(k=0,1,\dots,p\), where

\[ \gamma_i(g) = \frac{1}{p!}\sum\limits_{(j_1,\dots,j_p)\in \mathcal{P}_p}{(\tau_{i+j_1}-v_1)\cdots(\tau_{i+j_p}-vp)},\]

for a polynomial \(g(x) = (x-v_1) \cdots (x-v_p)\), where \(\mathcal{P}_p\) is the set of all permutations of the intergers \(\{1,2,\dots,p\}\). More...

 
static T derivProd (const std::vector< T > &zeros, const int &order, const T &x)
 Compute the derivative of a certain order of a normalized polynomial (leading coefficient is 1) defined by its roots at a given point. \(g(y) = (y-y_1) \cdots (y-y_n)\), where \(y_1,\dots,y_n\) are the roots of the polynomial. More...
 
static void distributePoints (T a, T b, int n, gsMatrix< T > &points)
 Compute a number of equally distributed points in a given interval \([a,b]\). You get a list of points \(\{a, a+(b-a)\frac{1}{n-1}, \dots, a+(b-a)\frac{n-2}{n-1}, b\}\). More...
 
static int greatestSubInterval (const gsKnotVector< T > &knots, const int &posStart, const int &posEnd)
 This function finds the greatest knot interval in a given range in a knot vector. More...
 

Member Function Documentation

gsMatrix< T > computeControlPoints ( const gsMatrix< T > &  weights,
const gsFunction< T > &  fun,
const gsMatrix< T > &  xik 
)
staticprotected

The quasi-interpolant is a spline function, in particular a linear combination of some controlpoints and the B-spline basis functions. \(Q_p~f(x) = \sum\limits_{i=1}^n{\lambda_i(f)B_{i,p(x)}}\) where the controlpoints can be computed as \(\lambda_i(f) = \sum\limits_{k=0}^p{\omega_{i,k}f(x_i,k)}\). The points \(x_{i,k}\) are equally distributed points in the largest subinterval of \([\tau_{i+1}, \tau_{i+p}]\).

Parameters
weightsthe weights \(\omega_i,k\) of the above formula
funthe function to approximate, \(f\) of the above formula
xikthe points \(x_{i,k}\) of the above formula
Returns
the computed control point \(\lambda_i(f)\)
void computeWeights ( const gsMatrix< T > &  points,
const gsKnotVector< T > &  knots,
const int &  pos,
gsMatrix< T > &  weights 
)
staticprotected

To compute the control points \( \lambda_i(f) = \sum\limits_{k=0}^p{\omega_{i,k}f(x_{i,k})} \) of the quasi-interpolant one uses the function computeControlPoints. The weights \( \omega_{i,k} \) can be computed as \(\omega_{i,k} = \gamma_i(p_{i,k})\), for \(k=0,1,\dots,p\), where

\[ \gamma_i(g) = \frac{1}{p!}\sum\limits_{(j_1,\dots,j_p)\in \mathcal{P}_p}{(\tau_{i+j_1}-v_1)\cdots(\tau_{i+j_p}-vp)},\]

for a polynomial \(g(x) = (x-v_1) \cdots (x-v_p)\), where \(\mathcal{P}_p\) is the set of all permutations of the intergers \(\{1,2,\dots,p\}\).

Parameters
pointsthe points \(x_{i,k}\) of the above formula
knotsthe knotvector of the quasi-interpolant
posthe index i of the above formula
[out]weightsthe computed weights \(\omega_{i,k}\) of the above formula
T derivProd ( const std::vector< T > &  zeros,
const int &  order,
const T &  x 
)
staticprotected

Compute the derivative of a certain order of a normalized polynomial (leading coefficient is 1) defined by its roots at a given point. \(g(y) = (y-y_1) \cdots (y-y_n)\), where \(y_1,\dots,y_n\) are the roots of the polynomial.

Parameters
zerosroots of the polynomial
orderthe order of the derivative to compute
xevaluation point
Returns
the value of the derivative, at the given point, \(D^\alpha g(x)\), where \(\alpha\) is the given order.
void distributePoints ( a,
b,
int  n,
gsMatrix< T > &  points 
)
staticprotected

Compute a number of equally distributed points in a given interval \([a,b]\). You get a list of points \(\{a, a+(b-a)\frac{1}{n-1}, \dots, a+(b-a)\frac{n-2}{n-1}, b\}\).

Parameters
astart value of the interval
bend value of the interval
nnumber of points
[out]computedpoints
void EvalBased ( const gsBasis< T > &  bb,
const gsFunction< T > &  fun,
const bool  specialCase,
gsMatrix< T > &  result 
)
static

A quasi-interpolation scheme based on the evaluation of the function at certain points. See sections 8.2.1, 8.2.2, 8.2.3 and Theorem 8.7 or Lemma 9.7 of "Spline methods (Lyche Morken)". The formulas for the special cases (degrees 1, 2 and 3) look like this:

\[ P_{deg}~f(x) = \sum_{j=1}^n {\lambda_j(f) B_j(x)} \]

where the coefficients \( \lambda_j\) for \( j=1,\dots,n\) are given as:

\[ \lambda_j(f) = f(\tau_{j+1}) \]

for degree 1,

\[ \lambda_j(f) = \begin{cases} f(\tau_1) &\mbox{if } j=1; \\ \frac{1}{2} (-f(x_{j,0}) + 4f(x_{j,1}) - f(x_{j,2}) ), &\mbox{if } 1<j<n; \\ f(\tau_{n+1}) &\mbox{if } j=n; \end{cases} \]

where \( x_{j,0} = \tau_{j+1}, \quad x_{j,1} = \frac{\tau_{j+1}+\tau_{j+2}}{2}, \quad x_{j,2} = \tau_{j+2} \).

for degree 2 and

\[ \lambda_j(f) = \begin{cases} f(\tau_4) &\mbox{if} j=1; \\ \frac{1}{18}(-5f(\tau_4)+40f(\tau_{9/2})-24f(\tau_5)+8f(\tau_{11/2})-f(\tau_6)) &\mbox{if } j=2; \\ \frac{1}{6} (f(\tau_{j+1}) -8f(\tau_{j+3/2}) +20 f(\tau_{j+2}) -8f(\tau_{j+5/2})+f(\tau_{j+3})), &\mbox{if } 2<j<n-1; \\ \frac{1}{18}(-f(\tau_{n-1})+8f(\tau_{n-1/2})-24f(\tau_n)+40f(\tau_{n+1/2})-5f(\tau_{n+1})) &\mbox{if } j=n-1; \\ f(\tau_{n+1}) &\mbox{if } j=n; \end{cases} \]

where \( \tau_{j+k/2} = \frac{\tau_{j+(k-1)/2}+\tau_{j+(k+1)/2}}{2} \),

for degree 3.

Theorem 8.7:

Let \( \mathbb{S}_{p,\mathbf{\tau}} \) be a spline space with a \(p+1\)-regular knot vector \( \tau = (\mathbf{\tau}_i)_{i=1}^{n+p+1} \). Let \( (x_{j,k})_{k=0}^r \) be \(r+1\) distinct points in \( [\tau_j,\tau_{j+p+1}] \) for \( j=1, \dots, n \) and let \(\omega_{j,k} \) be the j-th B-spline coefficient of the polynomial

\[ p_{j,k}(x) = \prod_{s=0, s\ne k}^r {\frac{x-x_{j,s}}{x_{j,k}-x_{j,s}}}. \]

Then \(P_{p,p}~f = f \) for all \( f \in \tau_r \) and if \(r=p\) and all the numbers \((x_{j,k})_{k=0}^r \) lie in one subinterval

\[ \tau_j \le \tau_{\ell_j} \le x_{j,0} < x_{j,1} < \cdots < x_{j,r} \le \tau_{\ell_j +1} \le \tau_{j+p+1} \]

then \(P_{p,p}~f = f\) for all \( f \in \mathbb{S}_{p,\mathbf{\tau}} \).

Parameters
bthe B-spline basis of the interpolant (knots and degree)
funa function to approximate,
specialCaseif set to true, use the special implementations for degrees 1, 2 and 3; if set to false, use the general implementation
resulta B-spline function, that approximates the given function
int greatestSubInterval ( const gsKnotVector< T > &  knots,
const int &  posStart,
const int &  posEnd 
)
staticprotected

This function finds the greatest knot interval in a given range in a knot vector.

Parameters
knotsthe knot vector
posStartthe index of the left knot of the first interval to be considered
posEndthe index of the right knot of the last interval to be considers
Returns
the index of the left knot of the largest knot interval
void Schoenberg ( const gsBasis< T > &  b,
const gsFunction< T > &  fun,
gsMatrix< T > &  result 
)
static

A quasi-interpolation scheme based on Schoenberg Variation Diminishing Spline Approximation. See Exercise 9.1 of "Spline methods (Lyche Morken)".

Parameters
bthe B-spline basis of the interpolant (knots and degree)
funa function to approximate
[out]resulta B-spline function, that approximates the given function
void Taylor ( const gsBasis< T > &  bb,
const gsFunction< T > &  fun,
const int &  r,
gsMatrix< T > &  result 
)
static

A quasi-interpolation scheme based on the tayor expansion of the function to approximate. See Theorem 8.5 of "Spline methods (Lyche Morken)" Theorem: (Lyche, Morken: Thm 8.5, page 178) Let \(p\) and \(\boldsymbol{\tau}\) be the degree and knotvector of the quasi-interpolant, respectively. Futhermore let \(r\) be an integer with \( 0 \le r \le p \) and let \(x_j\) be a number in \([\tau_j, \tau_{j+p+1}]\) for \(j=1,\dots,n\). Consider the quasi-interpolant

\[ Q_{p,r}~f=\sum\limits_{j=1}^n{\lambda_j(f)B_{j,p}}, \quad \text{where} \quad \lambda_j(f) = \frac{1}{p!}\sum\limits_{k=0}^r{(-1)^kD^{p-k}\rho_{j,p}(x_j)D^kf(x_j)} \]

and \(\rho_{j,p}(y) = (y-\tau_{j+1}) \cdots (y - \tau_{j+p})\). Then \(Q_{p,r}\) reproduces all polynomials of degree \(r\) and \(Q_{p,p}\) reproduces all splines in \(\mathbb{S}_{p,\tau}\).

Parameters
bthe B-spline basis of the interpolant (knots and degree)
funa function to approximate
ran integer in [0,deg] (order of maximal derivatives of the function)
[out]resulta B-spline function, that approximates the given function