CoDiPack  2.2.0
A Code Differentiation Package
SciComp TU Kaiserslautern
Loading...
Searching...
No Matches
eigenWrappers.hpp
1/*
2 * CoDiPack, a Code Differentiation Package
3 *
4 * Copyright (C) 2015-2024 Chair for Scientific Computing (SciComp), University of Kaiserslautern-Landau
5 * Homepage: http://scicomp.rptu.de
6 * Contact: Prof. Nicolas R. Gauger (codi@scicomp.uni-kl.de)
7 *
8 * Lead developers: Max Sagebaum, Johannes Blühdorn (SciComp, University of Kaiserslautern-Landau)
9 *
10 * This file is part of CoDiPack (http://scicomp.rptu.de/software/codi).
11 *
12 * CoDiPack is free software: you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * CoDiPack is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * See the GNU General Public License for more details.
22 * You should have received a copy of the GNU
23 * General Public License along with CoDiPack.
24 * If not, see <http://www.gnu.org/licenses/>.
25 *
26 * For other licensing options please contact us.
27 *
28 * Authors:
29 * - SciComp, University of Kaiserslautern-Landau:
30 * - Max Sagebaum
31 * - Johannes Blühdorn
32 * - Former members:
33 * - Tim Albring
34 */
35#pragma once
36
37#include "../../config.h"
38
39#if CODI_EnableEigen
40
41 #include <Eigen/Eigen>
42
43 #include "../../misc/macros.hpp"
44
46namespace codi {
47
49 template<typename T, Eigen::StorageOptions store>
50 using MapEigenMatrix = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, store>>;
51
53 template<typename T, Eigen::StorageOptions store>
54 using MapEigenMatrixConst = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, store> const>;
55
57 template<typename T>
58 using MapEigenVector = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1>>;
59
61 template<typename T>
62 using MapEigenVectorConst = Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> const>;
63
65 template<Eigen::StorageOptions store, typename T>
66 MapEigenMatrix<T, store> mapEigen(T* p, int rows, int cols) {
67 return MapEigenMatrix<T, store>(p, rows, cols);
68 }
69
71 template<Eigen::StorageOptions store, typename T>
72 MapEigenMatrixConst<T, store> mapEigen(T const* p, int rows, int cols) {
73 return MapEigenMatrixConst<T, store>(p, rows, cols);
74 }
75
77 template<typename T>
79 return mapEigen<Eigen::StorageOptions::RowMajor>(p, rows, cols);
80 }
81
83 template<typename T>
85 return mapEigen<Eigen::StorageOptions::RowMajor>(p, rows, cols);
86 }
87
89 template<typename T>
91 return mapEigen<Eigen::StorageOptions::ColMajor>(p, rows, cols);
92 }
93
95 template<typename T>
97 return mapEigen<Eigen::StorageOptions::ColMajor>(p, rows, cols);
98 }
99
101 template<typename T>
102 MapEigenVector<T> mapEigen(T* p, int size) {
103 return MapEigenVector<T>(p, size);
104 }
105
107 template<typename T>
108 MapEigenVectorConst<T> mapEigen(T const* p, int size) {
109 return MapEigenVectorConst<T>(p, size);
110 }
111}
112
113#endif
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, store > const > MapEigenMatrixConst
Abbreviation for a constant mapped Eigen matrix.
Definition eigenWrappers.hpp:54
MapEigenMatrix< T, store > mapEigen(T *p, int rows, int cols)
Create a mapped Eigen matrix with specified storing option.
Definition eigenWrappers.hpp:66
MapEigenMatrix< T, Eigen::StorageOptions::ColMajor > mapEigenColMajor(T *p, int rows, int cols)
Create a mapped Eigen matrix with a column major data layout.
Definition eigenWrappers.hpp:90
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, 1 > > MapEigenVector
Abbreviation for a mapped Eigen vector.
Definition eigenWrappers.hpp:58
MapEigenMatrix< T, Eigen::StorageOptions::RowMajor > mapEigenRowMajor(T *p, int rows, int cols)
Create a mapped Eigen matrix with a row major data layout.
Definition eigenWrappers.hpp:78
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, 1 > const > MapEigenVectorConst
Abbreviation for a constant mapped Eigen vector.
Definition eigenWrappers.hpp:62
Eigen::Map< Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, store > > MapEigenMatrix
Abbreviation for a mapped Eigen matrix.
Definition eigenWrappers.hpp:50