Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

atlas::polynomials::Polynomial< C > Class Template Reference

Polynomials with coefficients in C, which is expected to be a standard unsigned type. More...

#include <polynomials.h>

Inheritance diagram for atlas::polynomials::Polynomial< C >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Polynomial ()
 Polynomial (Degree d)
 Constructs x^d.
void swap (Polynomial &other)
operator[] (Degree j) const
bool operator== (const Polynomial &q) const
bool operator!= (const Polynomial &q) const
bool operator< (const Polynomial &q) const
 Operator < is the default from the standard library < on vector.
Degree degree () const
bool isZero () const
C & operator[] (Degree j)
Polynomialoperator+= (const Polynomial &q)
Polynomialoperator-= (const Polynomial &q)
Polynomialsubtract_from (const Polynomial &p)
Polynomialoperator *= (C)
Polynomial operator * (const Polynomial &q) const
void safeAdd (const Polynomial &p, Degree d, C c)
 Adds x^d.c.q, to *this, watching for overflow.
void safeAdd (const Polynomial &p, Degree d=0)
void safeSubtract (const Polynomial &p, Degree d, C c)
 Subtracts x^d.c.q from *this, watching for underflow.
void safeSubtract (const Polynomial &p, Degree d=0)

Private Member Functions

void adjustSize ()
 Adjusts the size of d_data so that it corresponds to the degree + 1.

Private Attributes

std::vector< C > d_data

Detailed Description

template<typename C>
class atlas::polynomials::Polynomial< C >

Polynomials with coefficients in C, which is expected to be a standard unsigned type.

The coefficient type C must support addition (+, +=), multiplication (*, *=), subtraction (unary and binary -, -=), and std::numeric_limits<C> (used to test for overflow in the safeAdd operation); moreover comparisons (<, ==, !=) should be defined, although < need not have any particular mathematical sense

Definition at line 63 of file polynomials.h.


Constructor & Destructor Documentation

template<typename C>
atlas::polynomials::Polynomial< C >::Polynomial  )  [inline]
 

Definition at line 74 of file polynomials.h.

Referenced by atlas::polynomials::Polynomial< C >::operator *(), and atlas::polynomials::Polynomial< C >::operator *=().

template<typename C>
atlas::polynomials::Polynomial< C >::Polynomial Degree  d  )  [explicit]
 

Constructs x^d.

We construct x^d, and not the zero polynomial, so that our basic assumption about the degree is satisfied.

Definition at line 60 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data.


Member Function Documentation

template<typename C>
void atlas::polynomials::Polynomial< C >::adjustSize  )  [private]
 

Adjusts the size of d_data so that it corresponds to the degree + 1.

Steps down through the coefficients of the polynomial, beginning with the top coefficient, until it finds a non-zero coefficient (or reaches zero). Then resizes d_data so that this non-zero coefficient is the top one (or to have size zero if the polynomial is zero).

Definition at line 88 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data.

Referenced by atlas::polynomials::Polynomial< C >::operator+=(), atlas::polynomials::Polynomial< C >::operator-=(), atlas::polynomials::Polynomial< C >::safeSubtract(), and atlas::polynomials::Polynomial< C >::subtract_from().

template<typename C>
Degree atlas::polynomials::Polynomial< C >::degree  )  const [inline]
 

Definition at line 106 of file polynomials.h.

Referenced by atlas::polynomials::compare(), atlas::kl::KLPolEntry::hashCode(), atlas::polynomials::Polynomial< C >::operator *(), atlas::kl::KLPolEntry::operator!=(), atlas::prettyprint::printPol(), atlas::polynomials::Polynomial< C >::safeAdd(), and atlas::polynomials::Polynomial< C >::safeSubtract().

template<typename C>
bool atlas::polynomials::Polynomial< C >::isZero  )  const [inline]
 

Definition at line 108 of file polynomials.h.

Referenced by atlas::kl::helper::Thicket::ascentCompute(), atlas::polynomials::compare(), atlas::kltest::dualityVerify(), atlas::kl::helper::Thicket::edgeCompute(), atlas::kl::KLPolEntry::hashCode(), atlas::polynomials::Polynomial< C >::operator *(), atlas::kl::KLPolEntry::operator!=(), atlas::polynomials::Polynomial< C >::operator+=(), atlas::polynomials::Polynomial< C >::operator-=(), atlas::kl_io::printAllKL(), atlas::kl_io::printKLList(), atlas::prettyprint::printPol(), atlas::polynomials::Polynomial< C >::safeAdd(), atlas::polynomials::Polynomial< C >::safeSubtract(), and atlas::kl::helper::Helper::writeRow().

template<typename C>
Polynomial< C > atlas::polynomials::Polynomial< C >::operator * const Polynomial< C > &  q  )  const
 

Definition at line 153 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data, atlas::polynomials::Polynomial< C >::degree(), atlas::polynomials::Polynomial< C >::isZero(), and atlas::polynomials::Polynomial< C >::Polynomial().

template<typename C>
Polynomial< C > & atlas::polynomials::Polynomial< C >::operator *=  ) 
 

Definition at line 143 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data, and atlas::polynomials::Polynomial< C >::Polynomial().

template<typename C>
bool atlas::polynomials::Polynomial< C >::operator!= const Polynomial< C > &  q  )  const [inline]
 

Definition at line 92 of file polynomials.h.

template<typename C>
Polynomial< C > & atlas::polynomials::Polynomial< C >::operator+= const Polynomial< C > &  q  ) 
 

Definition at line 98 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::adjustSize(), atlas::polynomials::Polynomial< C >::d_data, and atlas::polynomials::Polynomial< C >::isZero().

template<typename C>
Polynomial< C > & atlas::polynomials::Polynomial< C >::operator-= const Polynomial< C > &  q  ) 
 

Definition at line 115 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::adjustSize(), atlas::polynomials::Polynomial< C >::d_data, and atlas::polynomials::Polynomial< C >::isZero().

template<typename C>
bool atlas::polynomials::Polynomial< C >::operator< const Polynomial< C > &  q  )  const [inline]
 

Operator < is the default from the standard library < on vector.

The comparison operation below is only defined in order to allow ordered data types containing polynomials, such as |stdset<Polynomial<int> >|. Currently no such types are used in the Atlas (but initially they were).

Definition at line 104 of file polynomials.h.

template<typename C>
bool atlas::polynomials::Polynomial< C >::operator== const Polynomial< C > &  q  )  const [inline]
 

Definition at line 88 of file polynomials.h.

template<typename C>
C& atlas::polynomials::Polynomial< C >::operator[] Degree  j  )  [inline]
 

Definition at line 111 of file polynomials.h.

template<typename C>
C atlas::polynomials::Polynomial< C >::operator[] Degree  j  )  const [inline]
 

Definition at line 84 of file polynomials.h.

template<typename C>
void atlas::polynomials::Polynomial< C >::safeAdd const Polynomial< C > &  p,
Degree  d = 0
 

Definition at line 203 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data, atlas::polynomials::Polynomial< C >::degree(), atlas::polynomials::Degree, atlas::polynomials::Polynomial< C >::isZero(), and atlas::polynomials::safeAdd().

template<typename C>
void atlas::polynomials::Polynomial< C >::safeAdd const Polynomial< C > &  q,
Degree  d,
c
 

Adds x^d.c.q, to *this, watching for overflow.

NOTE: may forward a NumericOverflow exception.

NOTE: we need to be careful in the case where q = *this, but we can avoid making a copy, by doing the addition top-to-bottom.

Definition at line 180 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::d_data, atlas::polynomials::Polynomial< C >::degree(), atlas::polynomials::Degree, atlas::polynomials::Polynomial< C >::isZero(), atlas::polynomials::safeAdd(), and atlas::polynomials::safeProd().

Referenced by atlas::kl::helper::Thicket::ascentCompute(), and atlas::kl::helper::Helper::writeRow().

template<typename C>
void atlas::polynomials::Polynomial< C >::safeSubtract const Polynomial< C > &  p,
Degree  d = 0
 

Definition at line 257 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::adjustSize(), atlas::polynomials::Polynomial< C >::d_data, atlas::polynomials::Polynomial< C >::degree(), atlas::polynomials::Degree, atlas::polynomials::Polynomial< C >::isZero(), and atlas::polynomials::safeSubtract().

template<typename C>
void atlas::polynomials::Polynomial< C >::safeSubtract const Polynomial< C > &  q,
Degree  d,
c
 

Subtracts x^d.c.q from *this, watching for underflow.

NOTE: may forward a NumericUnderflow exception.

NOTE: q = *this is possible only for d = 0; still, we do the prudent thing and subtract backwards.

Definition at line 231 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::adjustSize(), atlas::polynomials::Polynomial< C >::d_data, atlas::polynomials::Polynomial< C >::degree(), atlas::polynomials::Degree, atlas::polynomials::Polynomial< C >::isZero(), atlas::polynomials::safeProd(), and atlas::polynomials::safeSubtract().

Referenced by atlas::kl::helper::Thicket::edgeCompute().

template<typename C>
Polynomial< C > & atlas::polynomials::Polynomial< C >::subtract_from const Polynomial< C > &  p  ) 
 

Definition at line 127 of file polynomials_def.h.

References atlas::polynomials::Polynomial< C >::adjustSize(), and atlas::polynomials::Polynomial< C >::d_data.

Referenced by atlas::kltest::dualityVerify().

template<typename C>
void atlas::polynomials::Polynomial< C >::swap Polynomial< C > &  other  )  [inline]
 

Definition at line 79 of file polynomials.h.


Member Data Documentation

template<typename C>
std::vector<C> atlas::polynomials::Polynomial< C >::d_data [private]
 

Definition at line 67 of file polynomials.h.

Referenced by atlas::polynomials::Polynomial< C >::adjustSize(), atlas::polynomials::Polynomial< C >::operator *(), atlas::polynomials::Polynomial< C >::operator *=(), atlas::polynomials::Polynomial< KLCoeff >::operator!=(), atlas::polynomials::Polynomial< C >::operator+=(), atlas::polynomials::Polynomial< C >::operator-=(), atlas::polynomials::Polynomial< KLCoeff >::operator<(), atlas::polynomials::Polynomial< KLCoeff >::operator==(), atlas::polynomials::Polynomial< C >::Polynomial(), atlas::polynomials::Polynomial< C >::safeAdd(), atlas::polynomials::Polynomial< C >::safeSubtract(), atlas::polynomials::Polynomial< C >::subtract_from(), and atlas::polynomials::Polynomial< KLCoeff >::swap().


The documentation for this class was generated from the following files:
Generated on Wed Mar 26 16:53:00 2008 for atlas by  doxygen 1.3.9.1