DGtal  1.4.beta
DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX > Class Template Reference

#include <DGtal/math/MPolynomial.h>

Public Types

typedef TRing Ring
 
typedef TAlloc Alloc
 
typedef TX X
 
typedef MPolynomial< n, Ring, AllocMPolyN
 
typedef MPolynomial< n - 1, X, typename Alloc::template rebind< X >::other > MPolyNM1
 

Public Member Functions

 operator MPolyNM1 () const
 
template<typename XX >
MPolynomialEvaluatorImpl< n - 1, Ring, MPolynomialEvaluator< n, Ring, Alloc, X >, Alloc, XX > operator() (const XX &x) const
 

Private Member Functions

 MPolynomialEvaluator (const MPolyN &poly, const X &evalpoint)
 
template<typename XX , typename Fun >
void evaluate (XX &res, const Fun &evalfun) const
 

Private Attributes

const MPolyNmyPoly
 The polynomial in question. More...
 
const XmyEvalPoint
 the evaluation point More...
 

Friends

class MPolynomial< n, TRing, TAlloc >
 
template<int nn, class TT , class HLHL , class AA , class SS >
class MPolynomialEvaluatorImpl
 

Detailed Description

template<int n, typename TRing, typename TAlloc, typename TX>
class DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >

The top level polynomial evaluation class, in case n > 1, i.e. in case the coefficients are polynomials by themselves.

This class is a backport from Spielwiese.

Definition at line 410 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

template<int n, typename TRing , typename TAlloc , typename TX >
typedef TAlloc DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::Alloc

Definition at line 419 of file MPolynomial.h.

◆ MPolyN

template<int n, typename TRing , typename TAlloc , typename TX >
typedef MPolynomial< n, Ring, Alloc > DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::MPolyN

Definition at line 421 of file MPolynomial.h.

◆ MPolyNM1

template<int n, typename TRing , typename TAlloc , typename TX >
typedef MPolynomial< n - 1, X, typename Alloc::template rebind<X>::other > DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::MPolyNM1

Definition at line 423 of file MPolynomial.h.

◆ Ring

template<int n, typename TRing , typename TAlloc , typename TX >
typedef TRing DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::Ring

Definition at line 418 of file MPolynomial.h.

◆ X

template<int n, typename TRing , typename TAlloc , typename TX >
typedef TX DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::X

Definition at line 420 of file MPolynomial.h.

Constructor & Destructor Documentation

◆ MPolynomialEvaluator()

template<int n, typename TRing , typename TAlloc , typename TX >
DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::MPolynomialEvaluator ( const MPolyN poly,
const X evalpoint 
)
inlineprivate

Definition at line 429 of file MPolynomial.h.

430  : myPoly( poly ), myEvalPoint( evalpoint )
431  {}
const X & myEvalPoint
the evaluation point
Definition: MPolynomial.h:426
const MPolyN & myPoly
The polynomial in question.
Definition: MPolynomial.h:425

Member Function Documentation

◆ evaluate()

template<int n, typename TRing , typename TAlloc , typename TX >
template<typename XX , typename Fun >
void DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::evaluate ( XX &  res,
const Fun &  evalfun 
) const
inlineprivate

Will be called by "child". Evaluates the polynomial into an element of XX (which must not necessarily be X, it can also be MPolynomial<k, X> for some k < n - 1) using the given functor to evaluate the coefficients, which are of type MPolynomial<n-1, Ring>.

Definition at line 441 of file MPolynomial.h.

442  {
443  X xx = (X) 1;
444  for ( int i = 0; i < (int) myPoly.myValue.size(); ++i )
445  {
446  res += evalfun( myPoly.myValue[i] ) * xx;
447  xx = xx * myEvalPoint;
448  }
449  }
Size size() const
Definition: MPolynomial.h:752

References DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myEvalPoint, DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myPoly, DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().

◆ operator MPolyNM1()

template<int n, typename TRing , typename TAlloc , typename TX >
DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::operator MPolyNM1 ( ) const
inline

Evaluate to polynomial of type MPolynomial< n-1, X>.

Definition at line 456 of file MPolynomial.h.

457  {
458  MPolyNM1 res( myPoly.getAllocator() );
459  X xx = (X) 1;
460  for ( int i = 0; i < (int) myPoly.myValue.size(); ++i )
461  {
462  res += MPolyNM1( myPoly.myValue[i] ) * xx;
463  xx = xx * myEvalPoint;
464  }
465  return res;
466  }
MPolynomial< n - 1, X, typename Alloc::template rebind< X >::other > MPolyNM1
Definition: MPolynomial.h:423
Alloc getAllocator() const
Definition: MPolynomial.h:1107

References DGtal::MPolynomial< n, TRing, TAlloc >::getAllocator(), DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myEvalPoint, DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myPoly, DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::IVector< T, TAlloc, usePointers >::size().

◆ operator()()

template<int n, typename TRing , typename TAlloc , typename TX >
template<typename XX >
MPolynomialEvaluatorImpl< n - 1, Ring, MPolynomialEvaluator< n, Ring, Alloc, X >, Alloc, XX > DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::operator() ( const XX &  x) const
inline

Continue evaluation to lower level.

Definition at line 475 of file MPolynomial.h.

476  {
478  < n - 1, Ring, MPolynomialEvaluator< n, Ring, Alloc, X >, Alloc, XX >
479  ( *this, x );
480  }
friend class MPolynomialEvaluatorImpl
Definition: MPolynomial.h:415

Friends And Related Function Documentation

◆ MPolynomial< n, TRing, TAlloc >

template<int n, typename TRing , typename TAlloc , typename TX >
friend class MPolynomial< n, TRing, TAlloc >
friend

Definition at line 394 of file MPolynomial.h.

◆ MPolynomialEvaluatorImpl

template<int n, typename TRing , typename TAlloc , typename TX >
template<int nn, class TT , class HLHL , class AA , class SS >
friend class MPolynomialEvaluatorImpl
friend

Definition at line 415 of file MPolynomial.h.

Field Documentation

◆ myEvalPoint

template<int n, typename TRing , typename TAlloc , typename TX >
const X& DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myEvalPoint
private

◆ myPoly

template<int n, typename TRing , typename TAlloc , typename TX >
const MPolyN& DGtal::MPolynomialEvaluator< n, TRing, TAlloc, TX >::myPoly
private

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