QUGaR 0.0.4
Loading...
Searching...
No Matches
qugar::impl::BezierTP< dim, range > Class Template Reference

dim-dimensional tensor-product Bezier polynomial function. More...

#include <bezier_tp.hpp>

Inheritance diagram for qugar::impl::BezierTP< dim, range >:
[legend]
Collaboration diagram for qugar::impl::BezierTP< dim, range >:
[legend]

Public Types

using Parent = PolynomialTP<dim, range>
 Parent type.
 
using CoefsType = typename Parent::CoefsType
 Coefs type.
 
template<typename T >
using Value = typename Parent::template Value<T>
 Value type.
 
template<typename T >
using Gradient = typename Parent::template Gradient<T>
 Gradient type.
 
template<typename T >
using Hessian = typename Parent::template Hessian<T>
 Hessian type.
 
template<int N>
using Interval = ::algoim::Interval<N>
 Algoim's interval alias.
 
- Public Types inherited from qugar::impl::PolynomialTP< dim, range >
using CoefsType = std::conditional_t<range == 1, real, Point<range>>
 Coefs type.
 
- Public Types inherited from qugar::impl::DomainFunc< dim, range >
template<int N>
using Interval = ::algoim::Interval<N>
 Algoim's interval alias.
 
template<typename T >
using Value = std::conditional_t<range == 1, T, Vector<T, range>>
 Value type.
 
template<typename T >
using Gradient = Vector<Value<T>, dim>
 Gradient type.
 
template<typename T >
using Hessian = Vector<Value<T>, num_hessian>
 Hessian (symmetric type).
 

Public Member Functions

 BezierTP (const TensorSizeTP< dim > &order)
 Constructor.
 
 BezierTP (const TensorSizeTP< dim > &order, const CoefsType &value)
 Constructs a constant value Bezier tensor product.
 
 BezierTP (const TensorSizeTP< dim > &order, const std::vector< CoefsType > &coefs)
 Constructor.
 
 BezierTP (const BezierTP< dim, range > &bezier)
 Copy constructor.
 
 BezierTP (const MonomialsTP< dim, range > &monomials)
 Constructor.
 
virtual Value< realoperator() (const Point< dim > &point) const final
 Evaluator operator.
 
virtual Value< Interval< dim > > operator() (const Point< dim, Interval< dim > > &point) const final
 Evaluator operator.
 
virtual Gradient< realgrad (const Point< dim > &point) const final
 Gradient evaluator operator.
 
virtual Gradient< Interval< dim > > grad (const Point< dim, Interval< dim > > &point) const final
 Gradient evaluator operator.
 
virtual Hessian< realhessian (const Point< dim > &point) const final
 Hessian evaluator operator.
 
const ::algoim::xarray< CoefsType, dim > & get_xarray () const
 Gets a constant reference to the stored xarray view of the polynomial coefficients.
 
template<int dim_aux = dim>
requires (dim == dim_aux && dim > 1)
std::shared_ptr< BezierTP< dim - 1, range > > extract_facet (const int local_facet_id) const
 
std::shared_ptr< BezierTP< dim, range > > raise_order (const TensorSizeTP< dim > &new_order) const
 Raises the order of the Bezier tensor product.
 
std::shared_ptr< BezierTP< dim, range > > negate () const
 Creates a new Bezier tensor product (TP) object that is the negation of the current object.
 
template<int range_aux = range>
requires (range_aux == range && range == 1)
void rescale_domain (const BoundBox< dim > &new_domain)
 Recomputes (in-place) the Bezier coefficients for a new domain (that may not be [0, 1]).
 
template<int range_aux = range>
requires (range_aux == range && range == 1)
FuncSign sign () const
 Returns the sign of the function represented by the Bézier tensor-product using the properties of the control points convex hull.
 
std::shared_ptr< BezierTP< dim, range > > operator* (const BezierTP< dim, range > &rhs) const
 Product of two Beziers.
 
std::shared_ptr< BezierTP< dim, range > > operator+ (const BezierTP< dim, range > &rhs) const
 Addition of two Beziers.
 
