* of the array denotes the
* constant term, the second the
* linear one, and so on. The
- * order of the polynomial
+ * degree of the polynomial
* represented by this object is
* thus the number of elements in
* the @p{coefficient} array
void value (const number x,
std::vector<number> &values) const;
+ /**
+ * Degree of the polynomial. This
+ * is the degree reflected by the
+ * number of coefficients
+ * provided by the
+ * constructor. Leading non-zero
+ * coefficients are not treated
+ * separately.
+ */
+ unsigned int degree () const;
+
/**
* Exception
*/
};
+template <typename number>
+inline
+unsigned int
+Polynomial<number>::degree () const
+{
+ Assert (coefficients.size()>0, ExcVoidPolynomial());
+ return coefficients.size() - 1;
+}
+
#endif
std::vector<number> *ck = new std::vector<number>(k+1);
- const number a = 1./k+1;
- const number b = a*(2*k+1);
+ const number a = 1./(k);
+ const number b = a*(2*k-1);
+ const number c = a*(k-1);
(*ck)[k] = b*(*coefficients[k-1])[k-1];
(*ck)[k-1] = b*(*coefficients[k-1])[k-2];
for (unsigned int i=1 ; i<= k-2 ; ++i)
(*ck)[i] = b*(*coefficients[k-1])[i-1]
- - k*a*(*coefficients[k-2])[i];
- (*ck)[0] = -k*a*(*coefficients[k-2])[0];
+ -c*(*coefficients[k-2])[i];
+
+ (*ck)[0] = -c*(*coefficients[k-2])[0];
// finally assign the newly
// created vector to the