Cantera  4.0.0a1
Loading...
Searching...
No Matches
eigen_dense.h
1// This file is part of Cantera. See License.txt in the top-level directory or
2// at https://cantera.org/license.txt for license and copyright information.
3
4#ifndef CT_EIGEN_DENSE_H
5#define CT_EIGEN_DENSE_H
6
8
9#if CT_USE_SYSTEM_EIGEN
10 #if CT_USE_SYSTEM_EIGEN_PREFIXED
11 #include <eigen3/Eigen/Dense>
12 #else
13 #include <Eigen/Dense>
14 #endif
15#else
16#include "cantera/ext/Eigen/Dense"
17#endif
18#include <concepts>
19
20namespace Cantera
21{
22
23//! @addtogroup matrices
24//! @{
25
26typedef Eigen::Map<Eigen::MatrixXd> MappedMatrix;
27typedef Eigen::Map<const Eigen::MatrixXd> ConstMappedMatrix;
28typedef Eigen::Map<Eigen::VectorXd> MappedVector;
29typedef Eigen::Map<const Eigen::VectorXd> ConstMappedVector;
30typedef Eigen::Map<Eigen::RowVectorXd> MappedRowVector;
31typedef Eigen::Map<const Eigen::RowVectorXd> ConstMappedRowVector;
32
33//! @}
34
35template<class Derived>
36concept EigenDenseDouble = std::same_as<typename Derived::Scalar, double>;
37
38// Require a 1D type with contiguous storage
39template<class Derived>
41 && (Derived::IsVectorAtCompileTime == 1);
42
43//! Convenience wrapper for accessing Eigen vector/array/map data as a span
44//! @todo Remove once %Cantera requires Eigen 5.0 or newer.
45template<EigenVectorLike Derived>
46inline span<double> asSpan(Eigen::DenseBase<Derived>& v)
47{
48 return span<double>(v.derived().data(), v.size());
49}
50
51//! Convenience wrapper for accessing Eigen vector/array/map data as a span
52//! @todo Remove once %Cantera requires Eigen 5.0 or newer.
53template<EigenVectorLike Derived>
54inline span<const double> asSpan(const Eigen::DenseBase<Derived>& v)
55{
56 return span<const double>(v.derived().data(), v.size());
57}
58
59}
60
61#endif
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
span< double > asSpan(Eigen::DenseBase< Derived > &v)
Convenience wrapper for accessing Eigen vector/array/map data as a span.
Definition eigen_dense.h:46