OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Member Functions | Private Attributes | List of all members
polynomial::PolynomialSum Class Reference

#include <PolynomialSum.h>

Public Member Functions

 PolynomialSum ()
 
 PolynomialSum (const TwoPolynomial &polynomial)
 
 PolynomialSum (const PolynomialSum &polynomialSum)
 
 ~PolynomialSum ()
 
PolynomialSumoperator= (const PolynomialSum &sum)
 
void differentiateX ()
 
void differentiateS ()
 
void multiplyPolynomial (const TwoPolynomial &poly)
 
void printPolynomial () const
 
std::size_t numberOfTerms () const
 
bool isPolynomialZero (const std::size_t &p) const
 
void truncate (const std::size_t &truncateOrder)
 
double evaluatePolynomial (const std::size_t &p, const double &x, const double &s) const
 
void putSumTogether (const std::vector< double > &dSvalues, std::vector< std::vector< double >> &finalPolynomial) const
 
double evaluatePolynomial2 (const double &x, const double &s, const std::vector< double > &dSvalues) const
 
void addPolynomial (const PolynomialSum &poly)
 
std::vector< std::size_t > getdSfactors (const std::size_t &p) const
 
void sortTerms ()
 

Private Attributes

std::vector< TwoPolynomial > polynomialSum_m
 

Detailed Description

Definition at line 52 of file PolynomialSum.h.

Constructor & Destructor Documentation

◆ PolynomialSum() [1/3]

polynomial::PolynomialSum::PolynomialSum ( )

Default constructor, initialises empty sum

Definition at line 36 of file PolynomialSum.cpp.

◆ PolynomialSum() [2/3]

polynomial::PolynomialSum::PolynomialSum ( const TwoPolynomial &  polynomial)
explicit

Constructor, initialises sum with a single polynomial from input

Parameters
polynomial-> The polynomial sum is initialised with this
polynomial as the first and only term

Definition at line 39 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ PolynomialSum() [3/3]

polynomial::PolynomialSum::PolynomialSum ( const PolynomialSum polynomialSum)

Copy constructor

Definition at line 43 of file PolynomialSum.cpp.

◆ ~PolynomialSum()

polynomial::PolynomialSum::~PolynomialSum ( )

Desctructor, does nothing

Definition at line 47 of file PolynomialSum.cpp.

Member Function Documentation

◆ addPolynomial()

void polynomial::PolynomialSum::addPolynomial ( const PolynomialSum poly)

Add poly to the sum by concatenating the lists

Parameters
poly-> Polynomial that is added to the list

Definition at line 111 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ differentiateS()

void polynomial::PolynomialSum::differentiateS ( )

Differentiate each term wrt s

Definition at line 61 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ differentiateX()

void polynomial::PolynomialSum::differentiateX ( )

Differentiate each term wrt x

Definition at line 55 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ evaluatePolynomial()

double polynomial::PolynomialSum::evaluatePolynomial ( const std::size_t &  p,
const double &  x,
const double &  s 
) const
inline

Evaluate polynomial in term p at the point (x, s)
If p is outside list range zero is returned

Parameters
p-> Term index, starting with term 0
x-> Point x where polynomial is evaluated
s-> Point s where polynomial is evaluated

Definition at line 140 of file PolynomialSum.h.

References polynomialSum_m.

◆ evaluatePolynomial2()

double polynomial::PolynomialSum::evaluatePolynomial2 ( const double &  x,
const double &  s,
const std::vector< double > &  dSvalues 
) const

Evaluate polynomial after putting the sum together into one polynomial

Parameters
x-> Point x where polynomial is evaluated
s-> Point s where polynomial is evaluated
dSvalues-> List of evaluated S(s)-derivatives, starting with zeroth (no) derivative

Definition at line 205 of file PolynomialSum.cpp.

References putSumTogether().

Here is the call graph for this function:

◆ getdSfactors()

std::vector< std::size_t > polynomial::PolynomialSum::getdSfactors ( const std::size_t &  p) const

Returns lists of S(s)-derivatives in term p
Returns empty list if p is negative or outside list range

Parameters
p-> Term index, starting with term 0

Definition at line 123 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ isPolynomialZero()

bool polynomial::PolynomialSum::isPolynomialZero ( const std::size_t &  p) const

Check if term p is a zero polynomial
Returns true if p is negative or outside the range of list range

Parameters
p-> Term index, starting with term 0

Definition at line 96 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ multiplyPolynomial()

void polynomial::PolynomialSum::multiplyPolynomial ( const TwoPolynomial &  poly)

Multiply term with input polynomial

Parameters
poly-> Polynomial to be multiplied with this polynomial

Definition at line 81 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ numberOfTerms()

std::size_t polynomial::PolynomialSum::numberOfTerms ( ) const
inline

Returns number of terms in the sum

Definition at line 136 of file PolynomialSum.h.

References polynomialSum_m.

◆ operator=()

PolynomialSum & polynomial::PolynomialSum::operator= ( const PolynomialSum sum)

Assigment operator

Definition at line 50 of file PolynomialSum.cpp.

References polynomialSum_m, and sum().

Here is the call graph for this function:

◆ printPolynomial()

void polynomial::PolynomialSum::printPolynomial ( ) const

Print polynomial, for internal debugging

Definition at line 87 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ putSumTogether()

void polynomial::PolynomialSum::putSumTogether ( const std::vector< double > &  dSvalues,
std::vector< std::vector< double >> &  finalPolynomial 
) const

Put together all terms in the PolynomialSum by evaluating the
S(s)-derivatives and multiply them with the polynomial coefficients
Polynomial coefficients are now of type double

Parameters
dSvalues-> List of evaluated S(s)-derivates, starting with zeroth (no) derivative
finalPolynomial-> Resulting polynomial, must pass an empty vector of vectors into this function

Definition at line 159 of file PolynomialSum.cpp.

References polynomialSum_m.

Referenced by evaluatePolynomial2().

◆ sortTerms()

void polynomial::PolynomialSum::sortTerms ( )

Sort polynomialSum_m such that the TwoPolynomial objects with fewest
S(s)-derivatives come first, in ascending order
If any TwoPolynomial objects have identical S(s)-derivatives these are put together by adding the polynomials

Definition at line 132 of file PolynomialSum.cpp.

References polynomialSum_m.

◆ truncate()

void polynomial::PolynomialSum::truncate ( const std::size_t &  truncateOrder)

Truncate series in x at truncateOrder

Parameters
truncateOrder-> Highest power of x after truncation

Definition at line 105 of file PolynomialSum.cpp.

References polynomialSum_m.

Member Data Documentation

◆ polynomialSum_m

std::vector<TwoPolynomial> polynomial::PolynomialSum::polynomialSum_m
private

The documentation for this class was generated from the following files: