delpi
0.0.1
DElta-complete LP solver
Toggle main menu visibility
Loading...
Searching...
No Matches
eigen.h
1
11
#pragma once
12
13
#include <gmpxx.h>
14
15
#include <Eigen/Core>
16
#include <Eigen/LU>
17
18
namespace
Eigen
{
19
template
<>
20
struct
NumTraits<mpq_class> : GenericNumTraits<mpq_class> {
21
typedef
mpq_class Real;
22
typedef
mpq_class NonInteger;
23
typedef
mpq_class Nested;
24
25
static
inline
Real epsilon() {
return
0; }
26
static
inline
Real dummy_precision() {
return
0; }
27
static
inline
int
digits10() {
return
0; }
28
29
enum
{
30
IsInteger = 0,
31
IsSigned = 1,
32
IsComplex = 0,
33
RequireInitialization = 1,
34
ReadCost = 6,
35
AddCost = 150,
36
MulCost = 100
37
};
38
};
39
40
namespace
internal {
41
42
template
<>
43
struct
cast_impl<mpq_class, double> {
44
static
double
run(
const
mpq_class& x) {
return
x.get_d(); }
45
};
46
#if 0
47
template
<>
48
struct
scalar_score_coeff_op<mpq_class> {
49
struct
result_type {
50
std::size_t len;
51
explicit
result_type(
const
int
i = 0) : len(i) {}
// Eigen uses Score(0) and Score()
52
explicit
result_type(
const
mpq_class& q) : len(mpz_size(q.get_num_mpz_t()) + mpz_size(q.get_den_mpz_t()) - 1) {}
53
std::strong_ordering operator<=>(
const
result_type& y)
const
{
54
if
(len == y.len)
return
std::strong_ordering::equal;
55
return
(len < y.len) ? std::strong_ordering::less : std::strong_ordering::greater;
56
}
57
};
58
result_type operator()(
const
mpq_class& x)
const
{
return
result_type{x}; }
59
};
60
#endif
61
}
// namespace internal
62
}
// namespace Eigen
63
64
namespace
delpi
{
65
using
EMatrix = Eigen::MatrixX<mpq_class>;
66
using
EVector = Eigen::VectorX<mpq_class>;
67
using
DMatrix = Eigen::MatrixXd;
68
using
DVector = Eigen::VectorXd;
69
template
<
class
T>
70
using
Matrix = Eigen::MatrixX<T>;
71
template
<
class
T>
72
using
Vector = Eigen::VectorX<T>;
73
template
<
class
T>
74
using
VectorView = Eigen::Map<Eigen::VectorX<T>>;
75
template
<
class
T>
76
using
MatrixView = Eigen::Map<Eigen::MatrixX<T>>;
77
using
Index = Eigen::Index;
78
using
VectorD = Vector<double>;
79
using
VectorQ = Vector<mpq_class>;
80
using
MatrixD = Matrix<double>;
81
using
MatrixQ = Matrix<mpq_class>;
82
83
}
// namespace delpi
84
85
#ifdef DELPI_INCLUDE_FMT
86
87
#include "delpi/util/logging.h"
88
89
OSTREAM_FORMATTER(delpi::Matrix<mpq_class>)
90
OSTREAM_FORMATTER(delpi::Matrix<double>)
91
92
#endif
Eigen
Definition
eigen.h:18
delpi
Global namespace for the delpi library.
delpi
libs
eigen.h
Generated by
1.17.0