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: 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 39class ResidualBlock; 40 41Problem::Problem() : problem_impl_(new internal::ProblemImpl) {} 42Problem::Problem(const Problem::Options& options) 43 : problem_impl_(new internal::ProblemImpl(options)) {} 44Problem::~Problem() {} 45 46ResidualBlockId Problem::AddResidualBlock( 47 CostFunction* cost_function, 48 LossFunction* loss_function, 49 const vector<double*>& parameter_blocks) { 50 return problem_impl_->AddResidualBlock(cost_function, 51 loss_function, 52 parameter_blocks); 53} 54 55ResidualBlockId Problem::AddResidualBlock( 56 CostFunction* cost_function, 57 LossFunction* loss_function, 58 double* x0) { 59 return problem_impl_->AddResidualBlock(cost_function, 60 loss_function, 61 x0); 62} 63 64ResidualBlockId Problem::AddResidualBlock( 65 CostFunction* cost_function, 66 LossFunction* loss_function, 67 double* x0, double* x1) { 68 return problem_impl_->AddResidualBlock(cost_function, 69 loss_function, 70 x0, x1); 71} 72 73ResidualBlockId Problem::AddResidualBlock( 74 CostFunction* cost_function, 75 LossFunction* loss_function, 76 double* x0, double* x1, double* x2) { 77 return problem_impl_->AddResidualBlock(cost_function, 78 loss_function, 79 x0, x1, x2); 80} 81 82ResidualBlockId Problem::AddResidualBlock( 83 CostFunction* cost_function, 84 LossFunction* loss_function, 85 double* x0, double* x1, double* x2, double* x3) { 86 return problem_impl_->AddResidualBlock(cost_function, 87 loss_function, 88 x0, x1, x2, x3); 89} 90 91ResidualBlockId Problem::AddResidualBlock( 92 CostFunction* cost_function, 93 LossFunction* loss_function, 94 double* x0, double* x1, double* x2, double* x3, double* x4) { 95 return problem_impl_->AddResidualBlock(cost_function, 96 loss_function, 97 x0, x1, x2, x3, x4); 98} 99 100ResidualBlockId Problem::AddResidualBlock( 101 CostFunction* cost_function, 102 LossFunction* loss_function, 103 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5) { 104 return problem_impl_->AddResidualBlock(cost_function, 105 loss_function, 106 x0, x1, x2, x3, x4, x5); 107} 108 109ResidualBlockId Problem::AddResidualBlock( 110 CostFunction* cost_function, 111 LossFunction* loss_function, 112 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5, 113 double* x6) { 114 return problem_impl_->AddResidualBlock(cost_function, 115 loss_function, 116 x0, x1, x2, x3, x4, x5, x6); 117} 118 119ResidualBlockId Problem::AddResidualBlock( 120 CostFunction* cost_function, 121 LossFunction* loss_function, 122 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5, 123 double* x6, double* x7) { 124 return problem_impl_->AddResidualBlock(cost_function, 125 loss_function, 126 x0, x1, x2, x3, x4, x5, x6, x7); 127} 128 129ResidualBlockId Problem::AddResidualBlock( 130 CostFunction* cost_function, 131 LossFunction* loss_function, 132 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5, 133 double* x6, double* x7, double* x8) { 134 return problem_impl_->AddResidualBlock(cost_function, 135 loss_function, 136 x0, x1, x2, x3, x4, x5, x6, x7, x8); 137} 138 139ResidualBlockId Problem::AddResidualBlock( 140 CostFunction* cost_function, 141 LossFunction* loss_function, 142 double* x0, double* x1, double* x2, double* x3, double* x4, double* x5, 143 double* x6, double* x7, double* x8, double* x9) { 144 return problem_impl_->AddResidualBlock(cost_function, 145 loss_function, 146 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9); 147} 148 149void Problem::AddParameterBlock(double* values, int size) { 150 problem_impl_->AddParameterBlock(values, size); 151} 152 153void Problem::AddParameterBlock(double* values, 154 int size, 155 LocalParameterization* local_parameterization) { 156 problem_impl_->AddParameterBlock(values, size, local_parameterization); 157} 158 159void Problem::SetParameterBlockConstant(double* values) { 160 problem_impl_->SetParameterBlockConstant(values); 161} 162 163void Problem::SetParameterBlockVariable(double* values) { 164 problem_impl_->SetParameterBlockVariable(values); 165} 166 167void Problem::SetParameterization( 168 double* values, 169 LocalParameterization* local_parameterization) { 170 problem_impl_->SetParameterization(values, local_parameterization); 171} 172 173int Problem::NumParameterBlocks() const { 174 return problem_impl_->NumParameterBlocks(); 175} 176 177int Problem::NumParameters() const { 178 return problem_impl_->NumParameters(); 179} 180 181int Problem::NumResidualBlocks() const { 182 return problem_impl_->NumResidualBlocks(); 183} 184 185int Problem::NumResiduals() const { 186 return problem_impl_->NumResiduals(); 187} 188 189} // namespace ceres 190