Basic Image AlgorithmS Library
2.8.0
|
base class for solving polynomial equations More...
#include <MathAlgo/PolynomialSolve.hh>
Public Member Functions | |
void | AddDebugLevel (const long int lv) |
void | AddDebugLevel (const std::string &name) |
int | Analytic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solves polynomial of arbitrary order n<=4 analytically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted. More... | |
int | Analytic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solves polynomial of arbitrary order n<=3 analytically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted. More... | |
void | CalCoefficients (const std::vector< POLYNOMIALSOLVE_TYPE > &sol, std::vector< POLYNOMIALSOLVE_TYPE > &coeff) |
inverse function, calculates coefficients from the solutions More... | |
void | CheckCoefficients (std::vector< POLYNOMIALSOLVE_TYPE > &coeff, double eps=DBL_EPSILON) |
removes leading zeros in coefficients More... | |
int | Cubic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solve a polynomial of degree 3 coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[3] != 0.0 is asserted returns the number of real solutions More... | |
int | Cubic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solve a polynomial of degree 3 coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[3] != 0.0 is asserted returns the number of real solutions More... | |
bool | DebugLevelIsSet (const long int lv) const |
bool | DebugLevelIsSet (const std::string &name) const |
POLYNOMIALSOLVE_TYPE | EvaluatePolynomial (const POLYNOMIALSOLVE_TYPE x, const std::vector< POLYNOMIALSOLVE_TYPE > &coeff) const |
numerically robust way to evaluate a polynomial at position x, uses Horner scheme (same principle as in gsl_poly_eval) More... | |
int | FitPolynomial (const unsigned int degree, const std::vector< double > &x, const std::vector< double > &y, std::vector< double > &coefficients) |
given locations x and measurements y=f(x) approximate f by a polynomial of arbitrary degree and return coefficients More... | |
int | GetDebugLevel () const |
std::ostream & | GetDebugStream () const |
void | GetDebugStream (std::ostream &os) const |
int | GetNumberOfRealSolutions (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff) |
determine number of real solutions of polynomial More... | |
bool | HasRealSolution (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff) |
determine whether the polynomial has a solution in IR More... | |
int | Linear (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solve a polynomial of degree 1 coeff[1]*x+coeff[0]=0 coeff[1] != 0.0 is asserted returns the number of real solutions (always 1) More... | |
int | Linear (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solve a polynomial of degree 1 coeff[1]*x+coeff[0]=0 coeff[1] != 0.0 is asserted returns the number of complex solutions (always 1) More... | |
long int | Name2DebugLevel (const std::string &name) const |
looks up a debuglevel in the internal map, returns 0 if not found More... | |
long int | NewDebugLevel (const std::string &name) |
creates a new debuglevel More... | |
int | NonLinearRefine (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
does a non linear refinement using Powel from minpack for real roots (non imaginary) only More... | |
int | NonLinearRefine (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
does a non linear refinement using Powel from minpack for real roots (non imaginary) only More... | |
int | Numeric (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solves polynomial of arbitrary order n numerically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted. More... | |
int | Numeric (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solves polynomial of arbitrary order n numerically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted. More... | |
PolynomialSolve () | |
void | PrintDebugLevel (std::ostream &os=std::cout) const |
int | Quadratic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solve a polynomial of degree 2 coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[2] != 0.0 is asserted returns the number of real solutions (0, 1 or 2) More... | |
int | Quadratic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solve a polynomial of degree 2 coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[2] != 0.0 is asserted returns the number of complex solutions (alway 2) More... | |
int | Quartic (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solve a polynomial of degree 4 coeff[4]*x^4+coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[4] != 0.0 is asserted returns the number of real solutions More... | |
void | RemoveDebugLevel (const long int lv) |
void | RemoveDebugLevel (const std::string &name) |
void | SetDebugLevel (const long int lv) |
void | SetDebugLevel (const std::string &name) |
void | SetDebugStream (const std::ostream &os) |
void | ShowDebugLevel (std::ostream &os=std::cout) const |
prints all internally known debuglevels More... | |
int | Solve (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
solve polynomial of arbitrary order n coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted Uses analytical solution if n<=4 More... | |
int | Solve (const std::vector< POLYNOMIALSOLVE_TYPE > &coeff, std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > &sol) |
solve polynomial of arbitrary order n coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted. More... | |
~PolynomialSolve () | |
Static Public Member Functions | |
static long int | GetGlobalDebugLevel () |
static void | SetGlobalDebugLevel (long int lev) |
Public Attributes | |
double * | PowellCoeff_ |
int | PowellCoeffNum_ |
Protected Member Functions | |
POLYNOMIALSOLVE_TYPE | _GetCoeff (int order, int b, const std::vector< POLYNOMIALSOLVE_TYPE > &sol) |
helper function for CalCoefficients More... | |
long | ConsumeNextFreeDebuglevel_ () |
returns the next available debuglevel More... | |
Protected Attributes | |
long int | _liDebugLevel |
long int | _liNextDebugLevel |
new concept, debuglevel are managed here in the debug class More... | |
std::map< std::string, long int > | _String2Debuglevel |
Static Protected Attributes | |
static std::ostream | _zDebugStream |
static long int | GlobalDebugLevel = 0 |
base class for solving polynomial equations
Definition at line 50 of file PolynomialSolve.hh.
|
inline |
Definition at line 54 of file PolynomialSolve.hh.
|
inline |
Definition at line 55 of file PolynomialSolve.hh.
|
protected |
helper function for CalCoefficients
Definition at line 664 of file PolynomialSolve.cpp.
|
inlineinherited |
Definition at line 355 of file Debug.hh.
Referenced by BIAS::GLProjectionParametersBase::AddDebugLevel(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::FilterBase< InputStorageType, OutputStorageType >::FilterBase(), BIAS::ShowCamWxVideoSourceFactory::OpenDevice(), and BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph().
|
inlineinherited |
int PolynomialSolve::Analytic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solves polynomial of arbitrary order n<=4 analytically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted.
Definition at line 224 of file PolynomialSolve.cpp.
Referenced by BIAS::FMatrixEstimation::SevenPoint().
int PolynomialSolve::Analytic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solves polynomial of arbitrary order n<=3 analytically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted.
Definition at line 255 of file PolynomialSolve.cpp.
void PolynomialSolve::CalCoefficients | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | sol, |
std::vector< POLYNOMIALSOLVE_TYPE > & | coeff | ||
) |
inverse function, calculates coefficients from the solutions
Definition at line 650 of file PolynomialSolve.cpp.
void PolynomialSolve::CheckCoefficients | ( | std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
double | eps = DBL_EPSILON |
||
) |
removes leading zeros in coefficients
Definition at line 624 of file PolynomialSolve.cpp.
Referenced by BIAS::Triangulation::CorrectCorrespondences(), BIAS::Conic2D::IntersectsCircle(), and BIAS::FMatrixEstimation::SevenPoint().
|
inlineprotectedinherited |
int PolynomialSolve::Cubic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solve a polynomial of degree 3 coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[3] != 0.0 is asserted returns the number of real solutions
Definition at line 408 of file PolynomialSolve.cpp.
int PolynomialSolve::Cubic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solve a polynomial of degree 3 coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[3] != 0.0 is asserted returns the number of real solutions
Definition at line 508 of file PolynomialSolve.cpp.
|
inlineinherited |
Definition at line 341 of file Debug.hh.
Referenced by BIAS::GenSynthMatches::_AddUniformDistributedOutliers(), BIAS::GenSynthMatches::_CreateCamMovement(), BIAS::GenSynthMatches::_CreateStatic2DPoints(), BIAS::UnscentedTransform::ComputeSigmaPoints_(), BIAS::Triangulation::CorrectCorrespondences(), BIAS::GenSynthMatches::GetGTNormalizedF(), BIAS::MonteCarloTransform::GetSamples_(), and BIAS::MonteCarloTransform::Transform().
|
inlineinherited |
|
inline |
numerically robust way to evaluate a polynomial at position x, uses Horner scheme (same principle as in gsl_poly_eval)
Definition at line 244 of file PolynomialSolve.hh.
Referenced by BIAS::Triangulation::CorrectCorrespondences(), BIAS::ProjectionParametersPerspectiveDepth::DistortReflectivity(), BIAS::ProjectionParametersSpherical::InitAngleCorrFromPoly(), NonLinearRefine(), and BIAS::ProjectionParametersPerspectiveDepth::UnDistortReflectivity().
int PolynomialSolve::FitPolynomial | ( | const unsigned int | degree, |
const std::vector< double > & | x, | ||
const std::vector< double > & | y, | ||
std::vector< double > & | coefficients | ||
) |
given locations x and measurements y=f(x) approximate f by a polynomial of arbitrary degree and return coefficients
least squares approximation of parameters a_i of a polynomial which minimizes (a_0 + a_1x + a_2x^2 + ... + a_degree x^degree - y)^2 summed over all pairs (x;y), where i runs from 0 to degree
Definition at line 803 of file PolynomialSolve.cpp.
References BIAS::LevenbergMarquardt(), and BIAS::SVD::Solve().
Referenced by BIAS::ProjectionParametersSpherical::EstimateDistortionPolynomial(), BIAS::ProjectionParametersSpherical::EstimateUndistortionPolynomial(), and BIAS::ProjectionParametersPerspectiveDepth::SetReflectivityNormalizationParameters().
|
inlineinherited |
Definition at line 332 of file Debug.hh.
Referenced by BIAS::listenthread(), BIAS::Image< StorageType >::operator=(), and BIAS::ImageBase::operator=().
|
inlineinherited |
|
inlineinherited |
|
inlinestaticinherited |
int PolynomialSolve::GetNumberOfRealSolutions | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff | ) |
determine number of real solutions of polynomial
Definition at line 695 of file PolynomialSolve.cpp.
|
inline |
determine whether the polynomial has a solution in IR
Definition at line 198 of file PolynomialSolve.hh.
Referenced by BIAS::Conic2D::IntersectsCircle().
int PolynomialSolve::Linear | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solve a polynomial of degree 1 coeff[1]*x+coeff[0]=0 coeff[1] != 0.0 is asserted returns the number of real solutions (always 1)
Definition at line 289 of file PolynomialSolve.cpp.
int PolynomialSolve::Linear | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solve a polynomial of degree 1 coeff[1]*x+coeff[0]=0 coeff[1] != 0.0 is asserted returns the number of complex solutions (always 1)
Definition at line 308 of file PolynomialSolve.cpp.
|
inlineinherited |
|
inlineinherited |
creates a new debuglevel
Definition at line 474 of file Debug.hh.
Referenced by BIAS::COSAC< SolutionType >::COSAC(), BIAS::ProjectionParametersPerspectiveDepth::Init(), BIAS::MonteCarloTransform::MonteCarloTransform(), BIAS::PMatrixEstimation::PMatrixEstimation(), BIAS::PreemptiveRANSAC< SolutionType >::PreemptiveRANSAC(), BIAS::RANSACPreKnowledge< SolutionType >::RANSACPreKnowledge(), BIAS::ROI::ROI(), BIAS::RotationAveraging::RotationAveraging(), BIAS::SceneOpenSceneGraph::SceneOpenSceneGraph(), BIAS::ThreeDOutOpenSceneGraph::ThreeDOutOpenSceneGraph(), BIAS::Triangulation::Triangulation(), and BIAS::UnscentedTransform::UnscentedTransform().
int PolynomialSolve::NonLinearRefine | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
does a non linear refinement using Powel from minpack for real roots (non imaginary) only
Definition at line 725 of file PolynomialSolve.cpp.
References BIAS::Powell().
Referenced by BIAS::Triangulation::CorrectCorrespondences().
int PolynomialSolve::NonLinearRefine | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
does a non linear refinement using Powel from minpack for real roots (non imaginary) only
Definition at line 760 of file PolynomialSolve.cpp.
References EvaluatePolynomial(), and BIAS::Powell().
int PolynomialSolve::Numeric | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solves polynomial of arbitrary order n numerically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted.
Definition at line 115 of file PolynomialSolve.cpp.
Referenced by BIAS::Triangulation::CorrectCorrespondences().
int PolynomialSolve::Numeric | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solves polynomial of arbitrary order n numerically coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted.
Definition at line 135 of file PolynomialSolve.cpp.
References BIAS::Equal(), and BIAS::LaguerreSolver::Solve().
|
inlineinherited |
int PolynomialSolve::Quadratic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solve a polynomial of degree 2 coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[2] != 0.0 is asserted returns the number of real solutions (0, 1 or 2)
Definition at line 322 of file PolynomialSolve.cpp.
int PolynomialSolve::Quadratic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solve a polynomial of degree 2 coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[2] != 0.0 is asserted returns the number of complex solutions (alway 2)
Definition at line 375 of file PolynomialSolve.cpp.
int PolynomialSolve::Quartic | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solve a polynomial of degree 4 coeff[4]*x^4+coeff[3]*x^3+coeff[2]*x^2+coeff[1]*x+coeff[0]=0 coeff[4] != 0.0 is asserted returns the number of real solutions
@author koeser, woelk 08/2004
ATTENTION: under certain circumstances Quartic() doesn't seem to work correctly and does not return any solutions. EXAMPLE : for the following polynom coeff[0]=-5.3812376413659608331840900064; coeff[1]=21.5206398747126961268349987222; coeff[2]=-32.2795617934279306382450158708; coeff[3]=21.5221584472618552297262795037; coeff[4]=-5.38199880981732103890635698917;
Quartic() does not return any roots. Expected roots are: 0.999231378314545 + 0.030940956057273i 0.999231378314545 - 0.030940956057273i 1.004259532432780 + 0.000000000000000i 0.996476651583676 + 0.000000000000000i
Definition at line 542 of file PolynomialSolve.cpp.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Definition at line 318 of file Debug.hh.
Referenced by BIAS::ShowCamWxVideoSourceFactory::CreateBumbleBee(), BIAS::ShowCamWxVideoSourceFactory::CreateDCAM(), BIAS::VideoSource_MDcam::ScanBus(), BIAS::GLProjectionParametersBase::SetDebugLevel(), BIAS::VideoSource_Disk::VideoSource_Disk(), BIAS::VideoSource_DV2::VideoSource_DV2(), BIAS::VideoSource_DV::VideoSource_DV_Internal_Init_(), and BIAS::VideoSource_V4L::VideoSource_V4L().
|
inlineinherited |
|
inlineinherited |
|
inlinestaticinherited |
|
inlineinherited |
int PolynomialSolve::Solve | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< POLYNOMIALSOLVE_TYPE > & | sol | ||
) |
solve polynomial of arbitrary order n coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted Uses analytical solution if n<=4
Definition at line 47 of file PolynomialSolve.cpp.
Referenced by BIAS::Conic2D::IntersectConicProper(), and BIAS::ProjectionParametersPerspectiveDepth::UnDistortDepth().
int PolynomialSolve::Solve | ( | const std::vector< POLYNOMIALSOLVE_TYPE > & | coeff, |
std::vector< std::complex< POLYNOMIALSOLVE_TYPE > > & | sol | ||
) |
solve polynomial of arbitrary order n coeff[n]x^n+...+coeff[2]x^2+coeff[1]x+coeff[0]=0 coeff[n]!=0.0 is asserted.
Uses analytical solution if n<=3
Definition at line 87 of file PolynomialSolve.cpp.
|
protectedinherited |
Definition at line 510 of file Debug.hh.
Referenced by BIAS::Debug::operator=(), and BIAS::ImageBase::operator=().
|
protectedinherited |
new concept, debuglevel are managed here in the debug class
Definition at line 516 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
protectedinherited |
Definition at line 517 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |
Definition at line 511 of file Debug.hh.
Referenced by BIAS::Debug::operator=().
|
staticprotectedinherited |
double* BIAS::PolynomialSolve::PowellCoeff_ |
Definition at line 229 of file PolynomialSolve.hh.
int BIAS::PolynomialSolve::PowellCoeffNum_ |
Definition at line 228 of file PolynomialSolve.hh.