OpenGV
A library for solving calibrated central and non-central geometric vision problems
Sturm.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Author: Laurent Kneip *
3  * Contact: kneip.laurent@gmail.com *
4  * License: Copyright (c) 2013 Laurent Kneip, ANU. All rights reserved. *
5  * *
6  * Redistribution and use in source and binary forms, with or without *
7  * modification, are permitted provided that the following conditions *
8  * are met: *
9  * * Redistributions of source code must retain the above copyright *
10  * notice, this list of conditions and the following disclaimer. *
11  * * Redistributions in binary form must reproduce the above copyright *
12  * notice, this list of conditions and the following disclaimer in the *
13  * documentation and/or other materials provided with the distribution. *
14  * * Neither the name of ANU nor the names of its contributors may be *
15  * used to endorse or promote products derived from this software without *
16  * specific prior written permission. *
17  * *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"*
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
21  * ARE DISCLAIMED. IN NO EVENT SHALL ANU OR THE CONTRIBUTORS BE LIABLE *
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
25  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *
28  * SUCH DAMAGE. *
29  ******************************************************************************/
30 
37 #ifndef OPENGV_STURM_HPP_
38 #define OPENGV_STURM_HPP_
39 
40 #include <memory>
41 #include <stdlib.h>
42 #include <vector>
43 #include <list>
44 #include <Eigen/Eigen>
45 #include <Eigen/src/Core/util/DisableStupidWarnings.h>
46 
50 namespace opengv
51 {
55 namespace math
56 {
57 
58 class Bracket
59 {
60 public:
61  typedef std::shared_ptr<Bracket> Ptr;
62  typedef std::shared_ptr<const Bracket> ConstPtr;
63 
64  Bracket( double lowerBound, double upperBound );
65  Bracket( double lowerBound, double upperBound, size_t changes, bool setUpperBoundChanges );
66  virtual ~Bracket();
67 
68  bool dividable( double eps ) const;
69  void divide( std::list<Ptr> & brackets ) const;
70  double lowerBound() const;
71  double upperBound() const;
72  bool lowerBoundChangesComputed() const;
73  bool upperBoundChangesComputed() const;
74  void setLowerBoundChanges( size_t changes );
75  void setUpperBoundChanges( size_t changes );
76  size_t numberRoots() const;
77 
78 private:
79  double _lowerBound;
80  double _upperBound;
81  bool _lowerBoundChangesComputed;
82  bool _upperBoundChangesComputed;
83  size_t _lowerBoundChanges;
84  size_t _upperBoundChanges;
85 };
86 
91 class Sturm
92 {
93 
94 public:
95  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
97  typedef std::pair<double,double> bracket_t;
98 
103  Sturm( const Eigen::MatrixXd & p );
108  Sturm( const std::vector<double> & p );
112  virtual ~Sturm();
113 
114  void findRoots2( std::vector<double> & roots, double eps_x = 0.001, double eps_val = 0.001 );
119  std::vector<double> findRoots();
124  void bracketRoots( std::vector<double> & roots, double eps = -1.0 );
130  size_t evaluateChain( double bound );
136  size_t evaluateChain2( double bound );
142  double computeLagrangianBound();
143 
144 private:
151  void computeNegatedRemainder(
152  const Eigen::MatrixXd & p1,
153  const Eigen::MatrixXd & p2,
154  Eigen::MatrixXd & r );
155 
157  Eigen::MatrixXd _C;
159  size_t _dimension;
160 };
161 
162 }
163 }
164 
165 #endif /* OPENGV_STURM_HPP_ */
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef std::pair< double, double > bracket_t
Definition: Sturm.hpp:97
The namespace of this library.
Definition: AbsoluteAdapterBase.hpp:47
Definition: Sturm.hpp:58
Definition: Sturm.hpp:91