gtsam
3rdparty
Eigen
test
smallvectors.cpp
Go to the documentation of this file.
1
// This file is part of Eigen, a lightweight C++ template library
2
// for linear algebra.
3
//
4
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5
//
6
// This Source Code Form is subject to the terms of the Mozilla
7
// Public License v. 2.0. If a copy of the MPL was not distributed
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10
#define EIGEN_NO_STATIC_ASSERT
11
#include "
main.h
"
12
13
template
<
typename
Scalar>
void
smallVectors
()
14
{
15
typedef
Matrix<Scalar, 1, 2>
V2;
16
typedef
Matrix<Scalar, 3, 1>
V3;
17
typedef
Matrix<Scalar, 1, 4>
V4;
18
typedef
Matrix<Scalar, Dynamic, 1>
VX;
19
Scalar
x1
= internal::random<Scalar>(),
20
x2
= internal::random<Scalar>(),
21
x3
= internal::random<Scalar>(),
22
x4
= internal::random<Scalar>();
23
V2
v2
(
x1
,
x2
);
24
V3
v3
(
x1
,
x2
,
x3
);
25
V4 v4(
x1
,
x2
,
x3
,
x4
);
26
VERIFY_IS_APPROX
(
x1
,
v2
.x());
27
VERIFY_IS_APPROX
(
x1
,
v3
.x());
28
VERIFY_IS_APPROX
(
x1
, v4.x());
29
VERIFY_IS_APPROX
(
x2
,
v2
.y());
30
VERIFY_IS_APPROX
(
x2
,
v3
.y());
31
VERIFY_IS_APPROX
(
x2
, v4.y());
32
VERIFY_IS_APPROX
(
x3
,
v3
.z());
33
VERIFY_IS_APPROX
(
x3
, v4.z());
34
VERIFY_IS_APPROX
(
x4
, v4.w());
35
36
if
(!
NumTraits<Scalar>::IsInteger
)
37
{
38
VERIFY_RAISES_ASSERT
(V3(2, 1))
39
VERIFY_RAISES_ASSERT
(V3(3, 2))
40
VERIFY_RAISES_ASSERT
(V3(
Scalar
(3), 1))
41
VERIFY_RAISES_ASSERT
(V3(3,
Scalar
(1)))
42
VERIFY_RAISES_ASSERT
(V3(
Scalar
(3),
Scalar
(1)))
43
VERIFY_RAISES_ASSERT
(V3(
Scalar
(123),
Scalar
(123)))
44
45
VERIFY_RAISES_ASSERT
(V4(1, 3))
46
VERIFY_RAISES_ASSERT
(V4(2, 4))
47
VERIFY_RAISES_ASSERT
(V4(1,
Scalar
(4)))
48
VERIFY_RAISES_ASSERT
(V4(
Scalar
(1), 4))
49
VERIFY_RAISES_ASSERT
(V4(
Scalar
(1),
Scalar
(4)))
50
VERIFY_RAISES_ASSERT
(V4(
Scalar
(123),
Scalar
(123)))
51
52
VERIFY_RAISES_ASSERT
(VX(3, 2))
53
VERIFY_RAISES_ASSERT
(VX(
Scalar
(3), 1))
54
VERIFY_RAISES_ASSERT
(VX(3,
Scalar
(1)))
55
VERIFY_RAISES_ASSERT
(VX(
Scalar
(3),
Scalar
(1)))
56
VERIFY_RAISES_ASSERT
(VX(
Scalar
(123),
Scalar
(123)))
57
}
58
}
59
60
EIGEN_DECLARE_TEST
(smallvectors)
61
{
62
for
(
int
i
= 0;
i
<
g_repeat
;
i
++) {
63
CALL_SUBTEST
(smallVectors<int>() );
64
CALL_SUBTEST
(smallVectors<float>() );
65
CALL_SUBTEST
(smallVectors<double>() );
66
}
67
}
x4
static string x4("x4")
x3
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(smallvectors)
Definition:
smallvectors.cpp:60
VERIFY_RAISES_ASSERT
#define VERIFY_RAISES_ASSERT(a)
Definition:
main.h:340
smallVectors
void smallVectors()
Definition:
smallvectors.cpp:13
x1
Pose3 x1
Definition:
testPose3.cpp:663
Eigen::g_repeat
static int g_repeat
Definition:
main.h:169
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition:
integer_types.cpp:15
main.h
v2
Vector v2
Definition:
testSerializationBase.cpp:39
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
v3
Vector v3
Definition:
testSerializationBase.cpp:40
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition:
NumTraits.h:232
x2
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
CALL_SUBTEST
#define CALL_SUBTEST(FUNC)
Definition:
main.h:399
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:04:21