Loading...
Searching...
No Matches
Dune::Functions::Polynomial< K, C > Class Template Reference
Functions » Function implementations

A univariate polynomial implementation. More...

`#include <dune/functions/analyticfunctions/polynomial.hh>`

## Public Types

using | Coefficients = C
| The type of the stored coefficient container.

## Public Member Functions

| Polynomial ()=default
| Default constructor.
| Polynomial (Coefficients coefficients)
| Create from container of coefficients.
K | operator() (const K &x) const
| Evaluate polynomial using the Horner scheme.
bool | operator== (const Polynomial &other) const
| Comparison of coefficients.
const Coefficients & | coefficients () const
| Obtain reference to coefficient vector.

## Friends

auto | derivative (const Polynomial &p)
| Obtain derivative of Polynomial function.

## Detailed Description

template<class K, class C = std::vector<K>>
class Dune::Functions::Polynomial< K, C >

A univariate polynomial implementation.

Template Parameters

  K | Scalar type. The polynomial will map K to K
  C | Coefficient container type (default std::vector<K>)

This class will store a coefficient container of type C. Supported containers are std::vector, std::array, std::integer_sequence, std::tuple. When passing std::tuple, coefficients of type std::integral_constant are promoted as std::integral_constant when computing derivatives.

Class template argument deduction is supported for passing std::array, std::vector, std::integer_sequence, std::initializer_list. When passing such containers without specifying the template parameters, then the scalar type is deduced to be the coefficient type. Notice that the deduced coefficient container type when passing std::initializer_list is std::vector.

If you want to use different types for scalar and coefficients, you can use the makePolynomial() function to explicitly specify the scalar type while the coefficient type is deduced.

This class exists mainly to demonstrate how to implement the Concept::DifferentiableFunction<Range(Domain), DerivativeTraits> concept.

## Member Typedef Documentation

## Coefficients

template<class K, class C = std::vector<K>>

using Dune::Functions::Polynomial< K, C >::Coefficients = C

The type of the stored coefficient container.

## Constructor & Destructor Documentation

## Polynomial() [1/2]

template<class K, class C = std::vector<K>>

Dune::Functions::Polynomial< K, C >::Polynomial | ( |  | ) |

default

Default constructor.

## Polynomial() [2/2]

template<class K, class C = std::vector<K>>

Dune::Functions::Polynomial< K, C >::Polynomial | ( | Coefficients | coefficients | ) |

inline

Create from container of coefficients.

Coefficients are ordered in accordance with the corresponding monomial order. The constructed Polynomial object will store a copy of the passed coefficient container.

## Member Function Documentation

## coefficients()

template<class K, class C = std::vector<K>>

const Coefficients & Dune::Functions::Polynomial< K, C >::coefficients | ( |  | ) | const

inline

Obtain reference to coefficient vector.

## operator()()

template<class K, class C = std::vector<K>>

K Dune::Functions::Polynomial< K, C >::operator() | ( | const K & | x | ) | const

inline

Evaluate polynomial using the Horner scheme.

Coefficients of type std::integral_constant<0> are eliminated at compile time.

## operator==()

template<class K, class C = std::vector<K>>

bool Dune::Functions::Polynomial< K, C >::operator== | ( | const Polynomial< K, C > & | other | ) | const

inline

Comparison of coefficients.

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

- polynomial.hh