Keir Mierle | 8ebb073 | 2012-04-30 23:09:08 -0700 | [diff] [blame] | 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 | |
| 37 | namespace ceres { |
| 38 | |
| 39 | class ResidualBlock; |
| 40 | |
| 41 | Problem::Problem() : problem_impl_(new internal::ProblemImpl) {} |
| 42 | Problem::Problem(const Problem::Options& options) |
| 43 | : problem_impl_(new internal::ProblemImpl(options)) {} |
| 44 | Problem::~Problem() {} |
| 45 | |
| 46 | ResidualBlockId 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 | |
| 55 | ResidualBlockId 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 | |
| 64 | ResidualBlockId 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 | |
| 73 | ResidualBlockId 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 | |
| 82 | ResidualBlockId 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 | |
| 91 | ResidualBlockId 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 | |
| 100 | ResidualBlockId 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 | |
| 109 | void Problem::AddParameterBlock(double* values, int size) { |
| 110 | problem_impl_->AddParameterBlock(values, size); |
| 111 | } |
| 112 | |
| 113 | void Problem::AddParameterBlock(double* values, |
| 114 | int size, |
| 115 | LocalParameterization* local_parameterization) { |
| 116 | problem_impl_->AddParameterBlock(values, size, local_parameterization); |
| 117 | } |
| 118 | |
| 119 | void Problem::SetParameterBlockConstant(double* values) { |
| 120 | problem_impl_->SetParameterBlockConstant(values); |
| 121 | } |
| 122 | |
| 123 | void Problem::SetParameterBlockVariable(double* values) { |
| 124 | problem_impl_->SetParameterBlockVariable(values); |
| 125 | } |
| 126 | |
| 127 | void Problem::SetParameterization( |
| 128 | double* values, |
| 129 | LocalParameterization* local_parameterization) { |
| 130 | problem_impl_->SetParameterization(values, local_parameterization); |
| 131 | } |
| 132 | |
| 133 | int Problem::NumParameterBlocks() const { |
| 134 | return problem_impl_->NumParameterBlocks(); |
| 135 | } |
| 136 | |
| 137 | int Problem::NumParameters() const { |
| 138 | return problem_impl_->NumParameters(); |
| 139 | } |
| 140 | |
| 141 | int Problem::NumResidualBlocks() const { |
| 142 | return problem_impl_->NumResidualBlocks(); |
| 143 | } |
| 144 | |
| 145 | int Problem::NumResiduals() const { |
| 146 | return problem_impl_->NumResiduals(); |
| 147 | } |
| 148 | |
| 149 | } // namespace ceres |