15 std::floating_point
auto value,
24template <std::
floating_po
int F>
27 int precision = std::numeric_limits<F>::max_digits10) {
28 auto begin =
buf.data();
29 if (!std::signbit(value))
31 auto [end,
_] = std::to_chars(begin,
buf.data() +
buf.size(), value,
32 std::chars_format::scientific,
precision);
33 return std::string_view{
buf.data(), end};
36#pragma message "Using std::snprintf as a fallback to replace std::to_chars"
38inline std::string_view
40 int precision = std::numeric_limits<double>::max_digits10) {
44inline std::string_view
46 int precision = std::numeric_limits<float>::max_digits10) {
50 auto &
buf,
long double value,
51 int precision = std::numeric_limits<long double>::max_digits10) {
57#ifdef ALPAQA_WITH_QUAD_PRECISION
60 int precision = std::numeric_limits<__float128>::max_digits10) {
66template <std::
floating_po
int F>
68 std::array<char, 64>
buf;
72template <std::
floating_po
int F>
77template <std::
integral I>
82template <std::
floating_po
int F>
92 std::string_view begin, std::string_view end) {
93 std::array<char, 64>
buf;
96 for (
decltype(
M.rows()) r{}; r <
M.rows(); ++r) {
98 if (r !=
M.rows() - 1)
103 for (
decltype(
M.rows()) r{}; r <
M.rows(); ++r) {
105 for (
decltype(
M.cols()) c{}; c <
M.cols(); ++c) {
107 if (c !=
M.cols() - 1)
118 std::string_view end) {
123 std::array<char, 64>
buf;
124 for (
decltype(
M.rows()) r{}; r <
M.rows(); ++r) {
125 for (
decltype(
M.cols()) c{}; c <
M.cols(); ++c) {
127 if (c !=
M.cols() - 1)
130 if (r !=
M.rows() - 1)
133 return os <<
']' << end;
139 std::string_view end) {
144 std::array<char, 64>
buf;
145 for (
decltype(
M.rows()) r{}; r <
M.rows(); ++r) {
146 for (
decltype(
M.cols()) c{}; c <
M.cols(); ++c) {
148 if (c !=
M.cols() - 1)
151 if (r !=
M.rows() - 1)
154 return os <<
"]]" << end;
std::ostream & print_matlab_impl(std::ostream &os, const T &M, std::string_view end)
std::ostream & print_python_impl(std::ostream &os, const T &M, std::string_view end)
std::ostream & print_csv_impl(std::ostream &os, const T &M, std::string_view sep, std::string_view begin, std::string_view end)
std::string_view float_to_str_vw_snprintf(auto &&print, auto &buf, std::floating_point auto value, int precision, const char *fmt)
std::string_view float_to_str_vw(auto &buf, double value, int precision=std::numeric_limits< double >::max_digits10)
void print_elem(auto &buf, F value, std::ostream &os)
std::string float_to_str(F value, int precision)