DGtal 1.4.0
Loading...
Searching...
No Matches
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 505 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

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

Definition at line 509 of file MPolynomial.h.

◆ Ring

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

Definition at line 508 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 524 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 535 of file MPolynomial.h.

536 : myAllocator(allocator), myValue( Ring() )
537 {}

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 710 of file MPolynomial.h.

711 {
712 return myAllocator;
713 }

◆ 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 542 of file MPolynomial.h.

543 {
544 return myValue == 0;
545 }

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 551 of file MPolynomial.h.

552 {
553 return myValue;
554 }

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 684 of file MPolynomial.h.

685 {
686 return myValue != v;
687 }

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 571 of file MPolynomial.h.

572 {
573 return myValue;
574 }

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 581 of file MPolynomial.h.

582 {
583 return MPolynomial(myValue * v);
584 }
MPolynomial(const Ring &v=0, const Alloc &allocator=Alloc())

References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), and 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 630 of file MPolynomial.h.

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

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 601 of file MPolynomial.h.

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

References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), and 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 652 of file MPolynomial.h.

653 {
654 myValue += v;
655 return *this;
656 }

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 620 of file MPolynomial.h.

621 {
622 return MPolynomial(-myValue);
623 }

References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), and 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 611 of file MPolynomial.h.

612 {
613 return MPolynomial(myValue - v);
614 }

References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), and 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 663 of file MPolynomial.h.

664 {
665 myValue -= v;
666 return *this;
667 }

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 591 of file MPolynomial.h.

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

References DGtal::MPolynomial< n, TRing, TAlloc >::MPolynomial(), and 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 641 of file MPolynomial.h.

642 {
643 myValue /= v;
644 return *this;
645 }

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 561 of file MPolynomial.h.

562 {
563 myValue = v;
564 return *this;
565 }

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 674 of file MPolynomial.h.

675 {
676 return myValue == v;
677 }

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 693 of file MPolynomial.h.

694 {
695 s << myValue;
696 }

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 702 of file MPolynomial.h.

703 {
704 std::swap(myValue, p.myValue);
705 }

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 512 of file MPolynomial.h.

◆ myValue

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

Definition at line 513 of file MPolynomial.h.


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