Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
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
template
<
typename
MatrixType>
void
ctor_init1
(
const
MatrixType
&
m
)
24
{
25
// Check logic in PlainObjectBase::_init1
26
Index
rows
= m.rows();
27
Index
cols
= m.cols();
28
29
MatrixType
m0 = MatrixType::Random(rows,cols);
30
31
VERIFY_EVALUATION_COUNT
(
MatrixType
m1
(m0), 1);
32
VERIFY_EVALUATION_COUNT
(
MatrixType
m2
(m0+m0), 1);
33
VERIFY_EVALUATION_COUNT
(
MatrixType
m2
(m0.block(0,0,rows,cols)) , 1);
34
35
Wrapper<MatrixType>
wrapper
(m0);
36
VERIFY_EVALUATION_COUNT
(
MatrixType
m3(wrapper) , 1);
37
}
38
39
40
void
test_constructor
()
41
{
42
for
(
int
i
= 0;
i
<
g_repeat
;
i
++) {
43
CALL_SUBTEST_1(
ctor_init1
(
Matrix<float, 1, 1>
()) );
44
CALL_SUBTEST_1(
ctor_init1
(Matrix4d()) );
45
CALL_SUBTEST_1(
ctor_init1
(MatrixXcf(internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
), internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
))) );
46
CALL_SUBTEST_1(
ctor_init1
(MatrixXi(internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
), internal::random<int>(1,
EIGEN_TEST_MAX_SIZE
))) );
47
}
48
{
49
Matrix<Index,1,1>
a
(123);
50
VERIFY_IS_EQUAL
(a[0], 123);
51
}
52
{
53
Matrix<Index,1,1>
a
(123.0);
54
VERIFY_IS_EQUAL
(a[0], 123);
55
}
56
{
57
Matrix<float,1,1>
a
(123);
58
VERIFY_IS_EQUAL
(a[0], 123.
f
);
59
}
60
{
61
Array<Index,1,1>
a
(123);
62
VERIFY_IS_EQUAL
(a[0], 123);
63
}
64
{
65
Array<Index,1,1>
a
(123.0);
66
VERIFY_IS_EQUAL
(a[0], 123);
67
}
68
{
69
Array<float,1,1>
a
(123);
70
VERIFY_IS_EQUAL
(a[0], 123.
f
);
71
}
72
{
73
Array<Index,3,3>
a
(123);
74
VERIFY_IS_EQUAL
(
a
(4), 123);
75
}
76
{
77
Array<Index,3,3>
a
(123.0);
78
VERIFY_IS_EQUAL
(
a
(4), 123);
79
}
80
{
81
Array<float,3,3>
a
(123);
82
VERIFY_IS_EQUAL
(
a
(4), 123.
f
);
83
}
84
}
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
Wrapper::m_mat
MatrixType m_mat
Definition:
constructor.cpp:17
cols
int cols
Definition:
Tutorial_commainit_02.cpp:1
m2
MatrixType m2(n_dims)
test_constructor
void test_constructor()
Definition:
constructor.cpp:40
MatrixType
MatrixXf MatrixType
Definition:
benchmark-blocking-sizes.cpp:52
main.h
a
Array33i a
Definition:
Cwise_product.cpp:1
VERIFY_EVALUATION_COUNT
#define VERIFY_EVALUATION_COUNT(XPR, N)
Definition:
test/sparse_product.cpp:27
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:331
Wrapper
Definition:
constructor.cpp:15
m1
Matrix3d m1
Definition:
IOFormat.cpp:2
matlab_wrap.wrapper
wrapper
Definition:
matlab_wrap.py:61
ctor_init1
void ctor_init1(const MatrixType &m)
Definition:
constructor.cpp:23
Eigen::g_repeat
static int g_repeat
Definition:
main.h:144
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition:
Meta.h:33
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition:
testExpression.cpp:211
Wrapper::Wrapper
Wrapper(const MatrixType &x)
Definition:
constructor.cpp:18
EIGEN_TEST_MAX_SIZE
#define EIGEN_TEST_MAX_SIZE
Definition:
boostmultiprec.cpp:16
Eigen::Array
General-purpose arrays with easy API for coefficient-wise operations.
Definition:
Array.h:45
rows
int rows
Definition:
Tutorial_commainit_02.cpp:1
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
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
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:51