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

dim-dimensional tensor-product monomials function. More...

#include <monomials_tp.hpp>

Inheritance diagram for qugar::impl::MonomialsTP< dim, range >:
[legend]
Collaboration diagram for qugar::impl::MonomialsTP< 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, 1 >
using CoefsType
 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

 MonomialsTP (const TensorSizeTP< dim > &order)
 Constructor.
 
 MonomialsTP (const TensorSizeTP< dim > &order, const std::vector< CoefsType > &coefs)
 Constructor.
 
 MonomialsTP (const MonomialsTP< dim, range > &monomials)
 Copy constructor.
 
std::shared_ptr< MonomialsTP< dim, range > > create_derivative (const int dir) const
 Creates a derivative of the current MonomialsTP object in the specified direction.
 
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.
 
template<int dim_aux = dim>
requires (dim == dim_aux && dim > 1)
std::shared_ptr< MonomialsTP< dim - 1, range > > extract_facet (const int local_facet_id) const
 Extracts a facet from the monomials tensor product.
 
- Public Member Functions inherited from qugar::impl::PolynomialTP< dim, 1 >
 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 > horner (const Point< dim, T > &point, typename std::vector< CoefsType >::const_iterator &coefs, const Vector< int, dim > &order)
 Evaluates a monomials using Horner's method.
 
template<typename T >
static Vector< Value< T >, dim+1 > horner_der (const Point< dim, T > &point, typename std::vector< CoefsType >::const_iterator &coefs, const Vector< int, dim > &order)
 Evaluates the gradient of the monomials using the Horner's method.
 
static void transform_coefs_to_Bezier (const MonomialsTP< dim, range > &monomials, std::vector< CoefsType > &bzr_coefs)
 Transforms the coefficients of monomials to Bezier form.
 

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.
 

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, 1 >
TensorSizeTP< dim > order_
 Order of the polynomial along each parametric direction.
 
std::vector< CoefsTypecoefs_
 

Detailed Description

template<int dim, int range = 1>
class qugar::impl::MonomialsTP< dim, range >

dim-dimensional tensor-product monomials function.

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

Member Typedef Documentation

◆ CoefsType

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

Coefs type.

◆ Gradient

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

Gradient type.

◆ Hessian

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

Hessian type.

◆ Interval

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

Algoim's interval alias.

◆ Parent

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

Parent type.

◆ Value

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

Value type.

Constructor & Destructor Documentation

◆ MonomialsTP() [1/3]

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

Constructor.

The coefficients vector is allocated by the constructor.

Parameters
orderOrder of the polynomial along each parametric direction.

◆ MonomialsTP() [2/3]

template<int dim, int range = 1>
qugar::impl::MonomialsTP< dim, range >::MonomialsTP ( 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.

◆ MonomialsTP() [3/3]

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

Copy constructor.

Parameters
monomialsMonomials to copy.

Member Function Documentation

◆ create_derivative()

template<int dim, int range = 1>
std::shared_ptr< MonomialsTP< dim, range > > qugar::impl::MonomialsTP< dim, range >::create_derivative ( const int dir) const
nodiscard

Creates a derivative of the current MonomialsTP object in the specified direction.

This function generates a new MonomialsTP object that represents the derivative of the current object in the direction specified by the parameter dir.

Parameters
dirThe direction in which to take the derivative. This should be an integer representing the axis or dimension along which the derivative is computed.
Returns
A std::shared_ptr to a new MonomialsTP object that represents the derivative of the current object in the specified direction.
Note
If the monomials has already order 1 (degree 0) in the specified direction, just a clone of the current object is returned.

◆ eval_()

template<int dim, int range = 1>
template<typename T >
Value< T > qugar::impl::MonomialsTP< 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 = 1>
template<int dim_aux = dim>
requires (dim == dim_aux && dim > 1)
std::shared_ptr< MonomialsTP< dim - 1, range > > qugar::impl::MonomialsTP< dim, range >::extract_facet ( const int local_facet_id) const
nodiscard

Extracts a facet from the monomials tensor product.

This function extracts a facet of the monomials tensor product specified by the local facet ID.

Template Parameters
dimThe dimension of the monomials tensor product.
rangeThe range type of the monomials tensor product.
Parameters
local_facet_idThe ID of the local facet to extract.
Returns
A shared pointer to the extracted facet.

◆ grad() [1/2]

template<int dim, int range = 1>
virtual Gradient< real > qugar::impl::MonomialsTP< 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 = 1>
virtual Gradient< Interval< dim > > qugar::impl::MonomialsTP< 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 = 1>
template<typename T >
Gradient< T > qugar::impl::MonomialsTP< 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 = 1>
virtual Hessian< real > qugar::impl::MonomialsTP< 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 = 1>
template<typename T >
Hessian< T > qugar::impl::MonomialsTP< 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.

◆ horner()

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

Evaluates a monomials using Horner's method.

For the method details check: https://en.wikipedia.org/wiki/Horner%27s_method

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.

◆ horner_der()

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

Evaluates the gradient of the monomials using the Horner's method.

For the method details check: https://en.wikipedia.org/wiki/Horner%27s_method

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.

◆ operator()() [1/2]

template<int dim, int range = 1>
virtual Value< real > qugar::impl::MonomialsTP< 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 = 1>
virtual Value< Interval< dim > > qugar::impl::MonomialsTP< 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 >.

◆ transform_coefs_to_Bezier()

template<int dim, int range = 1>
static void qugar::impl::MonomialsTP< dim, range >::transform_coefs_to_Bezier ( const MonomialsTP< dim, range > & monomials,
std::vector< CoefsType > & bzr_coefs )
static

Transforms the coefficients of monomials to Bezier form.

This function takes the coefficients of monomials and transforms them into the corresponding Bezier coefficients.

Parameters
monomialsMonomials whose coefficients are transformed.
bzr_coefsA vector containing the Bezier coefficients to be computed.

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