TiledArray  0.7.0
eigen.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2013 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * eigen.h
22  * Sep 16, 2013
23  *
24  */
25 
26 #ifndef TILEDARRAY_MATH_EIGEN_H__INCLUDED
27 #define TILEDARRAY_MATH_EIGEN_H__INCLUDED
28 
29 #pragma GCC diagnostic push
30 #pragma GCC system_header
31 #include <Eigen/Core>
32 #include <Eigen/QR>
33 #pragma GCC diagnostic pop
34 
35 #include <TiledArray/error.h>
36 
37 namespace TiledArray {
38  namespace math {
39 
40 
42 
49  template <typename T>
51  eigen_map(const T* t, const std::size_t m, const std::size_t n) {
52  TA_ASSERT(t);
53  TA_ASSERT(m > 0);
54  TA_ASSERT(n > 0);
55  return Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic,
56  Eigen::RowMajor>, Eigen::AutoAlign>(t, m, n);
57  }
58 
60 
67  template <typename T>
69  eigen_map(T* t, const std::size_t m, const std::size_t n) {
70  TA_ASSERT(t);
71  TA_ASSERT(m > 0);
72  TA_ASSERT(n > 0);
73  return Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic,
74  Eigen::RowMajor>, Eigen::AutoAlign>(t, m, n);
75  }
76 
78 
84  template <typename T>
86  eigen_map(const T* t, const std::size_t n) {
87  TA_ASSERT(t);
88  TA_ASSERT(n > 0);
89  return Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>, Eigen::AutoAlign>(t, n);
90  }
91 
93 
99  template <typename T>
100  inline Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>, Eigen::AutoAlign>
101  eigen_map(T* t, const std::size_t n) {
102  TA_ASSERT(t);
103  TA_ASSERT(n > 0);
104  return Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>, Eigen::AutoAlign>(t, n);
105  }
106 
107  } // namespace math
108 } // namespace TiledArray
109 
110 #endif // TILEDARRAY_MATH_EIGEN_H__INCLUDED
Eigen::Map< const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >, Eigen::AutoAlign > eigen_map(const T *t, const std::size_t m, const std::size_t n)
Construct a const Eigen::Map object for a given Tensor object.
Definition: eigen.h:51
#define TA_ASSERT(a)
Definition: error.h:107