Loading...
Searching...
No Matches
Sturm.hpp
Go to the documentation of this file.
/******************************************************************************
* Author: Laurent Kneip *
* Contact: kneip.laurent@gmail.com *
* License: Copyright (c) 2013 Laurent Kneip, ANU. All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* * Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* * Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* * Neither the name of ANU nor the names of its contributors may be *
* used to endorse or promote products derived from this software without *
* specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"*
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
* ARE DISCLAIMED. IN NO EVENT SHALL ANU OR THE CONTRIBUTORS BE LIABLE *
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
* SUCH DAMAGE. *
******************************************************************************/
#ifndef OPENGV_STURM_HPP_
#define OPENGV_STURM_HPP_
#include <memory>
#include <stdlib.h>
#include <vector>
#include <list>
#include <Eigen/Eigen>
#include <Eigen/src/Core/util/DisableStupidWarnings.h>
namespace opengv
{
namespace math
{
class Bracket
{
public:
typedef std::shared_ptr<Bracket> Ptr;
typedef std::shared_ptr<const Bracket> ConstPtr;
Bracket( double lowerBound, double upperBound );
Bracket( double lowerBound, double upperBound, size_t changes, bool setUpperBoundChanges );
virtual ~Bracket();
bool dividable( double eps ) const;
void divide( std::list<Ptr> & brackets ) const;
double lowerBound() const;
double upperBound() const;
bool lowerBoundChangesComputed() const;
bool upperBoundChangesComputed() const;
void setLowerBoundChanges( size_t changes );
void setUpperBoundChanges( size_t changes );
size_t numberRoots() const;
private:
double _lowerBound;
double _upperBound;
bool _lowerBoundChangesComputed;
bool _upperBoundChangesComputed;
size_t _lowerBoundChanges;
size_t _upperBoundChanges;
};
class Sturm
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
typedef std::pair<double,double> bracket_t;
Sturm( const Eigen::MatrixXd & p );
Sturm( const std::vector<double> & p );
virtual ~Sturm();
void findRoots2( std::vector<double> & roots, double eps_x = 0.001, double eps_val = 0.001 );
std::vector<double> findRoots();
void bracketRoots( std::vector<double> & roots, double eps = -1.0 );
size_t evaluateChain( double bound );
size_t evaluateChain2( double bound );
double computeLagrangianBound();
private:
void computeNegatedRemainder(
const Eigen::MatrixXd & p1,
const Eigen::MatrixXd & p2,
Eigen::MatrixXd & r );
Eigen::MatrixXd _C;
size_t _dimension;
};
}
}
#endif /* OPENGV_STURM_HPP_ */
opengv::math::Sturm::Sturm
Sturm(const Eigen::MatrixXd &p)
Contructor.
opengv::math::Sturm::~Sturm
virtual ~Sturm()
Destructor.
opengv::math::Sturm::Sturm
Sturm(const std::vector< double > &p)
Contructor.
opengv::math::Sturm::findRoots
std::vector< double > findRoots()
Finds the roots of the polynomial.
opengv::math::Sturm::evaluateChain2
size_t evaluateChain2(double bound)
Evaluates the Sturm chain at a single bound.
opengv::math::Sturm::computeLagrangianBound
double computeLagrangianBound()
Composes an initial bracket for all the roots of the polynomial.
opengv::math::Sturm::bracket_t
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::pair< double, double > bracket_t
Definition Sturm.hpp:97
opengv::math::Sturm::bracketRoots
void bracketRoots(std::vector< double > &roots, double eps=-1.0)
Finds brackets for the real roots of the polynomial.
opengv::math::Sturm::evaluateChain
size_t evaluateChain(double bound)
Evaluates the Sturm chain at a single bound.
opengv::math
The namespace of the math tools.
Definition arun.hpp:53
opengv
The namespace of this library.
Definition AbsoluteAdapterBase.hpp:48