dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
libqsopt_ex.h
1
12#pragma once
13
14#ifndef DLINEAR_ENABLED_QSOPTEX
15#error QSopt_ex is not enabled. Please enable it by adding "--//tools:enable_qsoptex" to the bazel command.
16#endif
17
18#include <gmpxx.h>
19
20extern "C" {
21#include <qsopt_ex/QSopt_ex.h> // IWYU pragma: export
22}
23
24#include <string>
25
26// These #defines from <qsopt_ex/QSopt_ex.h> cause problems for us
27// because they mess with SoPlex's enums.
28#undef OPTIMAL
29#undef DUAL_INFEASIBLE
30
31namespace dlinear::qsopt_ex {
32
39mpq_class *StringToMpqPtr(const std::string &str);
45mpq_class StringToMpq(const std::string &str);
52mpq_class *CStringToMpqPtr(const char str[]);
58mpq_class CStringToMpq(const char str[]);
59
66class MpqArray {
67 public:
72 explicit MpqArray(size_t n_elements);
73 MpqArray(const MpqArray &) = delete;
74 MpqArray(MpqArray &&) = delete;
75 MpqArray &operator=(const MpqArray &) = delete;
76 MpqArray &operator=(MpqArray &&) = delete;
78 ~MpqArray();
83 explicit operator const mpq_t *() const { return array_; }
84
89 explicit operator mpq_t *() { return array_; }
90
91 mpq_t &operator[](const int idx) { return array_[idx]; }
92
93 const mpq_t &operator[](const int idx) const { return array_[idx]; }
94
96 [[nodiscard]] size_t size() const { return array_ ? reinterpret_cast<size_t *>(array_)[-1] : 0; }
97
104 void Resize(size_t nElements);
105
106 private:
107 mpq_t *array_;
108
116 void AllocateMpqArray(size_t n_elements);
117
119 void FreeMpqArray();
120};
121
122void QSXStart();
123void QSXFinish();
124
125} // namespace dlinear::qsopt_ex
A wrapper around an array of mpq_t elements.
Definition libqsopt_ex.h:66
void Resize(size_t nElements)
Resize the array to have nElements elements.
MpqArray(size_t n_elements)
Construct a new MpqArray object, allocating the array with n_elements elements.
mpq_t * array_
array of mpq_t. It is allocated by AllocateMpqArray() and freed by FreeMpqArray().
void AllocateMpqArray(size_t n_elements)
Allocate the array with n_elements elements.
void FreeMpqArray()
Free the array of mpq_t.
~MpqArray()
Destroy the MpqArray object, freeing the array.
size_t size() const
Get read-only access to the size of the array.
Definition libqsopt_ex.h:96
mpq_class * CStringToMpqPtr(const char str[])
Convert a C-string to a mpq_class.
mpq_class CStringToMpq(const char str[])
Convert a string to a mpq_class.
mpq_class StringToMpq(const std::string &str)
Convert a string to a mpq_class.
mpq_class * StringToMpqPtr(const std::string &str)
Convert a string to a mpq_class.