DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Private Member Functions
DGtal::EhrhartPolynomial< TSpace, TInteger > Class Template Reference

Aim: This class implements the class Ehrhart Polynomial which is related to lattice point enumeration in bounded lattice polytopes. More...

#include <DGtal/geometry/volumes/EhrhartPolynomial.h>

Public Types

typedef EhrhartPolynomial< TSpace, TInteger > Self
 
typedef TSpace Space
 
typedef TInteger Integer
 
typedef BoundedLatticePolytope< SpaceLatticePolytope
 
typedef LagrangeInterpolation< IntegerLagrange
 
typedef Lagrange::Polynomial Polynomial
 
typedef std::size_t Size
 

Public Member Functions

 ~EhrhartPolynomial ()=default
 
 EhrhartPolynomial ()
 
 EhrhartPolynomial (const LatticePolytope &polytope)
 
 EhrhartPolynomial (const EhrhartPolynomial &other)=default
 
 EhrhartPolynomial (EhrhartPolynomial &&other)=default
 
EhrhartPolynomialoperator= (const EhrhartPolynomial &other)=default
 
EhrhartPolynomialoperator= (EhrhartPolynomial &&other)=default
 
Polynomial numerator () const
 
Integer denominator () const
 The (integral) denominator of the Ehrhart polynomial. More...
 
void init (const LatticePolytope &polytope)
 
Integer count (Integer t) const
 
Integer remainder (Integer t) const
 
Integer countInterior (Integer t) const
 
Integer remainderInterior (Integer t) const
 
void selfDisplay (std::ostream &that_stream) const
 
bool OK () const
 

Protected Attributes

Polynomial myE
 The Ehrhart polynomial (integral numerator part) More...
 
Integer myD
 The (integral) denominator of the Ehrhart polynomial. More...
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< TInteger >))
 

Detailed Description

template<typename TSpace, typename TInteger>
class DGtal::EhrhartPolynomial< TSpace, TInteger >

Aim: This class implements the class Ehrhart Polynomial which is related to lattice point enumeration in bounded lattice polytopes.

Description of class 'EhrhartPolynomial'

See also
testEhrhartPolynomial.cpp
Template Parameters
TSpacean arbitrary model of CSpace, which tells in which space live bounded lattice polytopes.
TIntegeran arbitrary model of CInteger, which must be precise enough to compute the Ehrhart polynomial (either int64_t or BigInteger).

Definition at line 66 of file EhrhartPolynomial.h.

Member Typedef Documentation

◆ Integer

template<typename TSpace , typename TInteger >
typedef TInteger DGtal::EhrhartPolynomial< TSpace, TInteger >::Integer

Definition at line 75 of file EhrhartPolynomial.h.

◆ Lagrange

template<typename TSpace , typename TInteger >
typedef LagrangeInterpolation< Integer > DGtal::EhrhartPolynomial< TSpace, TInteger >::Lagrange

Definition at line 77 of file EhrhartPolynomial.h.

◆ LatticePolytope

template<typename TSpace , typename TInteger >
typedef BoundedLatticePolytope<Space> DGtal::EhrhartPolynomial< TSpace, TInteger >::LatticePolytope

Definition at line 76 of file EhrhartPolynomial.h.

◆ Polynomial

template<typename TSpace , typename TInteger >
typedef Lagrange::Polynomial DGtal::EhrhartPolynomial< TSpace, TInteger >::Polynomial

Definition at line 78 of file EhrhartPolynomial.h.

◆ Self

template<typename TSpace , typename TInteger >
typedef EhrhartPolynomial< TSpace, TInteger > DGtal::EhrhartPolynomial< TSpace, TInteger >::Self

Definition at line 73 of file EhrhartPolynomial.h.

◆ Size

template<typename TSpace , typename TInteger >
typedef std::size_t DGtal::EhrhartPolynomial< TSpace, TInteger >::Size