std::shared_ptr< BezierTP< dim, range > > operator- (const BezierTP< dim, range > &rhs) const
 Subtraction of two Beziers.
 
template<int sub_dim>
std::shared_ptr< BezierTP< sub_dim, range > > compose (const BezierTP< sub_dim, dim > &rhs) const
 Composes the current Bezier with the given Bezier rhs.
 
- Public Member Functions inherited from qugar::impl::PolynomialTP< dim, range >
 PolynomialTP (const TensorSizeTP< dim > &order)
 Constructor.
 
 PolynomialTP (const TensorSizeTP< dim > &order, const CoefsType &value)
 Constructs a constant value PolynomialTP object with the specified order.
 
 PolynomialTP (const TensorSizeTP< dim > &order, const std::vector< CoefsType > &coefs)
 Constructor.
 
std::size_t get_num_coefs () const
 Get the number of coeficients.
 
const std::vector< CoefsType > & get_coefs () const
 Gets the polynomial coefficients.
 
const TensorSizeTP< dim > & get_order () const
 Gets the polynomial order along the parametric directions.
 
int get_order (int dir) const
 Gets the polynomial order (degree + 1) along the direction dir.
 
const CoefsTypeget_coef (int index) const
 Retrieves the coefficients at the specified index.
 
CoefsTypeget_coef (int index)
 Retrieves the coefficients at the specified index.
 
const CoefsTypeget_coef (const TensorIndexTP< dim > &index) const
 Retrieves the coefficient associated with the given tensor index.
 
CoefsTypeget_coef (const TensorIndexTP< dim > &index)
 Retrieves the coefficient associated with the given tensor index.
 
int get_degree (int dir) const
 Gets the polynomial degree (order - 1) along the direction dir.
 
void transform_image (const BoundBox< range > &old_domain, const BoundBox< range > &new_domain)
 Transforms (in place) the coefficients of the polynomial from old_domain to new_domain.
 
void coefs_linear_transform (const real scale, const CoefsType &shift)
 Applies a linear transformation to every coefficient.
 
- Public Member Functions inherited from qugar::impl::DomainFunc< dim, range >
 DomainFunc ()=default
 Default constructor.
 
 DomainFunc (const DomainFunc &)=default
 Default copy constructor.
 
 DomainFunc (DomainFunc &&)=default
 Default move constructor.
 
DomainFuncoperator= (const DomainFunc &)=default
 Default copy assignment operator.
 
DomainFuncoperator= (DomainFunc &&)=default
 Default move assignment operator.
 
virtual ~DomainFunc ()=default
 Default virtual destructor.
 

Static Public Member Functions

template<typename T >
static Value< T > casteljau (const Point< dim, T > &point, typename std::vector< CoefsType >::const_iterator &coefs, const Vector< int, dim > &order)
 Evaluates a Bezier polynomial using the Casteljau's algorithm.
 
template<typename T >
static Vector< Value< T >, dim+1 > casteljau_der (const Point< dim, T > &point, typename std::vector< CoefsType >::const_iterator &coefs, const Vector< int, dim > &order)
 Evaluates the gradient Bezier polynomial using the Casteljau's algorithm.
 

Private Member Functions

template<typename T >
Value< T > eval_ (const Point< dim, T > &point) const
 Evaluator operator.
 
template<typename T >
Gradient< T > grad_ (const Point< dim, T > &point) const
 Gradient evaluator operator.
 
template<typename T >
Hessian< T > hessian_ (const Point< dim, T > &point) const
 Hessian evaluator operator.
 

Private Attributes

::algoim::xarray< CoefsType, dim > coefs_xarray_
 dim-dimensional array view of the coefficients.
 

Additional Inherited Members

- Static Public Attributes inherited from qugar::impl::DomainFunc< dim, range >
static const int num_hessian = dim * (dim + 1) / 2
 Number of Hessian (symmetric) components.
 
