NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nc::polynomial::Poly1d< dtype > Class Template Reference

#include <Poly1d.hpp>

Public Member Functions

 Poly1d ()=default
 
 Poly1d (const NdArray< dtype > &inValues, IsRoots isRoots=IsRoots::NO)
 
double area (double a, double b) const
 
template<typename dtypeOut >
Poly1d< dtypeOut > astype () const
 
NdArray< dtype > coefficients () const
 
Poly1d< dtype > deriv () const
 
NdArray< dtype > eval (const NdArray< dtype > &xValues) const noexcept
 
dtype eval (dtype xValue) const noexcept
 
Poly1d< double > integ () const
 
NdArray< dtype > operator() (const NdArray< dtype > &xValues) const noexcept
 
dtype operator() (dtype inValue) const noexcept
 
Poly1d< dtype > operator* (const Poly1d< dtype > &inOtherPoly) const
 
Poly1d< dtype > & operator*= (const Poly1d< dtype > &inOtherPoly)
 
Poly1d< dtype > operator+ (const Poly1d< dtype > &inOtherPoly) const
 
Poly1d< dtype > & operator+= (const Poly1d< dtype > &inOtherPoly)
 
Poly1d< dtype > operator- (const Poly1d< dtype > &inOtherPoly) const
 
Poly1d< dtype > & operator-= (const Poly1d< dtype > &inOtherPoly)
 
Poly1d< dtype > operator^ (uint32 inPower) const
 
Poly1d< dtype > & operator^= (uint32 inPower)
 
uint32 order () const noexcept
 
void print () const
 
std::string str () const
 

Static Public Member Functions

static Poly1d< double > fit (const NdArray< dtype > &xValues, const NdArray< dtype > &yValues, const NdArray< dtype > &weights, uint8 polyOrder)
 
static Poly1d< double > fit (const NdArray< dtype > &xValues, const NdArray< dtype > &yValues, uint8 polyOrder)
 

Friends

std::ostream & operator<< (std::ostream &inOStream, const Poly1d< dtype > &inPoly)
 

Detailed Description

template<typename dtype>
class nc::polynomial::Poly1d< dtype >

A one-dimensional polynomial class. A convenience class, used to encapsulate "natural" operations on polynomials

Constructor & Destructor Documentation

◆ Poly1d() [1/2]

template<typename dtype >
nc::polynomial::Poly1d< dtype >::Poly1d ( )
default

