isce3 0.25.0
Loading...
Searching...
No Matches
polyfunc.h File Reference

Bunch of 1-D polynomial related functionality similar to numpy.polyfit, etc. More...

#include <cmath>
#include <tuple>
#include <Eigen/Dense>
#include <isce3/core/Poly1d.h>
#include <isce3/except/Error.h>

Go to the source code of this file.

Namespaces

namespace  isce3
 base interpolator is an abstract base class
 

Functions

std::tuple< Eigen::ArrayXd, double, double > isce3::math::polyfit (const Eigen::Ref< const Eigen::ArrayXd > &x, const Eigen::Ref< const Eigen::ArrayXd > &y, int deg, bool center_scale=false)
 Perform 1-D polyfitting for overdertmined problem via LSE using full-pivot House holder QR decomposition.
 
double isce3::math::polyval (const Eigen::Ref< const Eigen::ArrayXd > &coef, double x, double mean=0.0, double std=1.0)
 Perform 1-D polynomial evaluation via Horner's method
 
Eigen::ArrayXd isce3::math::polyval (const Eigen::Ref< const Eigen::ArrayXd > &coef, const Eigen::Ref< const Eigen::ArrayXd > &x, double mean=0.0, double std=1.0)
 Perform 1-D polynomial evaluation.
 
Eigen::ArrayXd isce3::math::polyder (const Eigen::Ref< const Eigen::ArrayXd > &coef, double std=1.0)
 Perform first-derivative of 1-D polynomial coeff in ascending order.
 
isce3::core::Poly1d isce3::math::polyfitObj (const Eigen::Ref< const Eigen::ArrayXd > &x, const Eigen::Ref< const Eigen::ArrayXd > &y, int deg, bool center_scale=false)
 Function to encapsulate polyfitted outputs in isce3 Poly1d object format.
 

Detailed Description

Bunch of 1-D polynomial related functionality similar to numpy.polyfit, etc.

Function Documentation

◆ polyder()

Eigen::ArrayXd isce3::math::polyder ( const Eigen::Ref< const Eigen::ArrayXd > & coef,
double std = 1.0 )

Perform first-derivative of 1-D polynomial coeff in ascending order.

Parameters
[in]coefa vector of polynomial coeff in ascending order.
[in]std(optional) std value or divider for scaling input. Default is 1.0 which implies no scaling.
Returns
derivative of input coeff in ascending order
Exceptions
LengthError,InvalidArgument

◆ polyfit()

std::tuple< Eigen::ArrayXd, double, double > isce3::math::polyfit ( const Eigen::Ref< const Eigen::ArrayXd > & x,
const Eigen::Ref< const Eigen::ArrayXd > & y,
int deg,
bool center_scale = false )

Perform 1-D polyfitting for overdertmined problem via LSE using full-pivot House holder QR decomposition.

See Eigen QR Solver To improve performance and stability, centering and scaling of the input vector will be performed per request. See centering and scaling in Matlab polyfit

Parameters
[in]xeigen vector of input values
[in]yeigen vector of "f(x)" and shall have the same size as "x"
[in]degorder of polynomial.
[in]center_scaleif true will centerize and rescale "x" by its mean and std, respectively, prior to solving for coeffs.
Returns
tuple of three values, a vector of coeff in ascending order, mean of "x", and std of "x". If "center_scale" is false, no centering and scaling is done and thus mean of "x" is set to 0 and std of "x" is set to 1.
Exceptions
LengthError,InvalidArgument

◆ polyfitObj()

isce3::core::Poly1d isce3::math::polyfitObj ( const Eigen::Ref< const Eigen::ArrayXd > & x,
const Eigen::Ref< const Eigen::ArrayXd > & y,
int deg,
bool center_scale = false )

Function to encapsulate polyfitted outputs in isce3 Poly1d object format.

Parameters
[in]xeigen vector of inputs
[in]yeigen vector of "f(x)" and shall have the same size as "x"
[in]degorder of polynomial.
[in]center_scaleif true will centerize and rescale "x" by its mean and std, respectively, prior to solving for coeffs.
Returns
isce3 Poly1d object
Exceptions
LengthError,InvalidArgument
See also
polyfit()

◆ polyval() [1/2]

Eigen::ArrayXd isce3::math::polyval ( const Eigen::Ref< const Eigen::ArrayXd > & coef,
const Eigen::Ref< const Eigen::ArrayXd > & x,
double mean = 0.0,
double std = 1.0 )

Perform 1-D polynomial evaluation.

Parameters
[in]coefa vector of polynomial coeff in ascending order.
[in]xarray of x values to be evaluated.
[in]mean(optional) mean value or offset for centralizing input. Default is 0.0 which implies no centralization.
[in]std(optional) std value or divider for scaling input. Default is 1.0 which implies no scaling.
Returns
array of evaluated values of x.
Exceptions
LengthError,InvalidArgument

◆ polyval() [2/2]

double isce3::math::polyval ( const Eigen::Ref< const Eigen::ArrayXd > & coef,
double x,
double mean = 0.0,
double std = 1.0 )

Perform 1-D polynomial evaluation via Horner's method

Parameters
[in]coefa vector of polynomial coeff in ascending order.
[in]xdesired x value to be evaluated.
[in]mean(optional) mean value or offset for centralizing input. Default is 0.0 which implies no centralization.
[in]std(optional) std value or divider for scaling input. Default is 1.0 which implies no scaling.
Returns
evaluated scalar value at "x".
Exceptions
LengthError,InvalidArgument

Generated for ISCE3.0 by doxygen 1.13.2.