Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
gtsam
3rdparty
Eigen
test
rvalue_types.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) 2013 Hauke Heibel <hauke.heibel@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
#include "
main.h
"
11
12
#include <Eigen/Core>
13
14
using
internal::UIntPtr
;
15
16
#if EIGEN_HAS_RVALUE_REFERENCES
17
template
<
typename
MatrixType>
18
void
rvalue_copyassign
(
const
MatrixType
&
m
)
19
{
20
21
typedef
typename
internal::traits<MatrixType>::Scalar
Scalar
;
22
23
// create a temporary which we are about to destroy by moving
24
MatrixType
tmp =
m
;
25
UIntPtr
src_address =
reinterpret_cast<
UIntPtr
>
(tmp.data());
26
27
// move the temporary to n
28
MatrixType
n
= std::move(tmp);
29
UIntPtr
dst_address =
reinterpret_cast<
UIntPtr
>
(n.data());
30
31
if
(MatrixType::RowsAtCompileTime==
Dynamic
|| MatrixType::ColsAtCompileTime==
Dynamic
)
32
{
33
// verify that we actually moved the guts
34
VERIFY_IS_EQUAL
(src_address, dst_address);
35
}
36
37
// verify that the content did not change
38
Scalar abs_diff = (m-
n
).
array
().abs().sum();
39
VERIFY_IS_EQUAL
(abs_diff,
Scalar
(0));
40
}
41
#else
42
template
<
typename
MatrixType>
43
void
rvalue_copyassign
(
const
MatrixType
&) {}
44
#endif
45
46
void
test_rvalue_types
()
47
{
48
CALL_SUBTEST_1(
rvalue_copyassign
( MatrixXf::Random(50,50).
eval
() ));
49
CALL_SUBTEST_1(
rvalue_copyassign
( ArrayXXf::Random(50,50).
eval
() ));
50
51
CALL_SUBTEST_1(
rvalue_copyassign
(
Matrix<float,1,Dynamic>::Random
(50).
eval
() ));
52
CALL_SUBTEST_1(
rvalue_copyassign
(
Array<float,1,Dynamic>::Random
(50).
eval
() ));
53
54
CALL_SUBTEST_1(
rvalue_copyassign
(
Matrix<float,Dynamic,1>::Random
(50).
eval
() ));
55
CALL_SUBTEST_1(
rvalue_copyassign
(
Array<float,Dynamic,1>::Random
(50).
eval
() ));
56
57
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,2,1>::Random
().
eval
() ));
58
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,3,1>::Random
().
eval
() ));
59
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,4,1>::Random
().
eval
() ));
60
61
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,2,2>::Random
().
eval
() ));
62
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,3,3>::Random
().
eval
() ));
63
CALL_SUBTEST_2(
rvalue_copyassign
(
Array<float,4,4>::Random
().
eval
() ));
64
}
m
Matrix3f m
Definition:
AngleAxis_mimic_euler.cpp:1
array
int array[24]
Definition:
Map_general_stride.cpp:1
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:33
rvalue_copyassign
void rvalue_copyassign(const MatrixType &)
Definition:
rvalue_types.cpp:43
n
int n
Definition:
BiCGSTAB_simple.cpp:1
MatrixType
MatrixXf MatrixType
Definition:
benchmark-blocking-sizes.cpp:52
Eigen::internal::UIntPtr
std::size_t UIntPtr
Definition:
Meta.h:51
main.h
test_rvalue_types
void test_rvalue_types()
Definition:
rvalue_types.cpp:46
VERIFY_IS_EQUAL
#define VERIFY_IS_EQUAL(a, b)
Definition:
main.h:331
Eigen::Array
General-purpose arrays with easy API for coefficient-wise operations.
Definition:
Array.h:45
eval
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition:
sparse_permutations.cpp:38
Eigen::Dynamic
const int Dynamic
Definition:
Constants.h:21
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition:
3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:53