dontalign.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) 2011 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 #if defined EIGEN_TEST_PART_1 || defined EIGEN_TEST_PART_2 || defined EIGEN_TEST_PART_3 || defined EIGEN_TEST_PART_4
11 #define EIGEN_DONT_ALIGN
12 #elif defined EIGEN_TEST_PART_5 || defined EIGEN_TEST_PART_6 || defined EIGEN_TEST_PART_7 || defined EIGEN_TEST_PART_8
13 #define EIGEN_DONT_ALIGN_STATICALLY
14 #endif
15 
16 #include "main.h"
17 #include <Eigen/Dense>
18 
19 template<typename MatrixType>
20 void dontalign(const MatrixType& m)
21 {
22  typedef typename MatrixType::Scalar Scalar;
25 
26  Index rows = m.rows();
27  Index cols = m.cols();
28 
29  MatrixType a = MatrixType::Random(rows,cols);
30  SquareMatrixType square = SquareMatrixType::Random(rows,rows);
31  VectorType v = VectorType::Random(rows);
32 
33  VERIFY_IS_APPROX(v, square * square.colPivHouseholderQr().solve(v));
34  square = square.inverse().eval();
35  a = square * a;
36  square = square*square;
37  v = square * v;
38  v = a.adjoint() * v;
39  VERIFY(square.determinant() != Scalar(0));
40 
41  // bug 219: MapAligned() was giving an assert with EIGEN_DONT_ALIGN, because Map Flags were miscomputed
42  Scalar* array = internal::aligned_new<Scalar>(rows);
43  v = VectorType::MapAligned(array, rows);
44  internal::aligned_delete(array, rows);
45 }
46 
48 {
49 #if defined EIGEN_TEST_PART_1 || defined EIGEN_TEST_PART_5
50  dontalign(Matrix3d());
51  dontalign(Matrix4f());
52 #elif defined EIGEN_TEST_PART_2 || defined EIGEN_TEST_PART_6
53  dontalign(Matrix3cd());
54  dontalign(Matrix4cf());
55 #elif defined EIGEN_TEST_PART_3 || defined EIGEN_TEST_PART_7
57  dontalign(Matrix<std::complex<float>, 32, 32>());
58 #elif defined EIGEN_TEST_PART_4 || defined EIGEN_TEST_PART_8
59  dontalign(MatrixXd(32, 32));
60  dontalign(MatrixXcf(32, 32));
61 #endif
62 }
Matrix3f m
SCALAR Scalar
Definition: bench_gemm.cpp:46
EIGEN_DEVICE_FUNC void aligned_delete(T *ptr, std::size_t size)
Definition: Memory.h:361
EIGEN_DECLARE_TEST(dontalign)
Definition: dontalign.cpp:47
MatrixXf MatrixType
void dontalign(const MatrixType &m)
Definition: dontalign.cpp:20
#define VERIFY_IS_APPROX(a, b)
EIGEN_DEVICE_FUNC const SquareReturnType square() const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Array< int, Dynamic, 1 > v
#define VERIFY(a)
Definition: main.h:380
The matrix class, also used for vectors and row-vectors.


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:11