ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/math/Polynomial.hpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/math/Polynomial.hpp (file contents):
Revision 1746 by tim, Wed Nov 17 06:37:56 2004 UTC vs.
Revision 1747 by tim, Wed Nov 17 18:58:49 2004 UTC

# Line 101 | Line 101 | class Polynomial {
101          }
102  
103          /**
104 +         * Set the coefficent of the specified exponent, if the coefficient is already there, it
105 +         * will be overwritten.
106           * @param exponent exponent of a term in this Polynomial
107           * @param coefficient multiplier of a term in this Polynomial
108           */
109          
110          void setCoefficient(int exponent, const ElemType& coefficient) {
111              polyPairMap_.insert(PolynomialPairMap::value_type(exponent, coefficient));
112 +        }
113 +
114 +        /**
115 +         * Set the coefficent of the specified exponent. If the coefficient is already there,  just add the
116 +         * new coefficient to the old one, otherwise,  just call setCoefficent
117 +         * @param exponent exponent of a term in this Polynomial
118 +         * @param coefficient multiplier of a term in this Polynomial
119 +         */
120 +        
121 +        void addCoefficient(int exponent, const ElemType& coefficient) {
122 +            PolynomialIterator i = find(exponent);
123 +
124 +            if (i != end()) {
125 +                i->second += coefficient;
126 +            } else {
127 +                setCoefficient(exponent, coefficient);
128 +            }
129          }
130  
131 +
132          /**
133           * Returns the coefficient associated with the given power for this Polynomial.
134           * @return the coefficient associated with the given power for this Polynomial
# Line 160 | Line 180 | Polynomial<ElemType> operator *(const Polynomial<ElemT
180      int coefficient;
181      
182      for (i = p1.begin(); i !=p1.end(); ++i) {
183 <        for (j = p1.begjn(); j !=p1.end(); ++j) {
183 >        for (j = p1.begin(); j !=p1.end(); ++j) {
184              exponent = i->first + j->first;            
185              coefficient = i->second * j->second;
186              k = p->find(exponent);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines