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>
189 octave::preserve_stream_state stream_state (os);
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>
230 octave::preserve_stream_state stream_state (os);
234 if (real_fmt.
width () >= 0)
235 os << std::setw (real_fmt.
width ());
238 os << std::setprecision (real_fmt.
precision ());
247 template <
typename T>
251 octave::preserve_stream_state stream_state (os);
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>
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>
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 ();
1406 octave::preserve_stream_state stream_state (os);
1421 os.flags (std::ios::right | std::ios::hex | std::ios::uppercase);
1423 os.flags (std::ios::right | std::ios::hex);
1428 for (std::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 (std::size_t i = 0; i <
sizeof (T); i++)
1454 for (std::size_t i = 0; i <
sizeof (T); i++)
1459 for (
int i =
sizeof (T) - 1; i >= 0; i--)
1466 octave::preserve_stream_state stream_state (os);
1469 os << std::setw (fw) <<
"0";
1475 octave::preserve_stream_state stream_state (os);
1478 os << std::setw (fw) <<
"NA";
1483 os << pr_rational_float<T> (fmt, val);
1486 octave::preserve_stream_state stream_state (os);
1495 os << std::setw (fw) << s;
1501 octave::preserve_stream_state stream_state (os);
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)
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 () <<
')';
1613 octave::preserve_stream_state stream_state (os);
1616 << std::setw (8) << std::setprecision (1)
1632 octave::preserve_stream_state stream_state (os);
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)
1956 octave::preserve_stream_state stream_state (os);
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)
2067 octave::preserve_stream_state stream_state (os);
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)
2360 octave::preserve_stream_state stream_state (os);
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.increment ();
2496 double limit =
r.limit ();
2497 double final_value =
r.final_value ();
2506 if (pr_as_read_syntax)
2510 os << base <<
" : ";
2512 os << increment <<
" : ";
2529 octave::preserve_stream_state stream_state (os);
2539 os <<
' ' <<
r.elem (i);
2546 inc = max_width / column_width;
2551 max_width -= extra_indent;
2559 while (col < num_elem)
2567 os << std::setw (extra_indent) <<
"";
2577 val = base + i * increment;
2579 if (i == num_elem - 1)
2595 bool pr_as_read_syntax,
2604 bool pr_as_read_syntax,
2607 switch (nda.
ndims ())
2612 pr_as_read_syntax, extra_indent);
2624 bool pr_as_read_syntax,
2632 if (pr_as_read_syntax && nstr > 1)
2643 if (pr_as_read_syntax)
2660 if (pr_as_read_syntax && nstr > 1)
2665 os <<
"sorry, printing char matrices not implemented yet\n";
2671 bool pr_as_read_syntax,
int extra_indent,
2674 switch (nda.
ndims ())
2679 pr_as_read_syntax, extra_indent, pr_as_string);
2683 print_nd_array <charNDArray, char, charMatrix> (os, nda,
2691 bool pr_as_read_syntax,
int extra_indent)
2700 bool pr_as_read_syntax,
int )
2707 else if (nda.
numel () == 1)
2713 int ndims = nda.
ndims ();
2721 for (
int i = 2; i < ndims; i++)
2729 std::string nm =
"ans";
2735 std::ostringstream buf;
2737 for (
int k = 2; k < ndims; k++)
2755 for (
int k = 2; k < ndims; k++)
2773 os <<
" " << page(ii, jj);
2786 template <
typename T>
2794 #define PRINT_CONV(T1, T2) \
2797 octave_print_conv<T1> \
2800 typedef T2 print_conv_type; \
2808 template <
typename T>
2812 std::size_t sz =
d.byte_size ();
2813 const unsigned char *tmpi =
d.iptr ();
2823 octave::preserve_stream_state stream_state (os);
2827 os.flags (std::ios::right | std::ios::hex | std::ios::uppercase);
2829 os.flags (std::ios::right | std::ios::hex);
2833 for (std::size_t i = 0; i < sz; i++)
2834 os << std::setw (2) <<
static_cast<int> (tmpi[i]);
2838 for (
int i = sz - 1; i >= 0; i--)
2839 os << std::setw (2) <<
static_cast<int> (tmpi[i]);
2846 for (std::size_t i = 0; i < sz; i++)
2853 for (std::size_t i = 0; i < sz; i++)
2858 for (
int i = sz - 1; i >= 0; i--)
2865 octave::preserve_stream_state stream_state (os);
2867 os << std::setw (fw)
2899 template <
typename T>
2910 os << typename octave_print_conv<octave_int<T>>::print_conv_type (val);
2920 #define PRINT_INT_SCALAR_INTERNAL(TYPE) \
2922 octave_print_internal (std::ostream& os, \
2923 const float_display_format& fmt, \
2924 const octave_int<TYPE>& val, bool dummy) \
2926 octave_print_internal_template (os, fmt, val, dummy); \
2938 template <typename T>
2941 bool pr_as_read_syntax,
int extra_indent)
2948 else if (nda.numel () == 1)
2953 int ndims = nda.ndims ();
2961 for (
int i = 2; i < ndims; i++)
2971 std::string nm =
"ans(:,:,";
2973 std::ostringstream buf;
2975 for (
int k = 2; k < ndims; k++)
2997 for (
int k = 2; k < ndims; k++)
3011 if ((ii < nr - 1) || (i <
m -1))
3024 int ndims = nda.ndims ();
3032 for (
int i = 2; i < ndims; i++)
3040 fw = 2 * nda(0).byte_size ();
3042 fw = nda(0).nbits ();
3054 if (new_digits > digits)
3055 digits = new_digits;
3058 isneg = (
abs (nda(i).value ()) != nda(i).value ());
3061 fw = digits + isneg;
3066 int max_width = octave::command_editor::terminal_cols () - extra_indent;
3070 inc = max_width / column_width;
3079 std::string nm =
"ans(:,:,";
3081 std::ostringstream buf;
3083 for (
int k = 2; k < ndims; k++)
3105 for (
int k = 2; k < ndims; k++)
3112 if (pr_as_read_syntax)
3121 os << typename octave_print_conv<T>::print_conv_type (page(ii, jj));
3126 if (pr_as_read_syntax)
3131 octave::preserve_stream_state stream_state (os);
3146 os << std::setw (extra_indent) <<
"";
3152 pr_int (os, page(ii, jj), fw);
3154 if ((ii < n_rows - 1) || (i <
m -1))
3169 #define PRINT_INT_ARRAY_INTERNAL(TYPE) \
3170 OCTINTERP_API void \
3171 octave_print_internal (std::ostream& os, const intNDArray<TYPE>& nda, \
3172 bool pr_as_read_syntax, int extra_indent) \
3174 octave_print_internal_template (os, nda, pr_as_read_syntax, extra_indent); \
3200 DEFUN (rats, args, ,
3228 int nargin = args.length ();
3230 if (nargin < 1 || nargin > 2)
3236 error (
"rats: X must be numeric");
3242 if (arg.
ndims () > 2)
3260 std::ostringstream buf;
3262 std::string s = buf.str ();
3264 std::list<std::string> lst;
3267 std::size_t s_len = s.length ();
3271 std::size_t
m = s.find (
'\n',
n);
3273 if (
m == std::string::npos)
3275 lst.push_back (s.substr (
n));
3280 lst.push_back (s.substr (
n,
m -
n));
3324 DEFUN (disp, args, nargout,
3325 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3350 if (args.length () != 1)
3361 std::ostringstream buf;
3370 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3391 if (args.length () != 2)
3403 error (
"fdisp: stream FID not open for writing");
3451 DEFUN (display, args, ,
3452 classes: cell
char double function_handle int8 int16 int32 int64 logical single
struct uint8 uint16 uint32 uint64
3490 int nargin = args.length ();
3497 if (nargin < 1 || nargin > 2)
3503 name = args(1).xstring_value (
"NAME must be a string");
3518 bool print_newlines =
false;
3614 std::string arg = argv[idx++];
3615 std::transform (arg.begin (), arg.end (), arg.begin (), tolower);
3617 if (arg ==
"default")
3625 else if (arg ==
"short")
3638 else if (arg ==
"g")
3645 else if (arg ==
"eng")
3655 else if (arg ==
"shorte")
3662 else if (arg ==
"shortg")
3669 else if (arg ==
"shorteng")
3676 else if (arg ==
"long")
3690 else if (arg ==
"g")
3696 else if (arg ==
"eng")
3705 else if (arg ==
"longe")
3712 else if (arg ==
"longg")
3719 else if (arg ==
"longeng")
3726 else if (arg ==
"hex")
3732 else if (arg ==
"native-hex")
3738 else if (arg ==
"bit")
3744 else if (arg ==
"native-bit")
3750 else if (arg ==
"+" || arg ==
"plus")
3759 if (arg.length () == 3)
3771 else if (arg ==
"rat")
3777 else if (arg ==
"bank")
3783 else if (arg ==
"free")
3789 else if (arg ==
"none")
3795 else if (arg ==
"compact")
3797 else if (arg ==
"loose")
3799 else if (arg ==
"lowercase")
3801 else if (arg ==
"uppercase")
3804 error (
"format: unrecognized format state '%s'", arg.c_str ());
4003 int nargin = args.length ();
4007 int argc = nargin + 1;
4016 warning (
"format: cannot query and set format at the same time, ignoring set operation");
4089 DEFUN (fixed_point_format, args, nargout,
4129 "fixed_point_format");
4132 DEFUN (print_empty_dimensions, args, nargout,
4160 "print_empty_dimensions");
4163 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)
OCTARRAY_API Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
OCTARRAY_OVERRIDABLE_FUNC_API bool isempty(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_OVERRIDABLE_FUNC_API const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
OCTARRAY_OVERRIDABLE_FUNC_API int ndims(void) const
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type cols(void) const
Template for N-dimensional array classes with like-type math operators.
void add(F &&fcn, Args &&... args)
void discard(std::size_t num)
OCTAVE_API std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Vector representing the dimensions (size) of an Array.
OCTAVE_API 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 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)
OCTINTERP_API int get_file_number(const octave_value &fid) const
OCTINTERP_API stream lookup(int fid, const std::string &who="") const
std::ostream * output_stream(void)
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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 error_unless(bool cond)
void scale(Matrix &m, double x, double y, double z)
ColumnVector transform(const Matrix &m, double x, double y, double z)
octave::idx_vector idx_vector
#define lo_ieee_signbit(x)
std::complex< T > floor(const std::complex< T > &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
bool words_big_endian(void)
float_format native_float_format(void)
@ flt_fmt_ieee_big_endian
class OCTAVE_API boolNDArray
std::complex< double > Complex
std::complex< float > FloatComplex
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
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.
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_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 DIGITS10
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
unsigned char i[sizeof(T)]
std::string undo_string_escapes(const std::string &s)
bool valid_identifier(const char *s)
std::size_t format(std::ostream &os, const char *fmt,...)
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)