~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/libmv/third_party/ceres/internal/ceres/solver_impl.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Ceres Solver - A fast non-linear least squares minimizer
 
2
// Copyright 2010, 2011, 2012 Google Inc. All rights reserved.
 
3
// http://code.google.com/p/ceres-solver/
 
4
//
 
5
// Redistribution and use in source and binary forms, with or without
 
6
// modification, are permitted provided that the following conditions are met:
 
7
//
 
8
// * Redistributions of source code must retain the above copyright notice,
 
9
//   this list of conditions and the following disclaimer.
 
10
// * Redistributions in binary form must reproduce the above copyright notice,
 
11
//   this list of conditions and the following disclaimer in the documentation
 
12
//   and/or other materials provided with the distribution.
 
13
// * Neither the name of Google Inc. nor the names of its contributors may be
 
14
//   used to endorse or promote products derived from this software without
 
15
//   specific prior written permission.
 
16
//
 
17
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
18
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
19
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
20
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
21
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
22
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
23
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
24
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
25
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
26
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
27
// POSSIBILITY OF SUCH DAMAGE.
 
28
//
 
29
// Author: keir@google.com (Keir Mierle)
 
30
 
 
31
#ifndef CERES_INTERNAL_SOLVER_IMPL_H_
 
32
#define CERES_INTERNAL_SOLVER_IMPL_H_
 
33
 
 
34
#include <string>
 
35
#include <vector>
 
36
#include "ceres/internal/port.h"
 
37
#include "ceres/solver.h"
 
38
 
 
39
namespace ceres {
 
40
namespace internal {
 
41
 
 
42
class Evaluator;
 
43
class LinearSolver;
 
44
class ProblemImpl;
 
45
class Program;
 
46
 
 
47
class SolverImpl {
 
48
 public:
 
49
  // Mirrors the interface in solver.h, but exposes implementation
 
50
  // details for testing internally.
 
51
  static void Solve(const Solver::Options& options,
 
52
                    ProblemImpl* problem_impl,
 
53
                    Solver::Summary* summary);
 
54
 
 
55
  // Create the transformed Program, which has all the fixed blocks
 
56
  // and residuals eliminated, and in the case of automatic schur
 
57
  // ordering, has the E blocks first in the resulting program, with
 
58
  // options.num_eliminate_blocks set appropriately.
 
59
  // If fixed_cost is not NULL, the residual blocks that are removed
 
60
  // are evaluated and the sum of their cost is returned in fixed_cost.
 
61
  static Program* CreateReducedProgram(Solver::Options* options,
 
62
                                       ProblemImpl* problem_impl,
 
63
                                       double* fixed_cost,
 
64
                                       string* error);
 
65
 
 
66
  // Create the appropriate linear solver, taking into account any
 
67
  // config changes decided by CreateTransformedProgram(). The
 
68
  // selected linear solver, which may be different from what the user
 
69
  // selected; consider the case that the remaining elimininated
 
70
  // blocks is zero after removing fixed blocks.
 
71
  static LinearSolver* CreateLinearSolver(Solver::Options* options,
 
72
                                          string* error);
 
73
 
 
74
  // Reorder the parameter blocks in program using the vector
 
75
  // ordering. A return value of true indicates success and false
 
76
  // indicates an error was encountered whose cause is logged to
 
77
  // LOG(ERROR).
 
78
  static bool ApplyUserOrdering(const ProblemImpl& problem_impl,
 
79
                                vector<double*>& ordering,
 
80
                                Program* program,
 
81
                                string* error);
 
82
 
 
83
  // Reorder the residuals for program, if necessary, so that the
 
84
  // residuals involving each E block occur together. This is a
 
85
  // necessary condition for the Schur eliminator, which works on
 
86
  // these "row blocks" in the jacobian.
 
87
  static bool MaybeReorderResidualBlocks(const Solver::Options& options,
 
88
                                         Program* program,
 
89
                                         string* error);
 
90
 
 
91
  // Create the appropriate evaluator for the transformed program.
 
92
  static Evaluator* CreateEvaluator(const Solver::Options& options,
 
93
                                    Program* program,
 
94
                                    string* error);
 
95
 
 
96
  // Run the minimization for the given evaluator and configuration.
 
97
  static void Minimize(const Solver::Options &options,
 
98
                       Program* program,
 
99
                       Evaluator* evaluator,
 
100
                       LinearSolver* linear_solver,
 
101
                       double* parameters,
 
102
                       Solver::Summary* summary);
 
103
 
 
104
  // Remove the fixed or unused parameter blocks and residuals
 
105
  // depending only on fixed parameters from the problem. Also updates
 
106
  // num_eliminate_blocks, since removed parameters changes the point
 
107
  // at which the eliminated blocks is valid.
 
108
  // If fixed_cost is not NULL, the residual blocks that are removed
 
109
  // are evaluated and the sum of their cost is returned in fixed_cost.
 
110
  static bool RemoveFixedBlocksFromProgram(Program* program,
 
111
                                           int* num_eliminate_blocks,
 
112
                                           double* fixed_cost,
 
113
                                           string* error);
 
114
};
 
115
 
 
116
}  // namespace internal
 
117
}  // namespace ceres
 
118
 
 
119
#endif  // CERES_INTERNAL_SOLVER_IMPL_H_