20gsMatrix<T> gsQuasiInterpolate<T>::localIntpl(
const gsBasis<T> &bb,
 
   21                                              const gsFunction<T> &fun,
 
   23                                              const gsMatrix<T> &ab)
 
   25    gsMatrix<T> bev, fev, pts, tmp;
 
   30    bb .eval_into(pts, bev);
 
   31    fun.eval_into(pts, fev);
 
   32    bev.transposeInPlace();
 
   33    fev.transposeInPlace();
 
   34    tmp = bev.partialPivLu().solve(fev);
 
   37    gsMatrix<index_t> act = bb.active(pts.col(0));
 
   38    index_t c = std::lower_bound(act.data(), act.data()+act.size(), i) - act.data();
 
   39    GISMO_ASSERT(c<act.size(), 
"Problem with basis function index");
 
   74gsMatrix<T> gsQuasiInterpolate<T>::localIntpl(
const gsHTensorBasis<d,T> &bb,
 
   75                                              const gsFunction<T> &fun,
 
   79    index_t j = bb.flatTensorIndexOf(i);
 
   80    return localIntpl(bb.tensorLevel(lvl),fun,j, bb.elementInSupportOf(i)); 
 
   85gsMatrix<T> gsQuasiInterpolate<T>::localIntpl(
const gsBasis<T> &bb,
 
   86                                              const gsFunction<T> &fun,
 
   89    if (
const gsHTensorBasis<1,T>* b = 
dynamic_cast<const gsHTensorBasis<1,T>* 
>(&bb))
 
   90        return localIntpl(*b,fun,i);
 
   91    if (
const gsHTensorBasis<2,T>* b = 
dynamic_cast<const gsHTensorBasis<2,T>* 
>(&bb))
 
   92         return localIntpl(*b,fun,i);
 
   93    if (
const gsHTensorBasis<3,T>* b = 
dynamic_cast<const gsHTensorBasis<3,T>* 
>(&bb))
 
   94        return localIntpl(*b,fun,i);
 
   95    if (
const gsHTensorBasis<4,T>* b = 
dynamic_cast<const gsHTensorBasis<4,T>* 
>(&bb))
 
   96        return localIntpl(*b,fun,i);
 
   98        return localIntpl(bb,fun,i,bb.elementInSupportOf(i));
 
  116    std::vector<gsMatrix<T> > derivs;
 
  121    std::vector<T> knots;
 
  122    for(
int j=0; j<n; j++)
 
  126        for(
int i=j+1; i<=j+deg; i++)
 
  127            knots.push_back(kv[i]);
 
  129        for(
int k=0; k<=r; k++) 
 
  131            const T factor1 = derivProd(knots, deg-k, xj(j)); 
 
  132            for(
int i=0; i<dim; i++)
 
  134                const T factor2 = derivs[k](i,j); 
 
  135                val(i) += std::pow(-1.0,k) * factor1 * factor2;
 
 
  150    res.transposeInPlace();
 
  162    const int n = b.
size();
 
  168    for(
unsigned int i=0; i<kv.
size(); i++)
 
  178                      "quasiInterpolateEvalBased is implemented for special cases of deg 1, 2 or 3!");
 
  186        for(
int i=0; i<n; i++)
 
  187            coefs.row(i) = TmpCoefs.col(i+1).transpose();
 
  194        for(
unsigned int i=0; i<kv.
size()-1; i++)
 
  195            knotsAvg(i) = (kv[i]+kv[i+1]) / (T)(2);
 
  199        coefs.row(0) = TmpCoefs.col(0);
 
  200        for(
int i=1; i<n-1; i++)
 
  203            coefs.row(i).noalias() =
 
  204                ( - TmpCoefs.col(i+1)
 
  205                  + 4 * TmpCoefsAvg.col(i+1)
 
  206                  - TmpCoefs.col(i+2) ) / (T)(2);
 
  208        coefs.row(n-1) = TmpCoefs.col(n);
 
  215        for(
unsigned int i=0; i<kv.
size()-1; i++)
 
  216            knotsAvg(i) = (kv[i]+kv[i+1]) / (T)(2);
 
  220        coefs.row(0) = TmpCoefs.col(3).transpose();
 
  223        coefs.row(1).noalias() =
 
  224                ( -  5 * TmpCoefs.col(3)
 
  225                  + 40 * TmpCoefsAvg.col(3)
 
  226                  - 24 * TmpCoefs.col(4)
 
  227                  +  8 * TmpCoefsAvg.col(4)
 
  228                  - TmpCoefs.col(5) ) / (T)(18);
 
  230        for(
int i=2; i<n-2; i++)
 
  233            coefs.row(i).noalias() =
 
  235                      -  8 * TmpCoefsAvg.col(i+1)
 
  236                      + 20 * TmpCoefs.col(i+2)
 
  237                      -  8 * TmpCoefsAvg.col(i+2)
 
  238                      + TmpCoefs.col(i+3) ) / (T)(6);
 
  242        coefs.row(n-2).noalias() =
 
  243                ( - TmpCoefs.col(n-2)
 
  244                  +  8 * TmpCoefsAvg.col(n-2)
 
  245                  - 24 * TmpCoefs.col(n-1)
 
  246                  + 40 * TmpCoefsAvg.col(n-1)
 
  247                  -  5 * TmpCoefs.col(n) ) / (T)(18);
 
  249        coefs.row(n-1) = TmpCoefs.col(n);
 
  255        for(
int i=0; i<n; i++)
 
  258            int gsi = greatestSubInterval(kv, i, i+kv.
degree());
 
  265            computeWeights(xik, kv, i+1, weights);
 
  268            coefs.row(i) = computeControlPoints(weights, fun, xik);
 
 
  281    std::vector<T> tmpZeros;
 
  285        const index_t n1 = zeros.size() - 1;
 
  288        for(
typename std::vector<T>::iterator it = tmpZeros.begin(); it!=tmpZeros.end(); ++it)
 
  290            std::iter_swap(it, tmpZeros.end()-1);
 
  292            std::iter_swap(it, tmpZeros.end()-1);
 
  298    const int n = zeros.size();
 
  300    for(
int i=0; i!=n; i++)
 
  303        tmpZeros.erase(tmpZeros.begin() + i);
 
  304        val += derivProd(tmpZeros, order-1, x);
 
 
  314    for(
int k=0; k<n; k++)
 
  315        points.
at(k) = a + (T)k/(T)(n-1) * (b-a);
 
 
  322    const int deg = knots.
degree();
 
  323    weights.resize(1,deg+1);
 
  327    for(
int k=0; k<deg+1; k++)
 
  333        for(
int i=0; i<k; i++)
 
  335            pointsReduced(i) = points(i);
 
  336            constant *= points(k) - points(i);
 
  338        for(
int i=k+1; i<deg+1; i++)
 
  340            pointsReduced(i-1) = points(i);
 
  341            constant *= points(k) - points(i);
 
  345        for(
int i=0; i<deg; i++)
 
  353            for(
int i=0; i<deg; i++)
 
  355                factor *= (knots[pos+indices[i]] - pointsReduced(i));
 
  359        while(std::next_permutation(indices.data(), indices.data()+deg));
 
  361        weights(k) = sum / constant;
 
 
  371    return (weights.asDiagonal() * funValues.transpose()).colwise().sum();
 
 
  378    const int diff = posEnd-posStart;
 
  380    int maxInd = posStart;
 
  381    for(
int i=1; i<diff+1; i++)
 
  383        const T dist = knots[posStart+i+1] - knots[posStart+i];
 
 
  404    result.resize(n,dim);
 
  408        cf = localIntpl(b,fun,i);
 
  422    result.resize(n,dim);
 
  426        cf = Schoenberg(b,fun,i);
 
 
Creates a mapped object or data pointer to a const matrix without copying data.
Definition gsAsMatrix.h:141
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
gsMatrix< T > anchors() const
Returns the anchor points that represent the members of the basis. There is exactly one anchor point ...
Definition gsBasis.h:437
virtual short_t domainDim() const =0
Dimension of the (source) domain.
virtual index_t size() const
size
Definition gsFunctionSet.h:613
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero functions and their derivatives up to order n at points u into result.
Definition gsFunctionSet.hpp:81
A function  from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual short_t domainDim() const=0
Dimension of the (source) domain.
virtual short_t targetDim() const
Dimension of the target space.
Definition gsFunctionSet.h:595
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const =0
Evaluate the function at points u into result.
Class for representing a knot vector.
Definition gsKnotVector.h:80
size_t size() const
Number of knots (including repetitions).
Definition gsKnotVector.h:242
int degree() const
Returns the degree of the knot vector.
Definition gsKnotVector.hpp:700
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition gsMatrix.h:211
const KnotVectorType & knots(int i=0) const
Returns the knot vector of the basis.
Definition gsBSplineBasis.h:371
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition gsBSplineBasis.h:324
index_t size() const
Returns the number of elements in the basis.
Definition gsBSplineBasis.h:165
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
unsigned factorial(unsigned n)
Returns the factorial of n i.e. n! Remember that factorial grow too fast and only n!...
Definition gsCombinatorics.h:29
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.
gsVector< unsigned > distributePoints(const gsGeometry< T > &geo, unsigned numPoints)
distributes sampling points according to the length of the patch in each parametric direction
Definition gsGeoUtils.hpp:536
@ GaussLegendre
Gauss-Legendre quadrature.
Definition gsQuadrature.h:37
static gsVector< index_t > numNodes(const gsBasis< T > &basis, const Real quA, const index_t quB, short_t fixDir=-1)
Definition gsQuadrature.h:155
Quasi-interpolation operators.
Definition gsQuasiInterpolate.h:37
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....
Definition gsQuasiInterpolate.hpp:156
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 ...
Definition gsQuasiInterpolate.hpp:367
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....
Definition gsQuasiInterpolate.hpp:414
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) defin...
Definition gsQuasiInterpolate.hpp:276
static void distributePoints(T a, T b, int n, gsMatrix< T > &points)
Compute a number of equally distributed points in a given interval . You get a list of points .
Definition gsQuasiInterpolate.hpp:311
static void computeWeights(const gsMatrix< T > &points, const gsKnotVector< T > &knots, const int &pos, gsMatrix< T > &weights)
To compute the control points  of the quasi-interpolant one uses the function computeControlPoints....
Definition gsQuasiInterpolate.hpp:320
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....
Definition gsQuasiInterpolate.hpp:103
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.
Definition gsQuasiInterpolate.hpp:376