DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
DGtal::MPolynomial< 0, TRing, TAlloc > Class Template Reference

Aim: Specialization of MPolynomial for degree 0. More...

#include <DGtal/math/MPolynomial.h>

Public Types

typedef TRing Ring
 
typedef TAlloc Alloc
 

Public Member Functions

 MPolynomial (const Ring &v=0, const Alloc &allocator=Alloc())
 
 MPolynomial (const Alloc &allocator)
 
bool isZero () const
 
 operator const Ring & () const
 
MPolynomialoperator= (const Ring &v)
 
Ring operator() () const
 
MPolynomial operator* (const Ring &v) const
 
MPolynomial operator/ (const Ring &v) const
 
MPolynomial operator+ (const Ring &v) const
 
MPolynomial operator- (const Ring &v) const
 
MPolynomial operator- () const
 
MPolynomialoperator*= (const Ring &v)
 
MPolynomialoperator/= (const Ring &v)
 
MPolynomialoperator+= (const Ring &v)
 
MPolynomialoperator-= (const Ring &v)
 
bool operator== (const Ring &v) const
 
bool operator!= (const Ring &v) const
 
void selfDisplay (std::ostream &s, int) const
 
void swap (MPolynomial &p)
 
Alloc getAllocator () const
 

Private Attributes

Alloc myAllocator
 
Ring myValue
 

Detailed Description

template<typename TRing, typename TAlloc>
class DGtal::MPolynomial< 0, TRing, TAlloc >

Aim: Specialization of MPolynomial for degree 0.

Description of template class 'MPolynomial'

Stores a polynomial of degree 0, i.e. a scalar of type T. We assume that the type T is not "too" complex, otherwise this class will be partially not very effective.

Template Parameters
TRingthe type chosen for the polynomial, defines also the type of the coefficents (generally int, float or double).
TAllocis an allocator for TRing, for example std::allocator<TRing>; this is also the default parameter. Usually this parameter does not needs to be changed.

This class is a backport from Spielwiese.

Author
Felix Fontein (felix.nosp@m.@fon.nosp@m.tein..nosp@m.de), University of Zurich, Switzerland

Definition at line 495 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

template<typename TRing , typename TAlloc >
typedef TAlloc DGtal::MPolynomial< 0, TRing, TAlloc >::Alloc

Definition at line 499 of file MPolynomial.h.

◆ Ring

template<typename TRing , typename TAlloc >
typedef TRing DGtal::MPolynomial< 0, TRing, TAlloc >::Ring

Definition at line 498 of file MPolynomial.h.

Constructor & Destructor Documentation

◆ MPolynomial() [1/2]

template<typename TRing , typename TAlloc >
DGtal::MPolynomial< 0, TRing, TAlloc >::MPolynomial ( const Ring v = 0,
const Alloc allocator = Alloc() 
)
inline

Constructor (default, or from ring value). Creates the constant polynomial v.

Parameters
vany value in the ring.
allocatoran allocator for the polynomial.

Definition at line 514 of file MPolynomial.h.

◆ MPolynomial() [2/2]

template<typename TRing , typename TAlloc >
DGtal::MPolynomial< 0, TRing, TAlloc >::MPolynomial ( const Alloc allocator)
inline

Allocator constructor. Creates the constant polynomial 0, where 0 is the default value of the ring.

Parameters
allocatoran allocator for the polynomial.

Definition at line 525 of file MPolynomial.h.

526 : myAllocator(allocator), myValue( Ring() )
527 {}

Member Function Documentation

◆ getAllocator()

template<typename TRing , typename TAlloc >
Alloc DGtal::MPolynomial< 0, TRing, TAlloc >::getAllocator ( ) const
inline
Returns
the allocator for this object.

Definition at line 700 of file MPolynomial.h.

701 {
702 return myAllocator;
703 }

◆ isZero()

template<typename TRing , typename TAlloc >
bool DGtal::MPolynomial< 0, TRing, TAlloc >::isZero ( ) const
inline
Returns
true if the polynomial is 0.

Definition at line 532 of file MPolynomial.h.

