gtsam
3rdparty
Eigen
test
constructor.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) 2017 Gael Guennebaud <gael.guennebaud@inria.fr>
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
11
#define TEST_ENABLE_TEMPORARY_TRACKING
12
13
#include "
main.h
"
14
15
template
<
typename
MatrixType>
struct
Wrapper
16
{
17
MatrixType
m_mat
;
18
inline
Wrapper
(
const
MatrixType
&
x
) :
m_mat
(
x
) {}
19
inline
operator
const
MatrixType
& ()
const
{
return
m_mat
; }
20
inline
operator
MatrixType
& () {
return
m_mat
; }
21
};
22
23
enum
my_sizes
{
M
= 12,
N
= 7};
24
25
template
<
typename
MatrixType>
void
ctor_init1
(
const
MatrixType
&
m
)
26
{
27
// Check logic in PlainObjectBase::_init1
28
Index
rows
=
m
.rows();
29
Index
cols
=
m
.cols();
30
31
MatrixType
m0
= MatrixType::Random(
rows
,
cols
);
32
33
VERIFY_EVALUATION_COUNT
(
MatrixType
m1
(
m0
), 1);
34
VERIFY_EVALUATION_COUNT
(
MatrixType
m2
(
m0
+
m0
), 1);
35
VERIFY_EVALUATION_COUNT
(
MatrixType
m2
(
m0
.block(0,0,
rows
,
cols
)) , 1);
36
37
Wrapper<MatrixType>
wrapper
(
m0
);
38
VERIFY_EVALUATION_COUNT
(
MatrixType
m3
(
wrapper
) , 1);
39
}
40
41
42
EIGEN_DECLARE_TEST
(
constructor
)
43
{
44
for
(
int
i
= 0;
i
<
g_repeat
;
i
++) {
45
CALL_SUBTEST_1
(
ctor_init1
(
Matrix<float, 1, 1>
()) );
46
CALL_SUBTEST_1
(
ctor_init1
(Matrix4d()) );
47
CALL_SUBTEST_1
(
ctor_init1
(MatrixXcf(internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
), internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
))) );
48
CALL_SUBTEST_1
(
ctor_init1
(MatrixXi(internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
), internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
))) );
49
}
50
{
51
Matrix<Index,1,1>
a
(123);
52
VERIFY_IS_EQUAL
(
a
[0], 123);
53
}
54
{
55
Matrix<Index,1,1>
a
(123.0);
56
VERIFY_IS_EQUAL
(
a
[0], 123);
57
}
58
{
59
Matrix<float,1,1>
a
(123);
60
VERIFY_IS_EQUAL
(
a
[0], 123.
f
);
61
}
62
{
63
Array<Index,1,1>
a
(123);
64
VERIFY_IS_EQUAL
(
a
[0], 123);
65
}
66
{
67
Array<Index,1,1>
a
(123.0);
68
VERIFY_IS_EQUAL
(
a
[0], 123);
69
}
70
{
71
Array<float,1,1>
a
(123);
72
VERIFY_IS_EQUAL
(
a
[0], 123.
f
);
73
}
74
{
75
Array<Index,3,3>
a
(123);
76
VERIFY_IS_EQUAL
(
a
(4), 123);
77
}
78
{
79
Array<Index,3,3>
a
(123.0);
80
VERIFY_IS_EQUAL
(
a
(4), 123);
81
}
82
{
83
Array<float,3,3>
a
(123);
84
VERIFY_IS_EQUAL
(
a
(4), 123.
f
);
85
}
86
{
87
MatrixXi
m1
(
M
,
N
);
88
VERIFY_IS_EQUAL
(
m1
.rows(),
M
);
89
VERIFY_IS_EQUAL
(
m1
.cols(),
N
);
90
ArrayXXi
a1
(
M
,
N
);
91
VERIFY_IS_EQUAL
(
a1
.rows(),
M
);
92
VERIFY_IS_EQUAL
(
a1
.cols(),
N
);
93
VectorXi
v1
(
M
);
94
VERIFY_IS_EQUAL
(
v1
.size(),
M
);
95
ArrayXi
a2
(
M
);
96
VERIFY_IS_EQUAL
(
a2
.size(),
M
);
97
}
98
}
MatrixType
MatrixXf MatrixType
Definition:
benchmark-blocking-sizes.cpp:52
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:386
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition:
gnuplot_common_settings.hh:12
m1
Matrix3d m1
Definition:
IOFormat.cpp:2
Eigen::Array
General-purpose arrays with easy API for coefficient-wise operations.
Definition:
Array.h:45
m0
static const DiscreteKey m0(M(0), 2)
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
align_3::a1
Point2 a1
Definition:
testPose2.cpp:769
m2
MatrixType m2(n_dims)
CALL_SUBTEST_1
#define CALL_SUBTEST_1(FUNC)
Definition:
split_test_helper.h:4
Wrapper
Definition:
constructor.cpp:15
matlab_wrap.wrapper
wrapper
Definition:
matlab_wrap.py:59
Eigen::g_repeat
static int g_repeat
Definition:
main.h:169
Wrapper::m_mat
MatrixType m_mat
Definition:
constructor.cpp:17
M
@ M
Definition:
constructor.cpp:23
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
Wrapper::Wrapper
Wrapper(const MatrixType &x)
Definition:
constructor.cpp:18
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition:
testExpression.cpp:218
ctor_init1
void ctor_init1(const MatrixType &m)
Definition:
constructor.cpp:25
m3
static const DiscreteKey m3(M(3), 2)
a
ArrayXXi a
Definition:
Array_initializer_list_23_cxx11.cpp:1
constructor
Definition:
init.h:200
main.h
N
@ N
Definition:
constructor.cpp:23
align_3::a2
Point2 a2
Definition:
testPose2.cpp:770
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition:
boostmultiprec.cpp:16
VERIFY_EVALUATION_COUNT
#define VERIFY_EVALUATION_COUNT(XPR, N)
Definition:
test/sparse_product.cpp:27
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(constructor)
Definition:
constructor.cpp:42
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
my_sizes
my_sizes
Definition:
constructor.cpp:23
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
v1
Vector v1
Definition:
testSerializationBase.cpp:38
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:74
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:02