- Protected Attributes inherited from qugar::impl::PolynomialTP< dim, range >
TensorSizeTP< dim > order_
 Order of the polynomial along each parametric direction.
 
std::vector< CoefsTypecoefs_
 

Detailed Description

template<int dim, int range>
class qugar::impl::BezierTP< dim, range >

dim-dimensional tensor-product Bezier polynomial function.

Template Parameters
dimDimension of the parametric domain.
rangeDimension of the image.

Member Typedef Documentation

◆ CoefsType

template<int dim, int range>
using qugar::impl::BezierTP< dim, range >::CoefsType = typename Parent::CoefsType

Coefs type.

◆ Gradient

template<int dim, int range>
template<typename T >
using qugar::impl::BezierTP< dim, range >::Gradient = typename Parent::template Gradient<T>

Gradient type.

◆ Hessian

template<int dim, int range>
template<typename T >
using qugar::impl::BezierTP< dim, range >::Hessian = typename Parent::template Hessian<T>

Hessian type.

◆ Interval

template<int dim, int range>
template<int N>
using qugar::impl::BezierTP< dim, range >::Interval = ::algoim::Interval<N>

Algoim's interval alias.

◆ Parent

template<int dim, int range>
using qugar::impl::BezierTP< dim, range >::Parent = PolynomialTP<dim, range>

Parent type.

◆ Value

template<int dim, int range>
template<typename T >
using qugar::impl::BezierTP< dim, range >::Value = typename Parent::template Value<T>

Value type.

Constructor & Destructor Documentation

◆ BezierTP() [1/5]

template<int dim, int range>
qugar::impl::BezierTP< dim, range >::BezierTP ( const TensorSizeTP< dim > & order)
explicit

Constructor.

The coefficients vector is allocated by the constructor.

Parameters
orderOrder of the polynomial along each parametric direction.

◆ BezierTP() [2/5]

template<int dim, int range>
qugar::impl::BezierTP< dim, range >::BezierTP ( const TensorSizeTP< dim > & order,
const CoefsType & value )

Constructs a constant value Bezier tensor product.

Parameters
orderOrder of the polynomial along each parametric direction.
valueThe value to set for all the coefficients.

◆ BezierTP() [3/5]

template<int dim, int range>
qugar::impl::BezierTP< dim, range >::BezierTP ( const TensorSizeTP< dim > & order,
const std::vector< CoefsType > & coefs )

Constructor.

Parameters
coefsCoefficients of the polynomial. The ordering is such that dimension 0 is inner-most, i.e., iterates the fastest, while dimension dim-1 is outer-most and iterates the slowest.
orderOrder of the polynomial along each parametric direction.

◆ BezierTP() [4/5]

template<int dim, int range>
qugar::impl::BezierTP< dim, range >::BezierTP ( const BezierTP< dim, range > & bezier)

Copy constructor.

Parameters
bezierBezier to copy.

◆ BezierTP() [5/5]

template<int dim, int range>
qugar::impl::BezierTP< dim, range >::BezierTP ( const MonomialsTP< dim, range > & monomials)
explicit

Constructor.

Constructs from monomials.

Parameters
monomialsMonomials from which the Bezier is created.

Member Function Documentation

◆ casteljau()

template<int dim, int range>
template<typename T >
static Value< T > qugar::impl::BezierTP< dim, range >::casteljau ( const Point< dim, T > & point,
typename std::vector< CoefsType >::const_iterator & coefs,
const Vector< int, dim > & order )
static

Evaluates a Bezier polynomial using the Casteljau's algorithm.

For the algorithm details check: https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm

The evaluation along the dimensions is performed by recursively calling this function.

Template Parameters
TType of the input and output variables.
Parameters
pointEvaluation point.
coefsIterator to the coefficients of the polynomial. Their ordering is the same as the coefficients members of the class.
orderOrder of the polynomial along the dim dimensions.
Returns
Value of the polynomial at point.

◆ casteljau_der()

