Blender
V4.5
intern
libmv
libmv
numeric
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
21
#include "
libmv/numeric/levenberg_marquardt.h
"
22
#include "testing/testing.h"
23
24
using namespace
libmv
;
25
26
namespace
{
27
28
class
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
42
TEST
(
LevenbergMarquardt
, SimpleCase) {
43
Vec3
x
(0.76026643, -30.01799744, 0.55192142);
44
F
f;
45
LevenbergMarquardt<F>::SolverParameters
params;
46
LevenbergMarquardt<F>
lm(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
, 1
e
-5);
52
}
53
54
}
// namespace
TEST
TEST(array_store, Nop)
Definition
BLI_array_store_test.cc:305
x
x
Definition
BLI_expr_pylike_eval_test.cc:345
e
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
Definition
bmesh_query_inline.hh:42
operator()
SIMD_FORCE_INLINE btVector3 operator()(const btVector3 &x) const
Return the transform of the vector.
Definition
btTransform.h:90
libmv::LevenbergMarquardt
Definition
levenberg_marquardt.h:46
levenberg_marquardt.h
F
#define F
Definition
mball_tessellate.cc:276
libmv
Definition
libmv/autotrack/autotrack.h:30
libmv::Vec4
Eigen::Vector4d Vec4
Definition
numeric.h:110
libmv::Vec3
Eigen::Vector3d Vec3
Definition
numeric.h:109
libmv::LevenbergMarquardt::SolverParameters
Definition
levenberg_marquardt.h:72
Generated on
for Blender by
doxygen
1.18.0