dense_storage.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 template <typename T, int Rows, int Cols>
16 {
17  static const int Size = ((Rows==Dynamic || Cols==Dynamic) ? Dynamic : Rows*Cols);
18  typedef DenseStorage<T,Size, Rows,Cols, 0> DenseStorageType;
19 
20  const int rows = (Rows==Dynamic) ? 4 : Rows;
21  const int cols = (Cols==Dynamic) ? 3 : Cols;
22  const int size = rows*cols;
23  DenseStorageType reference(size, rows, cols);
24  T* raw_reference = reference.data();
25  for (int i=0; i<size; ++i)
26  raw_reference[i] = static_cast<T>(i);
27 
28  DenseStorageType copied_reference(reference);
29  const T* raw_copied_reference = copied_reference.data();
30  for (int i=0; i<size; ++i)
31  VERIFY_IS_EQUAL(raw_reference[i], raw_copied_reference[i]);
32 }
33 
34 template <typename T, int Rows, int Cols>
36 {
37  static const int Size = ((Rows==Dynamic || Cols==Dynamic) ? Dynamic : Rows*Cols);
38  typedef DenseStorage<T,Size, Rows,Cols, 0> DenseStorageType;
39 
40  const int rows = (Rows==Dynamic) ? 4 : Rows;
41  const int cols = (Cols==Dynamic) ? 3 : Cols;
42  const int size = rows*cols;
43  DenseStorageType reference(size, rows, cols);
44  T* raw_reference = reference.data();
45  for (int i=0; i<size; ++i)
46  raw_reference[i] = static_cast<T>(i);
47 
48  DenseStorageType copied_reference;
49  copied_reference = reference;
50  const T* raw_copied_reference = copied_reference.data();
51  for (int i=0; i<size; ++i)
52  VERIFY_IS_EQUAL(raw_reference[i], raw_copied_reference[i]);
53 }
54 
56 {
57  dense_storage_copy<int,Dynamic,Dynamic>();
58  dense_storage_copy<int,Dynamic,3>();
59  dense_storage_copy<int,4,Dynamic>();
60  dense_storage_copy<int,4,3>();
61 
62  dense_storage_copy<float,Dynamic,Dynamic>();
63  dense_storage_copy<float,Dynamic,3>();
64  dense_storage_copy<float,4,Dynamic>();
65  dense_storage_copy<float,4,3>();
66 
67  dense_storage_assignment<int,Dynamic,Dynamic>();
68  dense_storage_assignment<int,Dynamic,3>();
69  dense_storage_assignment<int,4,Dynamic>();
70  dense_storage_assignment<int,4,3>();
71 
72  dense_storage_assignment<float,Dynamic,Dynamic>();
73  dense_storage_assignment<float,Dynamic,3>();
74  dense_storage_assignment<float,4,Dynamic>();
75  dense_storage_assignment<float,4,3>();
76 }
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
#define VERIFY_IS_EQUAL(a, b)
Definition: main.h:331
void dense_storage_assignment()
void dense_storage_copy()
static const int Cols
void test_dense_storage()
const int Dynamic
Definition: Constants.h:21


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:57