// -*- c++ -*- /**************************************************************** **** **** This file belongs with the course **** Introduction to Scientific Programming in C++/Fortran2003 **** copyright 2017-2023 Victor Eijkhout eijkhout@tacc.utexas.edu **** **** poly.cxx : polynomial class implementation **** ****************************************************************/ #include using std::cin; using std::cout; #include using std::vector; #include "poly.hpp" polynomial::polynomial() { read(); set_positive(); print(); }; void polynomial::read() { int degree; std::cout << "Degree?"; std::cin >> degree ; std::cout << '\n'; coefficients = std::vector(degree+1); for (int c=0; c<=degree; c++) { std::cout << "coeff" << c << ":"; std::cin >> coefficients.at(c); } std::cout << '\n'; }; void polynomial::set_positive() { if (coefficients[0]<0) { std::cout << "Flipping to get positive leading coefficient" << '\n'; for (int ic=0; ic