Definition at line 79 of file EhrhartPolynomial.h.

◆ Space

template<typename TSpace , typename TInteger >
typedef TSpace DGtal::EhrhartPolynomial< TSpace, TInteger >::Space

Definition at line 74 of file EhrhartPolynomial.h.

Constructor & Destructor Documentation

◆ ~EhrhartPolynomial()

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::~EhrhartPolynomial ( )
default

Destructor.

◆ EhrhartPolynomial() [1/4]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::EhrhartPolynomial ( )
inline

Constructor. The object is invalid.

Definition at line 92 of file EhrhartPolynomial.h.

93 : myE(), myD( NumberTraits< Integer >::ZERO )
94 {}
Integer myD
The (integral) denominator of the Ehrhart polynomial.
Polynomial myE
The Ehrhart polynomial (integral numerator part)

◆ EhrhartPolynomial() [2/4]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::EhrhartPolynomial ( const LatticePolytope polytope)
inline

Constructs the Ehrhart polynomial from a lattice polytope

Parameters
polytopethe lattice polytope

Definition at line 99 of file EhrhartPolynomial.h.

100 {
101 init( polytope );
102 }
void init(const LatticePolytope &polytope)

References DGtal::EhrhartPolynomial< TSpace, TInteger >::init().

◆ EhrhartPolynomial() [3/4]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::EhrhartPolynomial ( const EhrhartPolynomial< TSpace, TInteger > &  other)
default

Copy constructor.

Parameters
otherthe object to clone.

◆ EhrhartPolynomial() [4/4]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::EhrhartPolynomial ( EhrhartPolynomial< TSpace, TInteger > &&  other)
default

Move constructor.

Parameters
otherthe object to clone.

Member Function Documentation

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< TInteger >)  )
private

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TSpace , typename TInteger >
DGtal::EhrhartPolynomial< TSpace, TInteger >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >)  )
private

◆ count()

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::count ( Integer  t) const
inline

◆ countInterior()

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::countInterior ( Integer  t) const
inline

Definition at line 181 of file EhrhartPolynomial.h.

181 {
182 return myE.degree() % 2 == 0
183 ? ( myE( -t ) / myD )
184 : - ( myE( -t ) / myD );
185 }
int degree() const
Definition: MPolynomial.h:1109

References DGtal::MPolynomial< n, TRing, TAlloc >::degree(), DGtal::EhrhartPolynomial< TSpace, TInteger >::myD, and DGtal::EhrhartPolynomial< TSpace, TInteger >::myE.

◆ denominator()

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::denominator ( ) const
inline

The (integral) denominator of the Ehrhart polynomial.

Definition at line 137 of file EhrhartPolynomial.h.

138 {
139 return myD;
140 }

References DGtal::EhrhartPolynomial< TSpace, TInteger >::myD.

Referenced by DGtal::EhrhartPolynomial< TSpace, TInteger >::selfDisplay().

◆ init()

template<typename TSpace , typename TInteger >
void DGtal::EhrhartPolynomial< TSpace, TInteger >::init ( const LatticePolytope polytope)
inline

Initializes the Ehrhart polynomial with a lattice polytope.

Parameters
polytopethe lattice polytope

Definition at line 145 of file EhrhartPolynomial.h.

146 {
147 std::vector< Integer > X( Space::dimension + 1 );
148 std::vector< Integer > Y( Space::dimension + 1 );
151 for ( Integer i = 1; i <= Space::dimension; ++i )
152 {
153 LatticePolytope Q = i * polytope;
154 Integer nb = Q.count();
155 X[ i ] = i;
156 Y[ i ] = nb;
157 }
158 // Compute polynomial (degree d)
159 Lagrange L( X );
160 myE = L.polynomial( Y );
161 myD = L.denominator();
162 }
BoundedLatticePolytope< Space > LatticePolytope
LagrangeInterpolation< Integer > Lagrange
static const Dimension dimension
static constants to store the dimension.
Definition: SpaceND.h:132
static const T ONE
Constant One.
Definition: NumberTraits.h:103
static const T ZERO
Constant Zero.
Definition: NumberTraits.h:100

