17 #include "../include/Polynomial.hpp"
23 std::cout<<
"Enter number of coefficients followed by the values for two polynomials. For example:" <<std::endl;
24 std::cout<<
"if p1 = 2x^3 + x and p2 = x^2 - 10x + 1,\nthen enter 4 0 1 0 2 3 1 -10 1" <<std::endl;
27 int main(
int argc,
char* argv[])
31 using FieldType = double;
37 size_t number_of_coeffs_p1 = std::stoul(argv[1]);
39 if ((
size_t)argc < idx + number_of_coeffs_p1 +1)
throw std::invalid_argument(
"Invalid number of inputs supplied");
40 for (
size_t i= 0; i < number_of_coeffs_p1; ++i) {
44 size_t number_of_coeffs_p2 = std::stoul(argv[++idx]);
45 if ((
size_t)argc < idx + number_of_coeffs_p2 + 1)
throw std::invalid_argument(
"Invalid number of inputs supplied");
46 for (
size_t i= 0; i < number_of_coeffs_p2; ++i) {
50 catch (std::invalid_argument& e) {
51 std::cout << e.what() <<std::endl;
62 std::cout<<
"Addition:p1+p2\n"<<padd<<std::endl;
65 std::cout<<
"Subtraction:p1-p2\n"<<psub<<std::endl;
void appendTerm(FieldT coeff)
Append new terms by pushing back coefficients.
void print_help()
This file demonstrates the top-level funtionalities of the Polynomial class.
Contains the definition for the abstract base class which will be used by different multiplication al...
int main(int argc, char *argv[])