DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Private Attributes
DGtal::MPolynomial< 0, TRing, TAlloc > Class Template Reference

#include <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 494 of file MPolynomial.h.


Member Typedef Documentation

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

Definition at line 498 of file MPolynomial.h.

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

Definition at line 497 of file MPolynomial.h.


Constructor & Destructor Documentation

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

: myAllocator(allocator), myValue(v)
{}
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 524 of file MPolynomial.h.

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

Member Function Documentation

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.

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

Definition at line 531 of file MPolynomial.h.

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

{
return myValue == 0;
}
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 540 of file MPolynomial.h.

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

{
return myValue;
}
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 673 of file MPolynomial.h.

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

{
return myValue != v;
}
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 560 of file MPolynomial.h.

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

{
return myValue;
}
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 570 of file MPolynomial.h.

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

{
return MPolynomial(myValue * v);
}
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 619 of file MPolynomial.h.

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

{
myValue *= v;
return *this;
}
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 590 of file MPolynomial.h.

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

{
return MPolynomial(myValue + v);
}
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 641 of file MPolynomial.h.

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

{
myValue += v;
return *this;
}
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 600 of file MPolynomial.h.

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

{
return MPolynomial(myValue - v);
}
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 609 of file MPolynomial.h.

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

{
return MPolynomial(-myValue);
}
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 652 of file MPolynomial.h.

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

{
myValue -= v;
return *this;
}
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 580 of file MPolynomial.h.

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

{
return MPolynomial(myValue / v);
}
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 630 of file MPolynomial.h.

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

{
myValue /= v;
return *this;
}
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 550 of file MPolynomial.h.

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

{
myValue = v;
return *this;
}
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 663 of file MPolynomial.h.

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

{
return myValue == v;
}
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
Ndegree of the polynomial, default to zero.

Definition at line 683 of file MPolynomial.h.

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

{
s << myValue;
}
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.

References DGtal::MPolynomial< n, TRing, TAlloc >::myValue, and DGtal::MPolynomial< n, TRing, TAlloc >::swap().


Field Documentation

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

Definition at line 501 of file MPolynomial.h.

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

Definition at line 502 of file MPolynomial.h.


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