template<int dim, int range>
template<typename T >
static Vector< Value< T >, dim+1 > qugar::impl::BezierTP< dim, range >::casteljau_der ( const Point< dim, T > & point,
typename std::vector< CoefsType >::const_iterator & coefs,
const Vector< int, dim > & order )
static

Evaluates the gradient Bezier polynomial using the Casteljau's algorithm.

For the algorithm details check: https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm

The evaluation along the dimensions is performed by recursively calling this function.

Template Parameters
TType of the input and output variables.
Parameters
pointEvaluation point.
coefsIterator to the coefficients of the polynomial. Their ordering is the same as the coefficients members of the class.
orderOrder of the polynomial along the dim dimensions.
Returns
The first component of the return vector corresponds to the value of the polynomial itself, while the gradient is stored in the following dim components.

◆ compose()

template<int dim, int range>
template<int sub_dim>
std::shared_ptr< BezierTP< sub_dim, range > > qugar::impl::BezierTP< dim, range >::compose ( const BezierTP< sub_dim, dim > & rhs) const
nodiscard

Composes the current Bezier with the given Bezier rhs.

Template Parameters
sub_dimSubdimension of the right-hand-size Bezier.
Parameters
rhsRight-hand-side Bezier for the composition.
Returns
Generated Bezier composition.

◆ eval_()

template<int dim, int range>
template<typename T >
Value< T > qugar::impl::BezierTP< dim, range >::eval_ ( const Point< dim, T > & point) const
nodiscardprivate

Evaluator operator.

Template Parameters
TInput and output's type.
Parameters
pointPoint at which the function is evaluated.
Returns
Function value at point.

◆ extract_facet()

template<int dim, int range>
template<int dim_aux = dim>
requires (dim == dim_aux && dim > 1)
std::shared_ptr< BezierTP< dim - 1, range > > qugar::impl::BezierTP< dim, range >::extract_facet ( const int local_facet_id) const
nodiscard

◆ get_xarray()

template<int dim, int range>
const ::algoim::xarray< CoefsType, dim > & qugar::impl::BezierTP< dim, range >::get_xarray ( ) const
nodiscard

Gets a constant reference to the stored xarray view of the polynomial coefficients.

Returns
Constant view of the polynomial coefficients.

◆ grad() [1/2]

template<int dim, int range>
virtual Gradient< real > qugar::impl::BezierTP< dim, range >::grad ( const Point< dim > & point) const
nodiscardfinalvirtual

Gradient evaluator operator.

Parameters
pointPoint at which the function's gradient is evaluated.
Returns
Function gradient at point.

Implements qugar::impl::DomainFunc< dim, range >.

◆ grad() [2/2]

template<int dim, int range>
virtual Gradient< Interval< dim > > qugar::impl::BezierTP< dim, range >::grad ( const Point< dim, Interval< dim > > & point) const
nodiscardfinalvirtual

Gradient evaluator operator.

Parameters
pointPoint at which the function's gradient is evaluated.
Returns
Function gradient at point.

Implements qugar::impl::DomainFunc< dim, range >.

◆ grad_()

template<int dim, int range>
template<typename T >
Gradient< T > qugar::impl::BezierTP< dim, range >::grad_ ( const Point< dim, T > & point) const
nodiscardprivate

Gradient evaluator operator.

Template Parameters
TInput and output's type.
Parameters
pointPoint at which the function's gradient is evaluated.
Returns
Function gradient at point.

◆ hessian()

template<int dim, int range>
virtual Hessian< real > qugar::impl::BezierTP< dim, range >::hessian ( const Point< dim > & point) const
nodiscardfinalvirtual

Hessian evaluator operator.

Parameters
pointPoint at which the function's hessian is evaluated.
Returns
Function hessian at point.

Implements qugar::impl::DomainFunc< dim, range >.

◆ hessian_()

template<int dim, int range>
template<typename T >
Hessian< T > qugar::impl::BezierTP< dim, range >::hessian_ ( const Point< dim, T > & point) const
nodiscardprivate

Hessian evaluator operator.

