5#ifndef LINE_IO_MARSHAL_H
6#define LINE_IO_MARSHAL_H
52template <
class T,
class S>
54 if (rows > 0 && cols > 0 && data ==
nullptr)
55 throw InputError(
"from_column_major: null buffer with nonzero dimensions");
57 for (std::size_t j = 0; j < cols; ++j)
58 for (std::size_t i = 0; i < rows; ++i)
64template <
class T,
class S>
66 if (rows > 0 && cols > 0 && data ==
nullptr)
67 throw InputError(
"from_row_major: null buffer with nonzero dimensions");
69 for (std::size_t i = 0; i < rows; ++i)
70 for (std::size_t j = 0; j < cols; ++j)
78 if (!m.
empty() && out ==
nullptr)
throw InputError(
"to_column_major: null destination");
79 for (std::size_t j = 0; j < m.
cols(); ++j)
80 for (std::size_t i = 0; i < m.
rows(); ++i)
86void to_host(
const std::vector<T>& v,
double* out) {
87 if (!v.empty() && out ==
nullptr)
throw InputError(
"to_host: null destination");
123 return std::string();
133 return std::string();
147 if (
dynamic_cast<const InputError*
>(&e) !=
nullptr)
return "line:input";
148 if (
dynamic_cast<const NumericError*
>(&e) !=
nullptr)
return "line:numeric";
149 if (
dynamic_cast<const UnsupportedError*
>(&e) !=
nullptr)
return "line:unsupported";
Base error for the multiprecision C++ port.
The algorithm cannot proceed on this instance (singular matrix, ...).
Requested feature or arithmetic mode is not ported yet.
The exception types the port throws.
Dense matrix and non-owning view.
void to_column_major(const Matrix< T > &m, double *out)
Write a Matrix into a column-major host buffer, as doubles.
std::string exact_denominator(const T &)
const char * error_id(const Error &e)
Stable identifier for an error, for mexErrMsgIdAndTxt and for mapping to a host exception class.
ExactValue marshal_scalar(const T &v)
Marshal any T; only the exact instantiation fills numerator/denominator.
Matrix< T > from_column_major(const S *data, std::size_t rows, std::size_t cols)
Build a Matrix from a column-major host buffer (MATLAB's mxGetPr layout, numpy's order='F').
std::string exact_numerator(const T &)
Numerator of an exact value as a decimal string; empty for inexact types.
Matrix< T > from_row_major(const S *data, std::size_t rows, std::size_t cols)
Build a Matrix from a row-major host buffer (numpy's default order='C').
void to_host(const std::vector< T > &v, double *out)
Write a vector into a host buffer, as doubles.
boost::multiprecision::number< boost::multiprecision::cpp_rational_backend, boost::multiprecision::et_off > Rational
Number-type abstraction for the templated API port.
An exact scalar as it crosses to a host without a rational type: the two decimal integer strings,...
bool is_exact
false when the source arithmetic was inexact