Blender V4.3
levenberg_marquardt_test.cc
Go to the documentation of this file.
1// Copyright (c) 2007, 2008, 2009 libmv authors.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to
5// deal in the Software without restriction, including without limitation the
6// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7// sell copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19// IN THE SOFTWARE.
20
22#include "testing/testing.h"
23
24using namespace libmv;
25
26namespace {
27
28class F {
29 public:
30 typedef Vec4 FMatrixType;
31 typedef Vec3 XMatrixType;
32 Vec4 operator()(const Vec3& x) const {
33 double x1 = x.x() - 2;
34 double y1 = x.y() - 5;
35 double z1 = x.z();
36 Vec4 fx;
37 fx << x1 * x1 + z1 * z1, y1 * y1 + z1 * z1, z1 * z1, x1 * x1;
38 return fx;
39 }
40};
41
42TEST(LevenbergMarquardt, SimpleCase) {
43 Vec3 x(0.76026643, -30.01799744, 0.55192142);
44 F f;
47 /* TODO(sergey): Better error handling. */
48 /* LevenbergMarquardt<F>::Results results = */ lm.minimize(params, &x);
49 Vec3 expected_min_x(2, 5, 0);
50
51 EXPECT_MATRIX_NEAR(expected_min_x, x, 1e-5);
52}
53
54} // namespace
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
SIMD_FORCE_INLINE btVector3 operator()(const btVector3 &x) const
Return the transform of the vector.
Definition btTransform.h:90
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
Eigen::Vector4d Vec4
Definition numeric.h:107
TEST(PolynomialCameraIntrinsics2, ApplyOnFocalCenter)
Eigen::Vector3d Vec3
Definition numeric.h:106