Default Constructor (not very usefull, but needed for other containers.

◆ Poly1d() [2/2]

template<typename dtype >
nc::polynomial::Poly1d< dtype >::Poly1d ( const NdArray< dtype > &  inValues,
IsRoots  isRoots = IsRoots::NO 
)
inline

Constructor

Parameters
inValues(polynomial coefficients in ascending order of power if second input is false, polynomial roots if second input is true)
isRoots

Member Function Documentation

◆ area()

template<typename dtype >
double nc::polynomial::Poly1d< dtype >::area ( double  a,
double  b 
) const
inline

Returns the area under the curve between the two bounds

Parameters
athe lower bound
bthe upper bound
Returns
double

◆ astype()

template<typename dtype >
template<typename dtypeOut >
Poly1d< dtypeOut > nc::polynomial::Poly1d< dtype >::astype ( ) const
inline

Returns a copy of the polynomial of the new type

Returns
Poly1d

◆ coefficients()

template<typename dtype >
NdArray< dtype > nc::polynomial::Poly1d< dtype >::coefficients ( ) const
inline

Returns the Poly1d coefficients

Returns
NdArray

◆ deriv()

template<typename dtype >
Poly1d< dtype > nc::polynomial::Poly1d< dtype >::deriv ( ) const
inline

Takes the derivative of the polynomial

Returns
Poly1d

◆ eval() [1/2]

template<typename dtype >
NdArray< dtype > nc::polynomial::Poly1d< dtype >::eval ( const NdArray< dtype > &  xValues) const
inlinenoexcept

Evaluates the Poly1D object for the input value

Parameters
xValues
Returns
predicted yValues

◆ eval() [2/2]

template<typename dtype >
dtype nc::polynomial::Poly1d< dtype >::eval ( dtype  xValue) const
inlinenoexcept

Evaluates the Poly1D object for the input value

Parameters
xValue
Returns
predicted yValue

◆ fit() [1/2]

template<typename dtype >
static Poly1d< double > nc::polynomial::Poly1d< dtype >::fit ( const NdArray< dtype > &  xValues,
const NdArray< dtype > &  yValues,
const NdArray< dtype > &  weights,
uint8  polyOrder 
)
inlinestatic

Polynomial linear least squares regression: Ax = b

Parameters
xValuesthe x measurements [1, n] or [n, 1] array
yValuesthe y measurements [n, 1] array
weightsthe measurement weights [1, n] or [n, 1] array
polyOrderthe order of the poly nomial to fit
Returns
Poly1d

◆ fit() [2/2]

template<typename dtype >
static Poly1d< double > nc::polynomial::Poly1d< dtype >::fit ( const NdArray< dtype > &  xValues,
const NdArray< dtype > &  yValues,
uint8  polyOrder 
)
inlinestatic

Polynomial linear least squares regression: Ax = b

Parameters
xValuesthe x measurements [1, n] or [n, 1] array
yValuesthe y measurements [n, 1] array
polyOrderthe order of the poly nomial to fit
Returns
Poly1d

◆ integ()

template<typename dtype >
Poly1d< double > nc::polynomial::Poly1d< dtype >::integ ( ) const
inline

Calculates the integral of the polynomial

Returns
Poly1d

◆ operator()() [1/2]

template<typename dtype >
NdArray< dtype > nc::polynomial::Poly1d< dtype >::operator() ( const NdArray< dtype > &  xValues) const
inlinenoexcept

Evaluates the Poly1D object for the input value

Parameters
xValues
Returns
predicted yValues

◆ operator()() [2/2]

template<typename dtype >
dtype nc::polynomial::Poly1d< dtype >::operator() ( dtype  inValue) const
inlinenoexcept

Evaluates the Poly1D object for the input value

Parameters
inValue
Returns
dtype scalar

◆ operator*()

template<typename dtype >
Poly1d< dtype > nc::polynomial::Poly1d< dtype >::operator* ( const Poly1d< dtype > &  inOtherPoly) const
inline

Multiplies the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator*=()

template<typename dtype >
Poly1d< dtype > & nc::polynomial::Poly1d< dtype >::operator*= ( const Poly1d< dtype > &  inOtherPoly)
inline

Multiplies the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator+()

template<typename dtype >
Poly1d< dtype > nc::polynomial::Poly1d< dtype >::operator+ ( const Poly1d< dtype > &  inOtherPoly) const
inline

Adds the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator+=()

template<typename dtype >
Poly1d< dtype > & nc::polynomial::Poly1d< dtype >::operator+= ( const Poly1d< dtype > &  inOtherPoly)
inline

Adds the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator-()

template<typename dtype >
Poly1d< dtype > nc::polynomial::Poly1d< dtype >::operator- ( const Poly1d< dtype > &  inOtherPoly) const
inline

Subtracts the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator-=()

template<typename dtype >
Poly1d< dtype > & nc::polynomial::Poly1d< dtype >::operator-= ( const Poly1d< dtype > &  inOtherPoly)
inline

Subtracts the two Poly1d objects

Parameters
inOtherPoly
Returns
Poly1d

◆ operator^()

template<typename dtype >
Poly1d< dtype > nc::polynomial::Poly1d< dtype >::operator^ ( uint32  inPower) const
inline

Raise the Poly1d to an integer power

Parameters
inPower
Returns
Poly1d

◆ operator^=()

template<typename dtype >
Poly1d< dtype > & nc::polynomial::Poly1d< dtype >::operator^= ( uint32  inPower)
inline

Raise the Poly1d to an integer power

Parameters
inPower
Returns
Poly1d

◆ order()

template<typename dtype >
uint32 nc::polynomial::Poly1d< dtype >::order ( ) const
inlinenoexcept

Returns the order of the Poly1d

Returns
NdArray

◆ print()

template<typename dtype >
void nc::polynomial::Poly1d< dtype >::print ( ) const
inline

Prints the string representation of the Poly1d object to the console

◆ str()

template<typename dtype >
std::string nc::polynomial::Poly1d< dtype >::str ( ) const
inline

Converts the polynomial to a string representation

Returns
Poly1d

Friends And Related Function Documentation

◆ operator<<

template<typename dtype >
std::ostream & operator<< ( std::ostream &  inOStream,
const Poly1d< dtype > &  inPoly 
)
friend

io operator for the Poly1d class

Parameters
inOStream
inPoly
Returns
std::ostream

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