References DGtal::BoundedLatticePolytope< TSpace >::count(), DGtal::LagrangeInterpolation< TEuclideanRing >::denominator(), DGtal::SpaceND< dim, TInteger >::dimension, DGtal::EhrhartPolynomial< TSpace, TInteger >::myD, DGtal::EhrhartPolynomial< TSpace, TInteger >::myE, and DGtal::LagrangeInterpolation< TEuclideanRing >::polynomial().

Referenced by DGtal::EhrhartPolynomial< TSpace, TInteger >::EhrhartPolynomial().

◆ numerator()

template<typename TSpace , typename TInteger >
Polynomial DGtal::EhrhartPolynomial< TSpace, TInteger >::numerator ( ) const
inline
Returns
the Ehrhart polynomial (integral numerator part)

Definition at line 131 of file EhrhartPolynomial.h.

132 {
133 return myE;
134 }

References DGtal::EhrhartPolynomial< TSpace, TInteger >::myE.

Referenced by DGtal::EhrhartPolynomial< TSpace, TInteger >::selfDisplay().

◆ OK()

template<typename TSpace , typename TInteger >
bool DGtal::EhrhartPolynomial< TSpace, TInteger >::OK ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 212 of file EhrhartPolynomial.h.

213 {
215 }

References DGtal::EhrhartPolynomial< TSpace, TInteger >::myD.

◆ operator=() [1/2]

template<typename TSpace , typename TInteger >
EhrhartPolynomial & DGtal::EhrhartPolynomial< TSpace, TInteger >::operator= ( const EhrhartPolynomial< TSpace, TInteger > &  other)
default

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'.

◆ operator=() [2/2]

template<typename TSpace , typename TInteger >
EhrhartPolynomial & DGtal::EhrhartPolynomial< TSpace, TInteger >::operator= ( EhrhartPolynomial< TSpace, TInteger > &&  other)
default

Move assignment.

Parameters
otherthe object to move.
Returns
a reference on 'this'.

◆ remainder()

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::remainder ( Integer  t) const
inline

◆ remainderInterior()

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::remainderInterior ( Integer  t) const
inline

Definition at line 189 of file EhrhartPolynomial.h.

189 {
190 return myE.degree() % 2 == 0
191 ? ( myE( -t ) % myD )
192 : - ( myE( -t ) % myD );
193 }

References DGtal::MPolynomial< n, TRing, TAlloc >::degree(), DGtal::EhrhartPolynomial< TSpace, TInteger >::myD, and DGtal::EhrhartPolynomial< TSpace, TInteger >::myE.

◆ selfDisplay()

template<typename TSpace , typename TInteger >
void DGtal::EhrhartPolynomial< TSpace, TInteger >::selfDisplay ( std::ostream &  that_stream) const
inline

Writes/Displays the object on an output stream.

Parameters
that_streamthe output stream where the object is written.

Definition at line 202 of file EhrhartPolynomial.h.

203 {
204 that_stream << "[EhrhartPolynomial num=" << numerator()
205 << " den=" << denominator() << " ]" << std::endl;
206 }
Integer denominator() const
The (integral) denominator of the Ehrhart polynomial.
Polynomial numerator() const

References DGtal::EhrhartPolynomial< TSpace, TInteger >::denominator(), and DGtal::EhrhartPolynomial< TSpace, TInteger >::numerator().

Referenced by DGtal::operator<<().

Field Documentation

◆ myD

template<typename TSpace , typename TInteger >
Integer DGtal::EhrhartPolynomial< TSpace, TInteger >::myD
protected

◆ myE

template<typename TSpace , typename TInteger >
Polynomial DGtal::EhrhartPolynomial< TSpace, TInteger >::myE
protected

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