TooN Algorithm Library - tag  0.2
polynomial.h
Go to the documentation of this file.
1 #ifndef POLYNOMIAL_H
2 #define POLYNOMIAL_H
3 #include <vector>
4 #include <TooN/TooN.h>
5 
6 std::vector<double> find_roots(const TooN::Vector<11>& v);
7 
8 
9 template<int N> double polyval(const TooN::Vector<N>& v, double x)
10 {
11  //Polynomials are stored with the coefficient of zero in the first
12  double val=0;
13  for(int i=v.size()-1; i > 0; i--)
14  {
15  val += v[i];
16  val *= x;
17  }
18 
19  val += v[0];
20  return val;
21 }
22 
23 #endif