7#include "libqsopt_ex.h"
16 mpq_EGlpNumReadStr(val, str);
17 auto result =
new mpq_class(val);
24 mpq_EGlpNumReadStr(val, str);
25 mpq_class result(val);
31 auto const memSize =
static_cast<size_t>(
sizeof(mpq_t) * n_elements +
sizeof(
size_t));
32 void *newArray =
nullptr;
34 newArray = calloc(1, memSize);
36 fprintf(stderr,
"EXIT: Not enough memory while allocating %zd bytes", memSize);
40 size_t *sizeArray = n_elements ?
static_cast<size_t *
>(newArray) :
nullptr;
41 if (n_elements) sizeArray[0] = n_elements;
43 array_ =
reinterpret_cast<mpq_t *
>(n_elements ? (sizeArray + 1) :
nullptr);
44 for (
size_t i = 0; i < n_elements; ++i) mpq_init(
array_[i]);
48 auto *sizeArray =
reinterpret_cast<size_t *
>(
array_);
49 if (sizeArray) sizeArray--;
50 size_t nElements = sizeArray ? sizeArray[0] : 0;
52 for (
size_t i = 0; i < nElements; ++i) mpq_clear(
array_[i]);
68void QSXStart() { QSexactStart(); }
70void QSXFinish() { QSexactClear(); }
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.
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.