Thunderbots Project
Loading...
Searching...
No Matches
Polynomial1d Class Reference

#include <polynomial1d.h>

Classes

struct  Constraint
 

Public Member Functions

 Polynomial1d ()
 
 Polynomial1d (const std::vector< double > &coeffs)
 
 Polynomial1d (const std::initializer_list< double > &coeffs)
 
 Polynomial1d (const std::vector< Constraint > constraints)
 
double getCoeff (unsigned int order) const
 
void setCoeff (unsigned int order, double coeff)
 
unsigned int getOrder () const
 
double valueAt (double val) const
 

Detailed Description

Polynomial1d is a representation of a polynomial that can calculate values at a given input

Constructor & Destructor Documentation

◆ Polynomial1d() [1/4]

Polynomial1d ( )
explicit

Construct a zero polynomial

◆ Polynomial1d() [2/4]

Polynomial1d ( const std::vector< double > &  coeffs)
explicit

Construct a polynomial from coefficients of the form coeffs[0] + coeffs[1]*x^(1) + ... + coeffs[n-1]*x^(n-1)

Parameters
coeffscoefficients of the polynomial

◆ Polynomial1d() [3/4]

Polynomial1d ( const std::initializer_list< double > &  coeffs)
explicit

Construct a polynomial from coefficients of the form coeffs[0] + coeffs[1]*x^(1) + ... + coeffs[n-1]*x^(n-1)

Parameters
coeffscoefficients of the polynomial

◆ Polynomial1d() [4/4]

Polynomial1d ( const std::vector< Constraint constraints)
explicit

Construct a polynomial from a series of constraints (input/output pairs)

Parameters
constraintsA series of pairs, where each pair is of the form {input, output}, indicating the output that the created polynomial must have for a given input.
constraintsA series of constraints that define the polynomial. Note that all inputs must be unique, and there must be at least two constraints.
Exceptions
std::invalid_argumentif any two inputs are equal, or if there are less then two constraints

Member Function Documentation

◆ getCoeff()

double getCoeff ( unsigned int  order) const

Returns the coefficient of the term of given order

Parameters
orderthe order of the term
Returns
the coefficient of the term

◆ getOrder()

unsigned int getOrder ( ) const

Returns the order of the Polynomial1d

Returns
the index of the highest order non-zero coefficient

◆ setCoeff()

void setCoeff ( unsigned int  order,
double  coeff 
)

Sets the coefficient of the term of given order

Parameters
orderthe order of the term to set the coefficient
coeffthe coefficient

◆ valueAt()

double valueAt ( double  val) const

Calculates the value of polynomial evaluated at value val

Parameters
valvalue to evaluate polynomial
Returns
value of polynomial evaluated at value val

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