Storm
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
7
9
10namespace storm {
11namespace adapters {
12
14 public:
19 template<class ValueType>
20 static std::unique_ptr<Eigen::SparseMatrix<ValueType>> toEigenSparseMatrix(storm::storage::SparseMatrix<ValueType> const& matrix);
21
22 template<typename ValueType>
23 static std::vector<ValueType> toStdVector(Eigen::Matrix<ValueType, Eigen::Dynamic, 1> const& v);
24
25 template<typename ValueType>
26 static Eigen::Matrix<ValueType, Eigen::Dynamic, 1> toEigenVector(std::vector<ValueType> const& v);
27};
28
29} // namespace adapters
30} // namespace storm
31
32namespace std {
33template<class ValueType>
34struct hash<Eigen::Matrix<ValueType, Eigen::Dynamic, 1>> {
35 std::size_t operator()(Eigen::Matrix<ValueType, Eigen::Dynamic, 1> const& vector) const {
36 size_t seed = 0;
37 for (uint_fast64_t i = 0; i < static_cast<uint_fast64_t>(vector.rows()); ++i) {
38 carl::hash_add(seed, std::hash<ValueType>()(vector(i)));
39 }
40 return seed;
41 }
42};
43} // namespace std
44
45namespace Eigen {
46template<>
47struct NumTraits<storm::RationalNumber> : GenericNumTraits<storm::RationalNumber> {
48 typedef storm::RationalNumber Real;
49 typedef storm::RationalNumber NonInteger;
50 typedef storm::RationalNumber Nested;
51 static inline Real epsilon() {
52 return 0;
53 }
54 static inline Real dummy_precision() {
55 return 0;
56 }
57 static inline int digits10() {
58 return 0;
59 }
60 enum { IsInteger = 0, IsSigned = 1, IsComplex = 0, RequireInitialization = 1, ReadCost = 6, AddCost = 150, MulCost = 100 };
61};
62} // 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.
LabParser.cpp.
Definition cli.cpp:18
std::size_t operator()(Eigen::Matrix< ValueType, Eigen::Dynamic, 1 > const &vector) const