Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
EigenAdapter.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4
8
9namespace storm {
10namespace adapters {
11
13 public:
18 template<class ValueType>
19 static std::unique_ptr<Eigen::SparseMatrix<ValueType>> toEigenSparseMatrix(storm::storage::SparseMatrix<ValueType> const& matrix);
20
21 template<typename ValueType>
22 static std::vector<ValueType> toStdVector(Eigen::Matrix<ValueType, Eigen::Dynamic, 1> const& v);
23
24 template<typename ValueType>
25 static Eigen::Matrix<ValueType, Eigen::Dynamic, 1> toEigenVector(std::vector<ValueType> const& v);
26};
27
28} // namespace adapters
29} // namespace storm
30
31namespace std {
32template<class ValueType>
33struct hash<Eigen::Matrix<ValueType, Eigen::Dynamic, 1>> {
34 std::size_t operator()(Eigen::Matrix<ValueType, Eigen::Dynamic, 1> const& vector) const {
35 size_t seed = 0;
36 for (uint_fast64_t i = 0; i < static_cast<uint_fast64_t>(vector.rows()); ++i) {
37 carl::hash_add(seed, std::hash<ValueType>()(vector(i)));
38 }
39 return seed;
40 }
41};
42} // namespace std
43
44namespace Eigen {
45template<>
46struct NumTraits<storm::RationalNumber> : GenericNumTraits<storm::RationalNumber> {
47 typedef storm::RationalNumber Real;
48 typedef storm::RationalNumber NonInteger;
49 typedef storm::RationalNumber Nested;
50 static inline Real epsilon() {
51 return 0;
52 }
53 static inline Real dummy_precision() {
54 return 0;
55 }
56 static inline int digits10() {
57 return 0;
58 }
59 enum { IsInteger = 0, IsSigned = 1, IsComplex = 0, RequireInitialization = 1, ReadCost = 6, AddCost = 150, MulCost = 100 };
60};
61} // namespace Eigen
static Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > toEigenVector(std::vector< ValueType > const &v)
static std::unique_ptr< Eigen::SparseMatrix< ValueType > > toEigenSparseMatrix(storm::storage::SparseMatrix< ValueType > const &matrix)
Converts a sparse matrix into a sparse matrix in the gmm++ format.
static std::vector< ValueType > toStdVector(Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > const &v)
A class that holds a possibly non-square matrix in the compressed row storage format.
std::size_t operator()(Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > const &vector) const