533 {
534 return myValue == 0;
535 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator const Ring &()

template<typename TRing , typename TAlloc >
DGtal::MPolynomial< 0, TRing, TAlloc >::operator const Ring & ( ) const
inline

Const cast operator to Ring value. Returns the coefficient value of this constant polynomial.

Definition at line 541 of file MPolynomial.h.

542 {
543 return myValue;
544 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator!=()

template<typename TRing , typename TAlloc >
bool DGtal::MPolynomial< 0, TRing, TAlloc >::operator!= ( const Ring v) const
inline

Difference operator.

Parameters
vany value in the ring.
Returns
true iff myValue is different from v.

Definition at line 674 of file MPolynomial.h.

675 {
676 return myValue != v;
677 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator()()

template<typename TRing , typename TAlloc >
Ring DGtal::MPolynomial< 0, TRing, TAlloc >::operator() ( ) const
inline

Evaluation operator for the polynomial.

Returns
the value of its coefficient.

Definition at line 561 of file MPolynomial.h.

562 {
563 return myValue;
564 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator*()

template<typename TRing , typename TAlloc >
MPolynomial DGtal::MPolynomial< 0, TRing, TAlloc >::operator* ( const Ring v) const
inline

Multiplication by value v.

Parameters
vany value in the ring.
Returns
a constant polynomial of coefficient myValue*v.

Definition at line 571 of file MPolynomial.h.

572 {
573 return MPolynomial(myValue * v);
574 }
MPolynomial(const Ring &v=0, const Alloc &allocator=Alloc())
Definition: MPolynomial.h:514

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator*=()

template<typename TRing , typename TAlloc >
MPolynomial & DGtal::MPolynomial< 0, TRing, TAlloc >::operator*= ( const Ring v)
inline

Self-multiplication by value v.

Parameters
vany value in the ring.
Returns
itself

Definition at line 620 of file MPolynomial.h.

621 {
622 myValue *= v;
623 return *this;
624 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator+()

template<typename TRing , typename TAlloc >
MPolynomial DGtal::MPolynomial< 0, TRing, TAlloc >::operator+ ( const Ring v) const
inline

Addition by value v.

Parameters
vany value in the ring.
Returns
a constant polynomial of coefficient myValue+v.

Definition at line 591 of file MPolynomial.h.

592 {
593 return MPolynomial(myValue + v);
594 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator+=()

template<typename TRing , typename TAlloc >
MPolynomial & DGtal::MPolynomial< 0, TRing, TAlloc >::operator+= ( const Ring v)
inline

Self-addition by value v.

Parameters
vany value in the ring.
Returns
itself

Definition at line 642 of file MPolynomial.h.

643 {
644 myValue += v;
645 return *this;
646 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator-() [1/2]

template<typename TRing , typename TAlloc >
MPolynomial DGtal::MPolynomial< 0, TRing, TAlloc >::operator- ( ) const
inline

Unary minus operator.

Returns
a constant polynomial of coefficient -myValue.

Definition at line 610 of file MPolynomial.h.

611 {
612 return MPolynomial(-myValue);
613 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator-() [2/2]

template<typename TRing , typename TAlloc >
MPolynomial DGtal::MPolynomial< 0, TRing, TAlloc >::operator- ( const Ring v) const
inline

Subtraction by value v.

Parameters
vany value in the ring.
Returns
a constant polynomial of coefficient myValue-v.

Definition at line 601 of file MPolynomial.h.

602 {
603 return MPolynomial(myValue - v);
604 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator-=()

template<typename TRing , typename TAlloc >
MPolynomial & DGtal::MPolynomial< 0, TRing, TAlloc >::operator-= ( const Ring v)
inline

Self-subtraction by value v.

Parameters
vany value in the ring.
Returns
itself

Definition at line 653 of file MPolynomial.h.

654 {
655 myValue -= v;
656 return *this;
657 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator/()

template<typename TRing , typename TAlloc >
MPolynomial DGtal::MPolynomial< 0, TRing, TAlloc >::operator/ ( const Ring v) const
inline

Division by value v.

Parameters
vany value in the ring.
Returns
a constant polynomial of coefficient myValue/v.

Definition at line 581 of file MPolynomial.h.

582 {
583 return MPolynomial(myValue / v);
584 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator/=()

template<typename TRing , typename TAlloc >
MPolynomial & DGtal::MPolynomial< 0, TRing, TAlloc >::operator/= ( const Ring v)
inline

Self-division by value v.

Parameters
vany value in the ring.
Returns
itself

Definition at line 631 of file MPolynomial.h.

632 {
633 myValue /= v;
634 return *this;
635 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator=()

template<typename TRing , typename TAlloc >
MPolynomial & DGtal::MPolynomial< 0, TRing, TAlloc >::operator= ( const Ring v)
inline

Assigment from coefficient in the ring.

Parameters
vany value in the ring.
Returns
itself

Definition at line 551 of file MPolynomial.h.

552 {
553 myValue = v;
554 return *this;
555 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ operator==()

template<typename TRing , typename TAlloc >
bool DGtal::MPolynomial< 0, TRing, TAlloc >::operator== ( const Ring v) const
inline

Equality operator.

Parameters
vany value in the ring.
Returns
true iff myValue is equal to v.

Definition at line 664 of file MPolynomial.h.

665 {
666 return myValue == v;
667 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ selfDisplay()

template<typename TRing , typename TAlloc >
void DGtal::MPolynomial< 0, TRing, TAlloc >::selfDisplay ( std::ostream &  s,
int   
) const
inline

Outputs itself in the stream s.

Parameters
sany stream

Definition at line 683 of file MPolynomial.h.

684 {
685 s << myValue;
686 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

◆ swap()

template<typename TRing , typename TAlloc >
void DGtal::MPolynomial< 0, TRing, TAlloc >::swap ( MPolynomial< 0, TRing, TAlloc > &  p)
inline

Swaps two polynomials.

Parameters
pany zero-degree polynomial.

Definition at line 692 of file MPolynomial.h.

693 {
694 std::swap(myValue, p.myValue);
695 }

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue.

Field Documentation

◆ myAllocator

template<typename TRing , typename TAlloc >
Alloc DGtal::MPolynomial< 0, TRing, TAlloc >::myAllocator
private

Definition at line 502 of file MPolynomial.h.

◆ myValue

template<typename TRing , typename TAlloc >
Ring DGtal::MPolynomial< 0, TRing, TAlloc >::myValue
private

Definition at line 503 of file MPolynomial.h.


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