DGtal 2.0.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 507 of file MPolynomial.h.

Member Typedef Documentation

◆ Alloc

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

Definition at line 511 of file MPolynomial.h.

◆ Ring

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

Definition at line 510 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 526 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 537 of file MPolynomial.h.

538 : myAllocator(allocator), myValue( Ring() )
539 {}

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

713 {
714 return myAllocator;
715 }

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

545 {
546 return myValue == 0;
547 }

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

554 {
555 return myValue;
556 }

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

687 {
688 return myValue != v;
689 }

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

574 {
575 return myValue;
576 }

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

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

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

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

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

604 {
605 return MPolynomial(myValue + v);
606 }

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

655 {
656 myValue += v;
657 return *this;
658 }

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

623 {
624 return MPolynomial(-myValue);
625 }

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

614 {
615 return MPolynomial(myValue - v);
616 }

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

666 {
667 myValue -= v;
668 return *this;
669 }

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

594 {
595 return MPolynomial(myValue / v);
596 }

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

644 {
645 myValue /= v;
646 return *this;
647 }

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

564 {
565 myValue = v;
566 return *this;
567 }

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

677 {
678 return myValue == v;
679 }

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

696 {
697 s << myValue;
698 }

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

705 {
706 std::swap(myValue, p.myValue);
707 }

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

◆ myValue

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

Definition at line 515 of file MPolynomial.h.


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