26 #if defined (HAVE_CONFIG_H)
122 return x - 3*
static_cast<int> (
x/3);
139 template <
typename T>
147 T absval = (
x < 0 ? -
x :
x);
148 int logabsval =
static_cast<int> (
std::floor (log10 (absval)));
154 ex = logabsval - 2 + ((-logabsval + 2) % 3);
156 ex = logabsval - (logabsval % 3);
162 template <
typename T>
171 template <
typename T>
178 template <
typename T>
182 return m_val /
std::pow (
static_cast<T
> (10), exponent ());
185 template <
typename T>
193 if (real_fmt.
width () >= 0)
197 os << std::setprecision (real_fmt.
precision ());
207 os << std::setw (0) <<
"E-";
209 os << std::setw (0) <<
"e-";
215 os << std::setw (0) <<
"E+";
217 os << std::setw (0) <<
"e+";
221 << std::setfill (
'0') << ex;
226 template <
typename T>
234 if (real_fmt.
width () >= 0)
235 os << std::setw (real_fmt.
width ());
238 os << std::setprecision (real_fmt.
precision ());
247 template <
typename T>
254 bool have_neg_sign = prf.
m_val < 0;
265 os << std::setw (fw);
273 if (s.find (
'/') != std::string::npos)
275 if (s.length () > (
static_cast<unsigned int> (fw)))
282 if (s.length () > (
static_cast<unsigned int> (fw) - 2))
287 if (s.length () > (
static_cast<unsigned int> (fw) - 3))
298 template <
typename T>
303 assert (
m.ndims () == 2);
308 T result = std::numeric_limits<T>::lowest ();
310 bool all_inf_or_nan =
true;
319 all_inf_or_nan =
false;
331 template <
typename T>
340 bool all_inf_or_nan =
true;
349 all_inf_or_nan =
false;
392 template <
typename T>
400 int fw = 0, ld = 0, rd = 0;
409 fw = (digits < 0 ? 4 : digits + 3);
439 rd = (prec > digits ? prec - digits : prec);
444 rd = (prec > digits ? prec - digits : prec);
449 rd = (prec > digits ? prec - 1 : prec);
459 || ld + rd > (1.5 * prec)))
488 fmt =
float_format (fw, ex, prec - 1, std::ios::scientific);
492 else if (!
bank_format && (inf_or_nan || int_only))
505 template <
typename T>
516 T val_abs = (val < 0 ? -val : val);
518 int digits = (inf_or_nan || val_abs == 0) ? 0 :
num_digits (val_abs);
520 return make_real_format<T> (digits, inf_or_nan, int_only);
537 template <
typename T>
540 int int_or_inf_or_nan)
542 T
scale = ((x_max == 0 || int_or_inf_or_nan)
549 int fw = 0, ld = 0, rd = 0;
558 int digits = (x_max > x_min ? x_max : x_min);
559 fw = (digits <= 0 ? 5 : digits + 4);
576 if (inf_or_nan && fw < 4)
579 else if (int_or_inf_or_nan)
581 int digits = (x_max > x_min ? x_max : x_min);
582 fw = (digits <= 0 ? 2 : digits + 1);
583 if (inf_or_nan && fw < 4)
593 rd_max = (prec > x_max ? prec - x_max : prec);
599 rd_max = (prec > x_max ? prec - x_max : prec);
605 rd_max = (prec > 1 ? prec - 1 : prec);
613 rd_min = (prec > x_min ? prec - x_min : prec);
619 rd_min = (prec > x_min ? prec - x_min : prec);
625 rd_min = (prec > 1 ? prec - 1 : prec);
629 ld = (ld_max > ld_min ? ld_max : ld_min);
630 rd = (rd_max > rd_min ? rd_max : rd_min);
632 fw = 1 + ld + 1 + rd;
633 if (inf_or_nan && fw < 4)
642 || ld + rd > (1.5 * prec)))))
649 if (x_max > 100 || x_min > 100)
655 if (inf_or_nan && fw < 6)
662 if (inf_or_nan && fw < 4)
664 fmt =
float_format (fw, prec - 1, std::ios::scientific);
679 template <
typename MT>
683 assert (
m.ndims () == 2);
688 bool inf_or_nan =
m.any_element_is_inf_or_nan ();
690 bool int_or_inf_or_nan =
m.all_elements_are_int_or_inf_or_nan ();
694 typedef typename MT::element_type ELT_T;
699 int x_max = (max_abs == 0 ? 0 :
num_digits (max_abs));
701 int x_min = (min_abs == 0 ? 0 :
num_digits (min_abs));
703 return make_real_matrix_format<ELT_T> (x_max, x_min, inf_or_nan,
721 template <
typename T>
724 bool inf_or_nan,
int int_only)
731 int i_fw = 0, r_fw = 0, ld = 0, rd = 0;
743 r_fw = (digits <= 0 ? 5 : digits + 4);
748 r_fw = 2 *
sizeof (T);
749 i_fw = 2 *
sizeof (T);
754 r_fw = 8 *
sizeof (T);
755 i_fw = 8 *
sizeof (T);
758 else if (inf_or_nan || int_only)
760 int digits = (x_max > x_min ? x_max : x_min);
761 i_fw = (digits <= 0 ? 1 : digits);
763 if (inf_or_nan && i_fw < 3)
781 rd_max = (prec > x_max ? prec - x_max : prec);
787 rd_max = (prec > x_max ? prec - x_max : prec);
793 rd_max = (prec > 1 ? prec - 1 : prec);
801 rd_min = (prec > x_min ? prec - x_min : prec);
807 rd_min = (prec > x_min ? prec - x_min : prec);
813 rd_min = (prec > 1 ? prec - 1 : prec);
817 ld = (ld_max > ld_min ? ld_max : ld_min);
818 rd = (rd_max > rd_min ? rd_max : rd_min);
829 || ld + rd > (1.5 * prec)))
833 int width = prec + 6;
840 if (x_max > 100 || x_min > 100)
845 i_fw = 3 + prec + ex;
847 if (inf_or_nan && i_fw < 5)
852 r_fmt =
float_format (r_fw, ex, prec - 1, std::ios::fixed);
853 i_fmt =
float_format (i_fw, ex, prec - 1, std::ios::fixed);
857 i_fw = 1 + prec + ex;
859 if (inf_or_nan && i_fw < 3)
864 r_fmt =
float_format (r_fw, prec - 1, std::ios::scientific);
865 i_fmt =
float_format (i_fw, prec - 1, std::ios::scientific);
875 else if (!
bank_format && (inf_or_nan || int_only))
889 template <
typename T>
904 T r_abs = (rp < 0 ? -rp : rp);
905 T i_abs = (ip < 0 ? -ip : ip);
926 return make_complex_format<T> (x_max, x_min, r_x, inf_or_nan, int_only);
943 template <
typename T>
946 int r_x_min,
bool inf_or_nan,
947 int int_or_inf_or_nan)
949 T
scale = ((x_max == 0 || int_or_inf_or_nan)
957 int i_fw = 0, r_fw = 0, ld = 0, rd = 0;
967 int digits = (r_x_max > r_x_min ? r_x_max : r_x_min);
969 r_fw = (digits <= 0 ? 5 : digits + 4);
974 r_fw = 2 *
sizeof (T);
975 i_fw = 2 *
sizeof (T);
980 r_fw = 8 *
sizeof (T);
981 i_fw = 8 *
sizeof (T);
989 if (inf_or_nan && i_fw < 3)
995 else if (int_or_inf_or_nan)
997 int digits = (x_max > x_min ? x_max : x_min);
998 i_fw = (digits <= 0 ? 1 : digits);
1000 if (inf_or_nan && i_fw < 3)
1013 rd_max = (prec > x_max ? prec - x_max : prec);
1019 rd_max = (prec > x_max ? prec - x_max : prec);
1025 rd_max = (prec > 1 ? prec - 1 : prec);
1033 rd_min = (prec > x_min ? prec - x_min : prec);
1039 rd_min = (prec > x_min ? prec - x_min : prec);
1045 rd_min = (prec > 1 ? prec - 1 : prec);
1049 ld = (ld_max > ld_min ? ld_max : ld_min);
1050 rd = (rd_max > rd_min ? rd_max : rd_min);
1054 if (inf_or_nan && i_fw < 3)
1067 || ld + rd > (1.5 * prec)))))
1071 int width = prec + 6;
1078 if (x_max > 100 || x_min > 100)
1083 i_fw = 3 + prec + ex;
1085 if (inf_or_nan && i_fw < 5)
1090 r_fmt =
float_format (r_fw, ex, prec - 1, std::ios::fixed);
1091 i_fmt =
float_format (i_fw, ex, prec - 1, std::ios::fixed);
1095 i_fw = 1 + prec + ex;
1097 if (inf_or_nan && i_fw < 3)
1102 r_fmt =
float_format (r_fw, prec - 1, std::ios::scientific);
1103 i_fmt =
float_format (i_fw, prec - 1, std::ios::scientific);
1127 template <
typename CMT>
1134 typedef typename CMT::real_matrix_type RMT;
1135 typedef typename CMT::real_elt_type ELT_T;
1140 bool inf_or_nan = cm.any_element_is_inf_or_nan ();
1142 bool int_or_inf_or_nan = (rp.all_elements_are_int_or_inf_or_nan ()
1143 && ip.all_elements_are_int_or_inf_or_nan ());
1145 RMT r_m_abs = rp.abs ();
1149 RMT i_m_abs = ip.abs ();
1153 int r_x_max = (r_max_abs == 0 ? 0 :
num_digits (r_max_abs));
1155 int r_x_min = (r_min_abs == 0 ? 0 :
num_digits (r_min_abs));
1157 int i_x_max = (i_max_abs == 0 ? 0 :
num_digits (i_max_abs));
1159 int i_x_min = (i_min_abs == 0 ? 0 :
num_digits (i_min_abs));
1161 int x_max = (r_x_max > i_x_max ? r_x_max : i_x_max);
1162 int x_min = (r_x_min > i_x_min ? r_x_min : i_x_min);
1164 return make_complex_matrix_format<ELT_T> (x_max, x_min, r_x_max, r_x_min,
1165 inf_or_nan, int_or_inf_or_nan);
1189 template <
typename T>
1193 double scale = ((x_max == 0 || all_ints)
1200 int fw = 0, ld = 0, rd = 0;
1209 int digits = (x_max > x_min ? x_max : x_min);
1210 fw = (digits < 0 ? 5 : digits + 4);
1215 fw = 2 *
sizeof (T);
1220 fw = 8 *
sizeof (T);
1225 int digits = (x_max > x_min ? x_max : x_min);
1240 rd_max = (prec > x_max ? prec - x_max : prec);
1246 rd_max = (prec > x_max ? prec - x_max : prec);
1252 rd_max = (prec > 1 ? prec - 1 : prec);
1260 rd_min = (prec > x_min ? prec - x_min : prec);
1266 rd_min = (prec > x_min ? prec - x_min : prec);
1272 rd_min = (prec > 1 ? prec - 1 : prec);
1276 ld = (ld_max > ld_min ? ld_max : ld_min);
1277 rd = (rd_max > rd_min ? rd_max : rd_min);
1287 || ld + rd > (1.5 * prec)))))
1294 if (x_max > 100 || x_min > 100)
1300 fmt =
float_format (fw, ex, prec - 1, std::ios::fixed);
1305 fmt =
float_format (fw, prec - 1, std::ios::scientific);
1327 double r_min =
r.base ();
1328 double r_max =
r.limit ();
1337 bool all_ints =
r.all_elements_are_ints ();
1339 double max_abs = (r_max < 0 ? -r_max : r_max);
1340 double min_abs = (r_min < 0 ? -r_min : r_min);
1342 int x_max = (max_abs == 0 ? 0 :
num_digits (max_abs));
1344 int x_min = (min_abs == 0 ? 0 :
num_digits (min_abs));
1346 return make_range_format<double> (x_max, x_min, all_ints);
1349 template <
typename T>
1353 unsigned char i[
sizeof (T)];
1356 #define PRINT_CHAR_BITS(os, c) \
1359 unsigned char ctmp = c; \
1361 stmp[0] = (ctmp & 0x80) ? '1' : '0'; \
1362 stmp[1] = (ctmp & 0x40) ? '1' : '0'; \
1363 stmp[2] = (ctmp & 0x20) ? '1' : '0'; \
1364 stmp[3] = (ctmp & 0x10) ? '1' : '0'; \
1365 stmp[4] = (ctmp & 0x08) ? '1' : '0'; \
1366 stmp[5] = (ctmp & 0x04) ? '1' : '0'; \
1367 stmp[6] = (ctmp & 0x02) ? '1' : '0'; \
1368 stmp[7] = (ctmp & 0x01) ? '1' : '0'; \
1374 #define PRINT_CHAR_BITS_SWAPPED(os, c) \
1377 unsigned char ctmp = c; \
1379 stmp[0] = (ctmp & 0x01) ? '1' : '0'; \
1380 stmp[1] = (ctmp & 0x02) ? '1' : '0'; \
1381 stmp[2] = (ctmp & 0x04) ? '1' : '0'; \
1382 stmp[3] = (ctmp & 0x08) ? '1' : '0'; \
1383 stmp[4] = (ctmp & 0x10) ? '1' : '0'; \
1384 stmp[5] = (ctmp & 0x20) ? '1' : '0'; \
1385 stmp[6] = (ctmp & 0x40) ? '1' : '0'; \
1386 stmp[7] = (ctmp & 0x80) ? '1' : '0'; \
1392 template <
typename T>
1402 int fw = fmt.
width ();
1421 os.flags (std::ios::right | std::ios::hex | std::ios::uppercase);
1423 os.flags (std::ios::right | std::ios::hex);
1428 for (
size_t i = 0; i <
sizeof (T); i++)
1429 os << std::setw (2) <<
static_cast<int> (tmp.
i[i]);
1433 for (
int i =
sizeof (T) - 1; i >= 0; i--)
1434 os << std::setw (2) <<
static_cast<int> (tmp.
i[i]);
1447 for (
size_t i = 0; i <
sizeof (T); i++)
1454 for (
size_t i = 0; i <
sizeof (T); i++)
1459 for (
int i =
sizeof (T) - 1; i >= 0; i--)
1469 os << std::setw (fw) <<
"0";
1478 os << std::setw (fw) <<
"NA";
1483 os << pr_rational_float<T> (fmt, val);
1495 os << std::setw (fw) << s;
1504 os << std::setw (fw) <<
"NaN";
1509 os << pr_engineering_float<T> (fmt, val);
1511 os << pr_formatted_float<T> (fmt, val);
1514 template <
typename T>
1526 template <
typename T>
1538 template <
typename T>
1541 const std::complex<T>& cval)
1571 bool pr_as_read_syntax)
1573 assert (nr == 0 || nc == 0);
1575 if (pr_as_read_syntax)
1577 if (nr == 0 && nc == 0)
1580 os <<
"zeros (" << nr <<
", " << nc <<
')';
1587 os <<
'(' << nr <<
'x' << nc <<
')';
1593 bool pr_as_read_syntax)
1597 if (pr_as_read_syntax)
1598 os <<
"zeros (" << dims.
str (
',') <<
')';
1604 os <<
'(' << dims.
str () <<
')';
1616 << std::setw (8) << std::setprecision (1)
1644 os << std::setw (extra_indent) <<
"";
1647 os <<
" Column " << col + 1 <<
":\n";
1648 else if (num_cols == 2)
1649 os <<
" Columns " << col + 1 <<
" and " << lim <<
":\n";
1651 os <<
" Columns " << col + 1 <<
" through " << lim <<
":\n";
1658 template <
typename T>
1664 else if (val < T (0))
1676 template <
typename T>
1680 return x < 0 ? -
x :
x;
1683 #define INSTANTIATE_ABS(T) \
1691 #define SPECIALIZE_UABS(T) \
1704 #define MAKE_INT_MATRIX_FORMAT(TYPE) \
1706 float_display_format \
1707 make_format (const intNDArray<TYPE>& nda) \
1709 bool isneg = false; \
1712 for (octave_idx_type i = 0; i < nda.numel (); i++) \
1715 = static_cast<int> \
1716 (std::floor (log10 (double (abs (nda(i).value ()))) + 1)); \
1718 if (new_digits > digits) \
1719 digits = new_digits; \
1722 isneg = (abs (nda(i).value ()) != nda(i).value ()); \
1725 return float_display_format (float_format (digits + isneg, 0, 0)); \
1737 #define MAKE_INT_SCALAR_FORMAT(TYPE) \
1739 float_display_format \
1740 make_format (const octave_int<TYPE>& val) \
1742 bool isneg = false; \
1744 = static_cast<int> \
1745 (std::floor (log10 (double (abs (val.value ()))) + 1)); \
1747 isneg = (abs (val.value ()) != val.value ()); \
1749 return float_display_format (float_format (digits + isneg, 0, 0)); \
1763 bool d,
bool pr_as_read_syntax)
1783 double d,
bool pr_as_read_syntax)
1785 if (pr_as_read_syntax)
1800 float d,
bool pr_as_read_syntax)
1802 if (pr_as_read_syntax)
1815 template <
typename MT>
1822 if (pr_as_read_syntax)
1828 os <<
' ' <<
m.elem(i,j);
1834 if (pr_as_read_syntax)
1838 template <
typename MT>
1865 int retval = r_fw + i_fw + 2;
1873 template <
typename MT>
1876 bool pr_as_read_syntax,
int extra_indent)
1881 if (nr == 0 || nc == 0)
1892 if (pr_as_read_syntax)
1895 max_width -= extra_indent;
1909 inc = max_width / column_width;
1914 if (pr_as_read_syntax)
1927 if (i == 0 && j == 0)
1969 os << std::setw (extra_indent) <<
"";
1988 template <
typename DMT>
1991 bool pr_as_read_syntax,
int extra_indent)
1996 if (nr == 0 || nc == 0)
2003 =
make_format (
typename DMT::full_matrix_type (
m.diag ()));
2008 if (pr_as_read_syntax)
2011 max_width -= extra_indent;
2025 inc = max_width / column_width;
2030 if (pr_as_read_syntax)
2069 os <<
"Diagonal Matrix\n";
2078 std::ostringstream tmp_oss;
2079 typename DMT::element_type zero = 0;
2081 zero_fw = tmp_oss.str ().length ();
2093 os << std::setw (extra_indent) <<
"";
2104 os << std::setw (zero_fw) <<
'0';
2115 template <
typename NDA_T,
typename ELT_T,
typename MAT_T>
2117 bool pr_as_read_syntax)
2125 int ndims = nda.ndims ();
2133 for (
int i = 2; i < ndims; i++)
2143 std::string nm =
"ans";
2149 std::ostringstream buf;
2151 for (
int k = 2; k < ndims; k++)
2169 for (
int k = 2; k < ndims; k++)
2192 bool pr_as_read_syntax,
int extra_indent)
2194 switch (nda.
ndims ())
2199 pr_as_read_syntax, extra_indent);
2203 print_nd_array <NDArray, double, Matrix> (os, nda, pr_as_read_syntax);
2210 bool pr_as_read_syntax,
int extra_indent)
2212 switch (nda.
ndims ())
2217 pr_as_read_syntax, extra_indent);
2221 print_nd_array <FloatNDArray, float, FloatMatrix> (os, nda, pr_as_read_syntax);
2226 template <
typename T>
2248 const Complex& c,
bool pr_as_read_syntax)
2250 if (pr_as_read_syntax)
2267 if (pr_as_read_syntax)
2282 bool pr_as_read_syntax,
int extra_indent)
2287 if (nr == 0 || nc == 0)
2294 int column_width = fw + 2;
2298 if (pr_as_read_syntax)
2301 max_width -= extra_indent;
2315 inc = max_width / column_width;
2320 if (pr_as_read_syntax)
2362 os <<
"Permutation Matrix\n";
2375 os << std::setw (extra_indent) <<
"";
2383 os << std::setw (fw) <<
m(i,j);
2396 bool pr_as_read_syntax,
int extra_indent)
2398 switch (nda.
ndims ())
2403 pr_as_read_syntax, extra_indent);
2407 print_nd_array <ComplexNDArray, Complex, ComplexMatrix>
2408 (os, nda, pr_as_read_syntax);
2415 bool pr_as_read_syntax,
int extra_indent)
2417 switch (nda.
ndims ())
2422 pr_as_read_syntax, extra_indent);
2426 print_nd_array <FloatComplexNDArray, FloatComplex, FloatComplexMatrix>
2427 (os, nda, pr_as_read_syntax);
2436 bool pr_as_read_syntax,
int extra_indent)
2443 bool pr_as_read_syntax,
int extra_indent)
2450 bool pr_as_read_syntax,
int extra_indent)
2457 bool pr_as_read_syntax,
int extra_indent)
2464 bool pr_as_read_syntax,
int extra_indent)
2471 bool pr_as_read_syntax,
int extra_indent)
2478 bool pr_as_read_syntax,
int extra_indent)
2485 bool pr_as_read_syntax,
int extra_indent)
2492 bool pr_as_read_syntax,
int extra_indent)
2494 double base =
r.base ();
2495 double increment =
r.inc ();
2496 double limit =
r.limit ();
2505 if (pr_as_read_syntax)
2509 os << base <<
" : ";
2511 os << increment <<
" : ";
2538 os <<
' ' <<
r.elem(i);
2545 inc = max_width / column_width;
2550 max_width -= extra_indent;
2558 while (col < num_elem)
2565 os << std::setw (extra_indent) <<
"";
2575 val = base + i * increment;
2577 if (i == num_elem - 1)
2580 if ((increment > 0 && val >= limit)
2581 || (increment < 0 && val <= limit))
2598 bool pr_as_read_syntax,
2607 bool pr_as_read_syntax,
2610 switch (nda.
ndims ())
2615 pr_as_read_syntax, extra_indent);
2627 bool pr_as_read_syntax,
2635 if (pr_as_read_syntax && nstr > 1)
2646 if (pr_as_read_syntax)
2663 if (pr_as_read_syntax && nstr > 1)
2668 os <<
"sorry, printing char matrices not implemented yet\n";
2674 bool pr_as_read_syntax,
int extra_indent,
2677 switch (nda.
ndims ())
2682 pr_as_read_syntax, extra_indent, pr_as_string);
2686 print_nd_array <charNDArray, char, charMatrix> (os, nda,
2694 bool pr_as_read_syntax,
int extra_indent)
2703 bool pr_as_read_syntax,
int )
2710 else if (nda.
numel () == 1)
2716 int ndims = nda.
ndims ();
2724 for (
int i = 2; i < ndims; i++)
2732 std::string nm =
"ans";
2738 std::ostringstream buf;
2740 for (
int k = 2; k < ndims; k++)
2758 for (
int k = 2; k < ndims; k++)
2776 os <<
" " << page(ii,jj);
2789 template <
typename T>
2797 #define PRINT_CONV(T1, T2) \
2800 octave_print_conv<T1> \
2803 typedef T2 print_conv_type; \
2811 template <
typename T>
2815 size_t sz =
d.byte_size ();
2816 const unsigned char *tmpi =
d.iptr ();
2830 os.flags (std::ios::right | std::ios::hex | std::ios::uppercase);
2832 os.flags (std::ios::right | std::ios::hex);
2836 for (
size_t i = 0; i < sz; i++)
2837 os << std::setw (2) <<
static_cast<int> (tmpi[i]);
2841 for (
int i = sz - 1; i >= 0; i--)
2842 os << std::setw (2) <<
static_cast<int> (tmpi[i]);
2849 for (
size_t i = 0; i < sz; i++)
2856 for (
size_t i = 0; i < sz; i++)
2861 for (
int i = sz - 1; i >= 0; i--)
2870 os << std::setw (fw)
2902 template <
typename T>
2913 os << typename octave_print_conv<octave_int<T>>::print_conv_type (val);
2923 #define PRINT_INT_SCALAR_INTERNAL(TYPE) \
2924 OCTINTERP_API void \
2925 octave_print_internal (std::ostream& os, \
2926 const float_display_format& fmt, \
2927 const octave_int<TYPE>& val, bool dummy) \
2929 octave_print_internal_template (os, fmt, val, dummy); \
2941 template <typename T>
2944 bool pr_as_read_syntax,
int extra_indent)
2951 else if (nda.numel () == 1)
2956 int ndims = nda.ndims ();
2964 for (
int i = 2; i < ndims; i++)
2974 std::string nm =
"ans(:,:,";
2976 std::ostringstream buf;
2978 for (
int k = 2; k < ndims; k++)
3000 for (
int k = 2; k < ndims; k++)
3014 if ((ii < nr - 1) || (i <
m -1))
3027 int ndims = nda.ndims ();
3035 for (
int i = 2; i < ndims; i++)
3043 fw = 2 * nda(0).byte_size ();
3045 fw = nda(0).nbits ();
3057 if (new_digits > digits)
3058 digits = new_digits;
3061 isneg = (
abs (nda(i).value ()) != nda(i).value ());
3064 fw = digits + isneg;
3073 inc = max_width / column_width;
3082 std::string nm =
"ans(:,:,";
3084 std::ostringstream buf;
3086 for (
int k = 2; k < ndims; k++)
3108 for (
int k = 2; k < ndims; k++)
3115 if (pr_as_read_syntax)
3124 os << typename octave_print_conv<T>::print_conv_type (page(ii,jj));
3129 if (pr_as_read_syntax)
3149 os << std::setw (extra_indent) <<
"";
3155 pr_int (os, page(ii,jj), fw);
3157 if ((ii < n_rows - 1) || (i <
m -1))
3172 #define PRINT_INT_ARRAY_INTERNAL(TYPE) \
3173 OCTINTERP_API void \
3174 octave_print_internal (std::ostream& os, const intNDArray<TYPE>& nda, \
3175 bool pr_as_read_syntax, int extra_indent) \
3177 octave_print_internal_template (os, nda, pr_as_read_syntax, extra_indent); \
3201 DEFUN (rats, args, ,
3229 int nargin = args.length ();
3231 if (nargin < 1 || nargin > 2)
3237 error (
"rats: X must be numeric");
3243 if (arg.
ndims () > 2)
3261 std::ostringstream buf;
3263 std::string s = buf.str ();
3265 std::list<std::string> lst;
3268 size_t s_len = s.length ();
3272 size_t m = s.find (
'\n',
n);
3274 if (
m == std::string::npos)
3276 lst.push_back (s.substr (
n));
3281 lst.push_back (s.substr (
n,
m -
n));
3325 DEFUN (disp, args, nargout,
3326 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3351 if (args.length () != 1)
3362 std::ostringstream buf;
3371 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3392 if (args.length () != 2)
3408 error (
"fdisp: stream FID not open for writing");
3453 DEFUN (display, args, ,
3454 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3492 int nargin = args.length ();
3499 if (nargin < 1 || nargin > 2)
3505 name = args(1).xstring_value (
"NAME must be a string");
3520 bool print_newlines =
false;
3616 std::string arg = argv[idx++];
3617 std::transform (arg.begin (), arg.end (), arg.begin (), tolower);
3632 else if (arg ==
"g")
3639 else if (arg ==
"eng")
3649 else if (arg ==
"shorte")
3656 else if (arg ==
"shortg")
3663 else if (arg ==
"shorteng")
3670 else if (arg ==
"long")
3684 else if (arg ==
"g")
3690 else if (arg ==
"eng")
3699 else if (arg ==
"longe")
3706 else if (arg ==
"longg")
3713 else if (arg ==
"longeng")
3720 else if (arg ==
"hex")
3726 else if (arg ==
"native-hex")
3732 else if (arg ==
"bit")
3738 else if (arg ==
"native-bit")
3744 else if (arg ==
"+" || arg ==
"plus")
3753 if (arg.length () == 3)
3765 else if (arg ==
"rat")
3771 else if (arg ==
"bank")
3777 else if (arg ==
"free")
3783 else if (arg ==
"none")
3789 else if (arg ==
"compact")
3791 else if (arg ==
"loose")
3793 else if (arg ==
"lowercase")
3795 else if (arg ==
"uppercase")
3798 error (
"format: unrecognized format state '%s'", arg.c_str ());
3984 int nargin = args.length ();
3988 int argc = nargin + 1;
3997 warning (
"format: cannot query and set format at the same time, ignoring set operation");
4059 DEFUN (fixed_point_format, args, nargout,
4101 DEFUN (print_empty_dimensions, args, nargout,
4131 DEFUN (split_long_rows, args, nargout,
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
charNDArray max(char d, const charNDArray &m)
charNDArray min(char d, const charNDArray &m)
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int ndims(void) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
Template for N-dimensional array classes with like-type math operators.
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Vector representing the dimensions (size) of an Array.
std::string str(char sep='x') const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool any_zero(void) const
void add(F &&fcn, Args &&... args)
static int terminal_cols(void)
int get_file_number(const octave_value &fid) const
stream lookup(int fid, const std::string &who="") const
std::ostream * output_stream(void)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
void print_with_name(std::ostream &os, const std::string &name) const
octave_idx_type rows(void) const
bool isnumeric(void) const
octave_idx_type numel(void) const
bool is_dq_string(void) const
octave_value reshape(const dim_vector &dv) const
bool print_name_tag(std::ostream &os, const std::string &name) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning(const char *fmt,...)
void error(const char *fmt,...)
#define panic_impossible()
void scale(Matrix &m, double x, double y, double z)
ColumnVector transform(const Matrix &m, double x, double y, double z)
#define lo_ieee_signbit(x)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
float_format native_float_format(void)
@ flt_fmt_ieee_big_endian
bool words_big_endian(void)
std::complex< T > floor(const std::complex< T > &x)
bool valid_identifier(const char *s)
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
size_t format(std::ostream &os, const char *fmt,...)
std::string undo_string_escapes(const std::string &s)
std::complex< double > Complex
std::complex< float > FloatComplex
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
std::string rational_approx(T val, int len)
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
int output_precision(void)
void set_output_prec(int prec)
float_display_format make_scalar_format(const T &val)
static float_display_format make_range_format(int x_max, int x_min, int all_ints)
static void init_format_state(void)
static T pr_max_internal(const MArray< T > &m)
static void pr_col_num_header(std::ostream &os, octave_idx_type total_width, int max_width, octave_idx_type lim, octave_idx_type col, int extra_indent)
#define PRINT_INT_SCALAR_INTERNAL(TYPE)
#define MAKE_INT_SCALAR_FORMAT(TYPE)
static void print_empty_matrix(std::ostream &os, octave_idx_type nr, octave_idx_type nc, bool pr_as_read_syntax)
#define PRINT_CONV(T1, T2)
void octave_print_internal_template(std::ostream &os, const float_display_format &fmt, const octave_int< T > &val, bool)
#define PRINT_CHAR_BITS(os, c)
#define SPECIALIZE_UABS(T)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
static void pr_float(std::ostream &os, const float_display_format &fmt, T val)
static int rat_string_len
static void pr_plus_format_matrix(std::ostream &os, const MT &m)
static void pr_plus_format(std::ostream &os, const T &val)
static float_display_format make_complex_format(int x_max, int x_min, int r_x, bool inf_or_nan, int int_only)
#define MAKE_INT_MATRIX_FORMAT(TYPE)
static void pr_int(std::ostream &os, const T &d, int fw=0)
float_display_format make_format(const double &d)
static void print_empty_nd_array(std::ostream &os, const dim_vector &dims, bool pr_as_read_syntax)
static void pr_any_float(std::ostream &os, const float_format &fmt, T val)
static void octave_print_matrix_internal(std::ostream &os, const MT &m, bool pr_as_read_syntax, int extra_indent)
static float_display_format make_matrix_format(const MT &m)
static bool uppercase_format
static int get_column_width(const float_display_format &fmt)
static float_display_format make_real_format(int digits, bool inf_or_nan, bool int_only)
bool Vprint_empty_dimensions
static float_display_format make_complex_matrix_format(int x_max, int x_min, int r_x_max, int r_x_min, bool inf_or_nan, int int_or_inf_or_nan)
static void octave_print_free(std::ostream &os, const MT &m, bool pr_as_read_syntax)
static void set_format_style(int argc, const string_vector &argv)
static std::string format_string("short")
static int calc_scale_exp(const int &x)
#define INSTANTIATE_ABS(T)
#define PRINT_INT_ARRAY_INTERNAL(TYPE)
static bool Vfixed_point_format
static int num_digits(T x)
static T pr_min_internal(const MArray< T > &m)
float_display_format make_complex_scalar_format(const std::complex< T > &c)
static void pr_imag_float(std::ostream &os, const float_display_format &fmt, T val)
static bool Vsplit_long_rows
static void octave_print_diag_matrix_internal(std::ostream &os, const DMT &m, bool pr_as_read_syntax, int extra_indent)
std::ostream & operator<<(std::ostream &os, const pr_engineering_float< T > &pef)
#define PRINT_CHAR_BITS_SWAPPED(os, c)
static int engineering_exponent(T x)
static float_display_format make_real_matrix_format(int x_max, int x_min, bool inf_or_nan, int int_or_inf_or_nan)
static std::string plus_format_chars
static void pr_scale_header(std::ostream &os, double scale)
void print_nd_array(std::ostream &os, const NDA_T &nda, bool pr_as_read_syntax)
static const int max_field_width
static const int digits10
static const int max_field_width
static const int digits10
static const int max_field_width
static const int digits10
unsigned char i[sizeof(T)]
#define SET_INTERNAL_VARIABLE(NM)