MADNESS
0.10.1
|
Array for storing coefficients of a polynomial of three variables with specified degree. More...
#include <polynomial.h>
Public Member Functions | |
PolynomialCoeffs ()=delete | |
PolynomialCoeffs (const double constant, const double x, const double y, const double z) | |
Create a linear function with the specified coefficients. More... | |
PolynomialCoeffs (const unsigned N) | |
Create a polynomial of degree N. More... | |
unsigned | get_degree () const |
Get the degree of the polynomial. More... | |
double | operator() (const std::array< double, 3 > &pt) const |
Evaluate the polynomial at the specified point. More... | |
PolynomialCoeffs | operator* (const double c) const |
Multiply a polynomial by a constant value. More... | |
PolynomialCoeffs | operator* (const PolynomialCoeffs &rhs) const |
Multiply two polynomials together. More... | |
PolynomialCoeffs & | operator*= (const double c) |
Scale the polynomial by a constant. More... | |
PolynomialCoeffs | operator+ (const PolynomialCoeffs &rhs) const |
Add two polynomials together. More... | |
PolynomialCoeffs & | operator+= (const PolynomialCoeffs &rhs) |
Adds another polynomial to this one. More... | |
double & | operator[] (const std::array< unsigned, 3 > &pows) |
Access the coefficient for the specified term. More... | |
double | operator[] (const std::array< unsigned, 3 > &pows) const |
Access the coefficient for the specified term. More... | |
PolynomialCoeffs | pow (const unsigned j) const |
Expands a linear polynomial raised to a power. More... | |
Static Protected Member Functions | |
static unsigned | polyIndex (const std::array< unsigned, 3 > &pows) |
Gets the array index for the coefficient of a particular term. More... | |
Protected Attributes | |
std::vector< double > | coeffs |
Array storing the coefficients. More... | |
unsigned | degree |
The degree of the polynomial. More... | |
Array for storing coefficients of a polynomial of three variables with specified degree.
The general polynomial of three variables is written as
where . This data structure stores the coefficients in a vector and provides access routines in terms of the exponents , , and .
|
delete |
|
inline |
Create a linear function with the specified coefficients.
[in] | constant | The constant term. |
[in] | x | The coefficient on x. |
[in] | y | The coefficient on y. |
[in] | z | The coefficient on z. |
References coeffs, constant(), and polyIndex().
|
inline |
|
inline |
Get the degree of the polynomial.
References degree.
Referenced by slymer::PrimitiveGaussian::PrimitiveGaussian().
double slymer::PolynomialCoeffs::operator() | ( | const std::array< double, 3 > & | pt | ) | const |
Evaluate the polynomial at the specified point.
[in] | pt | The point at which the polynomial is evaluated. |
References coeffs, degree, k, polyIndex(), and pow().
PolynomialCoeffs slymer::PolynomialCoeffs::operator* | ( | const double | c | ) | const |
PolynomialCoeffs slymer::PolynomialCoeffs::operator* | ( | const PolynomialCoeffs & | rhs | ) | const |
Multiply two polynomials together.
*this is one of the polynomials.
[in] | rhs | The other polynomial. |
References degree, and operator[]().
PolynomialCoeffs & slymer::PolynomialCoeffs::operator*= | ( | const double | c | ) |
PolynomialCoeffs slymer::PolynomialCoeffs::operator+ | ( | const PolynomialCoeffs & | rhs | ) | const |
PolynomialCoeffs & slymer::PolynomialCoeffs::operator+= | ( | const PolynomialCoeffs & | rhs | ) |
Adds another polynomial to this one.
[in] | rhs | The other polynomial. |
References coeffs, degree, and madness::swap().
|
inline |
Access the coefficient for the specified term.
[in] | pows | The powers of x, y, and z for this term. |
References coeffs, and polyIndex().
Referenced by operator*().
|
inline |
Access the coefficient for the specified term.
[in] | pows | The powers of x, y, and z for this term. |
References coeffs, and polyIndex().
|
inlinestaticprotected |
Gets the array index for the coefficient of a particular term.
Terms of degree 0 are stored before those of degree 1, etc.
Within a particular degree, think of the problem in the combinatorial "stars and bars" idea: there are n stars and two bars dividing them into three parts. (Each part corresponds to the number of x, y, or z factors.) The first array element will be bars in the 0 and 1 positions, then 0 and 2, ..., 0 and n+1, then 1 and 2, etc.
[in] | pows | The powers of x, y, and z for this term. |
Referenced by PolynomialCoeffs(), operator()(), and operator[]().
PolynomialCoeffs slymer::PolynomialCoeffs::pow | ( | const unsigned | j | ) | const |
Expands a linear polynomial raised to a power.
Essentially expands the polynomial
into a new PolynomialCoeffs object. That is, output[{{p,q,r}}] is the coefficient on the term.
This function requires multinomial coefficients, which involve factorials. We assume that the arguments to the factorials will not be large and hard-code small values. An error will be thrown if the maximum value is exceeded.
std::runtime_error | if the polynomial does not have degree 1. |
[in] | j | The exponent of the expansion. |
References degree.
Referenced by operator()().
|
protected |
Array storing the coefficients.
For a given degree n, there are monomials. The total array thus has terms. The array stores all terms with degree 0, then degree 1, then degree 2, etc.
Referenced by PolynomialCoeffs(), operator()(), operator*(), operator*=(), operator+(), operator+=(), and operator[]().
|
protected |
The degree of the polynomial.
Referenced by get_degree(), operator()(), operator*(), operator+(), operator+=(), and pow().