Template Parameters
TInput and output's type.
Parameters
pointPoint at which the function's hessian is evaluated.
Returns
Function hessian at point.

◆ negate()

template<int dim, int range>
std::shared_ptr< BezierTP< dim, range > > qugar::impl::BezierTP< dim, range >::negate ( ) const
nodiscard

Creates a new Bezier tensor product (TP) object that is the negation of the current object.

This function returns a shared pointer to a new BezierTP object where each control point has the same value but with negative sign.

Returns
A shared pointer to the negated BezierTP object.

◆ operator()() [1/2]

template<int dim, int range>
virtual Value< real > qugar::impl::BezierTP< dim, range >::operator() ( const Point< dim > & point) const
nodiscardfinalvirtual

Evaluator operator.

Parameters
pointPoint at which the function is evaluated.
Returns
Function value at point.

Implements qugar::impl::DomainFunc< dim, range >.

◆ operator()() [2/2]

template<int dim, int range>
virtual Value< Interval< dim > > qugar::impl::BezierTP< dim, range >::operator() ( const Point< dim, Interval< dim > > & point) const
nodiscardfinalvirtual

Evaluator operator.

Parameters
pointPoint at which the function is evaluated.
Returns
Function value at point.

Implements qugar::impl::DomainFunc< dim, range >.

◆ operator*()

template<int dim, int range>
std::shared_ptr< BezierTP< dim, range > > qugar::impl::BezierTP< dim, range >::operator* ( const BezierTP< dim, range > & rhs) const
nodiscard

Product of two Beziers.

Parameters
rhsSecond Bezier to multiply.
Returns
Product of Beziers.

◆ operator+()

template<int dim, int range>
std::shared_ptr< BezierTP< dim, range > > qugar::impl::BezierTP< dim, range >::operator+ ( const BezierTP< dim, range > & rhs) const
nodiscard

Addition of two Beziers.

Parameters
rhsSecond Bezier to sum.
Returns
Sum of Beziers. The resulting Bezier has the maximum order of the two Beziers along each dimension.

◆ operator-()

template<int dim, int range>
std::shared_ptr< BezierTP< dim, range > > qugar::impl::BezierTP< dim, range >::operator- ( const BezierTP< dim, range > & rhs) const
nodiscard

Subtraction of two Beziers.

Parameters
rhsBezier to subtract.
Returns
Subtraction of Beziers. The resulting Bezier has the maximum order of the two Beziers along each dimension.

◆ raise_order()

template<int dim, int range>
std::shared_ptr< BezierTP< dim, range > > qugar::impl::BezierTP< dim, range >::raise_order ( const TensorSizeTP< dim > & new_order) const
nodiscard

Raises the order of the Bezier tensor product.

This function creates a new Bezier tensor product with an increased order as specified by the new_order parameter. The new Bezier will represent the same polynomial function as the original, but with a higher order.

Parameters
new_orderThe new order for each dimension of the tensor product. Along each dimension, the new order must be greater or equal than the current order.
Returns
A shared pointer to the new Bezier tensor product with the raised order.

◆ rescale_domain()

template<int dim, int range>
template<int range_aux = range>
requires (range_aux == range && range == 1)
void qugar::impl::BezierTP< dim, range >::rescale_domain ( const BoundBox< dim > & new_domain)

Recomputes (in-place) the Bezier coefficients for a new domain (that may not be [0, 1]).

Parameters
new_domainNew domain for which the coefficientes are computed.

◆ sign()

template<int dim, int range>
template<int range_aux = range>
requires (range_aux == range && range == 1)
FuncSign qugar::impl::BezierTP< dim, range >::sign ( ) const
nodiscard

Returns the sign of the function represented by the Bézier tensor-product using the properties of the control points convex hull.

Returns
FuncSign The sign of the function.

Member Data Documentation

◆ coefs_xarray_

template<int dim, int range>
::algoim::xarray<CoefsType, dim> qugar::impl::BezierTP< dim, range >::coefs_xarray_
private

dim-dimensional array view of the coefficients.


The documentation for this class was generated from the following files: