#include <nmrStandardPolynomial.h>
Inheritance diagram for nmrStandardPolynomial:


Note: some methods include assertions. To avoid including the <assert.h> header file by all the files that use polynomials, I put these methods, and some which were more than one-liners, in the .cpp file. But in every practical way, nmrStandardPolynomial could be implemented completely as inline.
Note: We use dynamic allocation for the term information (Coefficient), which is separate from the STL provided dynamic allocation for the container elements. We store the pointer to the dynamically allocated term info in the container. Therefore: 1. We had to override the base-class's RemoveTerm() and Clear() methods. 2. Do not even try to make a copy of a nmrBernsteinPolynomial using copy-ctor or operator= (yeah, like you would). Just for safety, we declare these operations protected, and do not provide implementation. 3. A better solution may be to define a common base type for TermInfo, and have it declare a virtual dtor. Go for it, if you have time.
Definition at line 56 of file nmrStandardPolynomial.h.
| nmrStandardPolynomial::nmrStandardPolynomial | ( | VariableIndexType | numVariables, | |
| PowerType | minDegree, | |||
| PowerType | maxDegree | |||
| ) | [inline] |
Constructor determines the number of variables and the degree of the polynomial.
Definition at line 63 of file nmrStandardPolynomial.h.
| virtual InsertStatus nmrStandardPolynomial::SetCoefficient | ( | const nmrPolynomialTermPowerIndex & | where, | |
| CoefficientType | coefficient | |||
| ) | [virtual] |
Set a coefficient for the given term.
Implements nmrPolynomialContainer< void * >.
| virtual CoefficientType nmrStandardPolynomial::GetCoefficient | ( | const nmrPolynomialTermPowerIndex & | where | ) | const [inline, virtual] |
Retrieve the value of the user defined coefficient for a given term.
Definition at line 114 of file nmrStandardPolynomial.h.
References nmrPolynomialContainer< void * >::EndTermIterator(), and nmrPolynomialContainer< void * >::FindTerm().
| virtual void nmrStandardPolynomial::RemoveTerm | ( | TermIteratorType & | where | ) | [virtual] |
Remove a term from the polynomial. The term is given by iterator. The function also reclaims the space allocated for the term.
| virtual void nmrStandardPolynomial::Clear | ( | ) | [virtual] |
Remove all the terms to make an empty (zero) polynomial We cannot use nmrPolynomialContainer::Clear(), since it does not reclaim the space allocated for the term. This implementation does.
Reimplemented from nmrPolynomialContainer< void * >.
| virtual ValueType nmrStandardPolynomial::EvaluateBasis | ( | const nmrPolynomialTermPowerIndex & | where, | |
| const nmrMultiVariablePowerBasis & | variables | |||
| ) | const [inline, virtual] |
Evaluate the basis function for a term. The term is regarded as a list of powers, without any user defined coefficient. However, for different families of polynomial the set of basis functions are different. For example, Bezier polynomials have the multinomial coefficient in addition to each user defined coefficient. Implemented for each concrete polynomial class.
Implements nmrPolynomialBase.
Definition at line 146 of file nmrStandardPolynomial.h.
References nmrMultiVariablePowerBasis::EvaluatePowerProduct(), nmrPolynomialTermPowerIndex::GetDegree(), nmrMultiVariablePowerBasis::GetMaxDegree(), nmrPolynomialTermPowerIndex::GetNumVariables(), nmrMultiVariablePowerBasis::GetNumVariables(), and nmrPolynomialTermPowerIndex::GetPowers().
| virtual void nmrStandardPolynomial::SerializeTermInfo | ( | std::ostream & | output, | |
| const TermConstIteratorType & | termIterator | |||
| ) | const [virtual] |
This function is overridden to store the term coefficient to the stream. It is called from nmrPolynomialContainer::SerializeRaw().
Implements nmrDynAllocPolynomialContainer.
| virtual void nmrStandardPolynomial::DeserializeTermInfo | ( | std::istream & | input, | |
| TermIteratorType & | termIterator | |||
| ) | [virtual] |
This function is overridden to allocate memory for and read the term coefficient. It is called from nmrPolynomialContainer::DeserializeRaw().
Implements nmrDynAllocPolynomialContainer.
| virtual void nmrStandardPolynomial::AddConstant | ( | CoefficientType | shiftAmount | ) | [virtual] |
An actual implementation overriding nmrPolynomialBase. In this implementation, the coefficient of the term with degree zero is increased by the given shift amount.
Implements nmrPolynomialContainer< void * >.
| virtual void nmrStandardPolynomial::AddConstantToCoefficients | ( | CoefficientType | coefficients[], | |
| CoefficientType | shiftAmount | |||
| ) | const [virtual] |
Overloaded from nmrPolynomialBase. This implementation verifies that this polynomial contains a term of degree zero, and adds the shift amount to the corresponding external coefficient.
Implements nmrPolynomialContainer< void * >.