blob: c8f4a21eb2e2dc1a9466843afad97f57695d67c9 [file] [log] [blame]
Keir Mierle8ebb0732012-04-30 23:09:08 -07001// 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: sameeragarwal@google.com (Sameer Agarwal)
30// keir@google.com (Keir Mierle)
31
32#include "ceres/problem.h"
33
34#include <vector>
35#include "ceres/problem_impl.h"
36
37namespace ceres {
38
Keir Mierle8ebb0732012-04-30 23:09:08 -070039Problem::Problem() : problem_impl_(new internal::ProblemImpl) {}
40Problem::Problem(const Problem::Options& options)
41 : problem_impl_(new internal::ProblemImpl(options)) {}
42Problem::~Problem() {}
43
44ResidualBlockId Problem::AddResidualBlock(
45 CostFunction* cost_function,
46 LossFunction* loss_function,
47 const vector<double*>& parameter_blocks) {
48 return problem_impl_->AddResidualBlock(cost_function,
49 loss_function,
50 parameter_blocks);
51}
52
53ResidualBlockId Problem::AddResidualBlock(
54 CostFunction* cost_function,
55 LossFunction* loss_function,
56 double* x0) {
57 return problem_impl_->AddResidualBlock(cost_function,
58 loss_function,
59 x0);
60}
61
62ResidualBlockId Problem::AddResidualBlock(
63 CostFunction* cost_function,
64 LossFunction* loss_function,
65 double* x0, double* x1) {
66 return problem_impl_->AddResidualBlock(cost_function,
67 loss_function,
68 x0, x1);
69}
70
71ResidualBlockId Problem::AddResidualBlock(
72 CostFunction* cost_function,
73 LossFunction* loss_function,
74 double* x0, double* x1, double* x2) {
75 return problem_impl_->AddResidualBlock(cost_function,
76 loss_function,
77 x0, x1, x2);
78}
79
80ResidualBlockId Problem::AddResidualBlock(
81 CostFunction* cost_function,
82 LossFunction* loss_function,
83 double* x0, double* x1, double* x2, double* x3) {
84 return problem_impl_->AddResidualBlock(cost_function,
85 loss_function,
86 x0, x1, x2, x3);
87}
88
89ResidualBlockId Problem::AddResidualBlock(
90 CostFunction* cost_function,
91 LossFunction* loss_function,
92 double* x0, double* x1, double* x2, double* x3, double* x4) {
93 return problem_impl_->AddResidualBlock(cost_function,
94 loss_function,
95 x0, x1, x2, x3, x4);
96}
97
98ResidualBlockId Problem::AddResidualBlock(
99 CostFunction* cost_function,
100 LossFunction* loss_function,
101 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5) {
102 return problem_impl_->AddResidualBlock(cost_function,
103 loss_function,
104 x0, x1, x2, x3, x4, x5);
105}
106
Fisher12626e82012-10-21 14:12:04 -0400107ResidualBlockId Problem::AddResidualBlock(
108 CostFunction* cost_function,
109 LossFunction* loss_function,
110 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5,
111 double* x6) {
112 return problem_impl_->AddResidualBlock(cost_function,
113 loss_function,
114 x0, x1, x2, x3, x4, x5, x6);
115}
116
117ResidualBlockId Problem::AddResidualBlock(
118 CostFunction* cost_function,
119 LossFunction* loss_function,
120 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5,
121 double* x6, double* x7) {
122 return problem_impl_->AddResidualBlock(cost_function,
123 loss_function,
124 x0, x1, x2, x3, x4, x5, x6, x7);
125}
126
127ResidualBlockId Problem::AddResidualBlock(
128 CostFunction* cost_function,
129 LossFunction* loss_function,
130 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5,
131 double* x6, double* x7, double* x8) {
132 return problem_impl_->AddResidualBlock(cost_function,
133 loss_function,
134 x0, x1, x2, x3, x4, x5, x6, x7, x8);
135}
136
137ResidualBlockId Problem::AddResidualBlock(
138 CostFunction* cost_function,
139 LossFunction* loss_function,
140 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5,
141 double* x6, double* x7, double* x8, double* x9) {
142 return problem_impl_->AddResidualBlock(cost_function,
143 loss_function,
144 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9);
145}
146
Keir Mierle8ebb0732012-04-30 23:09:08 -0700147void Problem::AddParameterBlock(double* values, int size) {
148 problem_impl_->AddParameterBlock(values, size);
149}
150
151void Problem::AddParameterBlock(double* values,
152 int size,
153 LocalParameterization* local_parameterization) {
154 problem_impl_->AddParameterBlock(values, size, local_parameterization);
155}
156
Keir Mierle04938ef2013-02-17 12:37:55 -0800157void Problem::RemoveResidualBlock(ResidualBlockId residual_block) {
158 problem_impl_->RemoveResidualBlock(residual_block);
159}
160
161void Problem::RemoveParameterBlock(double* values) {
162 problem_impl_->RemoveParameterBlock(values);
163}
164
Keir Mierle8ebb0732012-04-30 23:09:08 -0700165void Problem::SetParameterBlockConstant(double* values) {
166 problem_impl_->SetParameterBlockConstant(values);
167}
168
169void Problem::SetParameterBlockVariable(double* values) {
170 problem_impl_->SetParameterBlockVariable(values);
171}
172
173void Problem::SetParameterization(
174 double* values,
175 LocalParameterization* local_parameterization) {
176 problem_impl_->SetParameterization(values, local_parameterization);
177}
178
179int Problem::NumParameterBlocks() const {
180 return problem_impl_->NumParameterBlocks();
181}
182
183int Problem::NumParameters() const {
184 return problem_impl_->NumParameters();
185}
186
187int Problem::NumResidualBlocks() const {
188 return problem_impl_->NumResidualBlocks();
189}
190
191int Problem::NumResiduals() const {
192 return problem_impl_->NumResiduals();
193}
194
195} // namespace ceres