17 #ifndef _POLYNOMIAL_HPP_
18 #define _POLYNOMIAL_HPP_
21 #include <initializer_list>
22 #ifdef INTRUSIVE_TESTS
23 #include "gtest/gtest.h"
28 template<
typename FieldT>
39 template <
typename FieldT>
56 template <
typename InputIt>
62 template <
typename convertibleToFieldT>
68 std::cout<<
"copy constructor Polynomial(const Polynomial&)"<<std::endl;
76 std::cout<<
"move constructor Polynomial(Polynomial&&)"<<std::endl;
99 std::swap(lhs.m_coefs,rhs.m_coefs);
100 std::swap(lhs.m_size,rhs.m_size);
116 std::cout<<
"friend -(const &)"<<std::endl;
124 std::cout<<
"friend -(&&)"<<std::endl;
127 return std::move(temp);
161 std::for_each(p.
m_coefs.begin(),p.
m_coefs.end(), [&](
const FieldT& coef) {os<<
"+ "<<coef <<
"x^"<<pow <<
" ";++pow; });
185 #ifdef INTRUSIVE_TESTS
190 friend class PolynomialTestMPZ;
214 template <
typename T>
221 template<
typename FieldT>
226 #endif //_POLYNOMIAL_HPP_
T minus(T v)
Brief function description here.
Polynomial< FieldT > operator*(const Polynomial< FieldT > &p1, const Polynomial< FieldT > &p2)
The multiplicaion operator. It picks the algorithm with which the Polynomial class is instantiated...
void appendTerm(FieldT coeff)
Append new terms by pushing back coefficients.
std::list< FieldT > m_coefs
Polynomial()
The default constructor to make the class default constructible.
friend std::ostream & operator<<(std::ostream &os, const Polynomial &p)
Polynomial operator+(const Polynomial &p2)
operator
friend Polynomial operator-(Polynomial const &rhs)
The unary (-) operator.
const FieldT & operator[](size_t i) const
Operator to fetch coefficients. Checks range.
friend Polynomial operator-(Polynomial &&temp)
Polynomial(Polynomial &&rhs)
Move constructor implemented using swap.
friend void swap(Polynomial &lhs, Polynomial &rhs) noexcept
A non-template friend swap to aid in the implementation of copy-and-swap.
Polynomial and related classes.
const Polynomial & operator+=(Polynomial const &p2)
The += operator for polynomials.
void trim()
Use to maintain the invariant 1.
Polynomial(const Polynomial &rhs)
Polynomial & minus()
Flip the sign of all coefs.
Contains the definition for the abstract base class which will be used by different multiplication al...
const Polynomial & operator-=(Polynomial const &p2)
The -= operator for polynomials.
Polynomial const & operator=(const Polynomial &rhs)
The assignemnt operator.