OPAL (Object Oriented Parallel Accelerator Library)
2021.1.99
OPAL
|
#include <PolynomialSum.h>
Public Member Functions | |
PolynomialSum () | |
PolynomialSum (const TwoPolynomial &polynomial) | |
PolynomialSum (const PolynomialSum &polynomialSum) | |
~PolynomialSum () | |
PolynomialSum & | operator= (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 |
Definition at line 52 of file PolynomialSum.h.
polynomial::PolynomialSum::PolynomialSum | ( | ) |
Default constructor, initialises empty sum
Definition at line 36 of file PolynomialSum.cpp.
|
explicit |
Constructor, initialises sum with a single polynomial from input
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.
polynomial::PolynomialSum::PolynomialSum | ( | const PolynomialSum & | polynomialSum | ) |
Copy constructor
Definition at line 43 of file PolynomialSum.cpp.
polynomial::PolynomialSum::~PolynomialSum | ( | ) |
Desctructor, does nothing
Definition at line 47 of file PolynomialSum.cpp.
void polynomial::PolynomialSum::addPolynomial | ( | const PolynomialSum & | poly | ) |
Add poly to the sum by concatenating the lists
poly | -> Polynomial that is added to the list |
Definition at line 111 of file PolynomialSum.cpp.
References polynomialSum_m.
void polynomial::PolynomialSum::differentiateS | ( | ) |
Differentiate each term wrt s
Definition at line 61 of file PolynomialSum.cpp.
References polynomialSum_m.
void polynomial::PolynomialSum::differentiateX | ( | ) |
Differentiate each term wrt x
Definition at line 55 of file PolynomialSum.cpp.
References polynomialSum_m.
|
inline |
Evaluate polynomial in term p at the point (x, s)
If p is outside list range zero is returned
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.
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
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().
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
p | -> Term index, starting with term 0 |
Definition at line 123 of file PolynomialSum.cpp.
References polynomialSum_m.
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
p | -> Term index, starting with term 0 |
Definition at line 96 of file PolynomialSum.cpp.
References polynomialSum_m.
void polynomial::PolynomialSum::multiplyPolynomial | ( | const TwoPolynomial & | poly | ) |
Multiply term with input polynomial
poly | -> Polynomial to be multiplied with this polynomial |
Definition at line 81 of file PolynomialSum.cpp.
References polynomialSum_m.
|
inline |
Returns number of terms in the sum
Definition at line 136 of file PolynomialSum.h.
References polynomialSum_m.
PolynomialSum & polynomial::PolynomialSum::operator= | ( | const PolynomialSum & | sum | ) |
Assigment operator
Definition at line 50 of file PolynomialSum.cpp.
References polynomialSum_m, and sum().
void polynomial::PolynomialSum::printPolynomial | ( | ) | const |
Print polynomial, for internal debugging
Definition at line 87 of file PolynomialSum.cpp.
References polynomialSum_m.
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
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().
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.
void polynomial::PolynomialSum::truncate | ( | const std::size_t & | truncateOrder | ) |
Truncate series in x at truncateOrder
truncateOrder | -> Highest power of x after truncation |
Definition at line 105 of file PolynomialSum.cpp.
References polynomialSum_m.
|
private |
Definition at line 132 of file PolynomialSum.h.
Referenced by addPolynomial(), differentiateS(), differentiateX(), evaluatePolynomial(), getdSfactors(), isPolynomialZero(), multiplyPolynomial(), numberOfTerms(), operator=(), PolynomialSum(), printPolynomial(), putSumTogether(), sortTerms(), and truncate().