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;
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);
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 }
dontalign
void dontalign(const MatrixType &m)
Definition: dontalign.cpp:20
MatrixType
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Eigen::array
Definition: EmulateArray.h:21
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(dontalign)
Definition: dontalign.cpp:47
rows
int rows
Definition: Tutorial_commainit_02.cpp:1
square
const EIGEN_DEVICE_FUNC SquareReturnType square() const
Definition: ArrayCwiseUnaryOps.h:425
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
VERIFY_IS_APPROX
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:15
Eigen::internal::aligned_delete
EIGEN_DEVICE_FUNC void aligned_delete(T *ptr, std::size_t size)
Definition: Memory.h:361
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
main.h
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
VectorType
Definition: FFTW.cpp:65
cols
int cols
Definition: Tutorial_commainit_02.cpp:1
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
VERIFY
#define VERIFY(a)
Definition: main.h:380
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 Fri Nov 1 2024 03:32:27