1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
1346
|
28 #include <cfloat> |
3124
|
29 #include <cmath> |
2825
|
30 #include <cstdio> |
1346
|
31 #include <cstring> |
1343
|
32 |
3503
|
33 #include <iomanip> |
|
34 #include <iostream> |
5765
|
35 #include <sstream> |
1728
|
36 #include <string> |
|
37 |
4655
|
38 #include "Array-util.h" |
453
|
39 #include "CMatrix.h" |
1
|
40 #include "Range.h" |
2926
|
41 #include "cmd-edit.h" |
1352
|
42 #include "dMatrix.h" |
2891
|
43 #include "lo-mappers.h" |
2317
|
44 #include "mach-info.h" |
1651
|
45 #include "oct-cmplx.h" |
4153
|
46 #include "quit.h" |
1755
|
47 #include "str-vec.h" |
1
|
48 |
3933
|
49 #include "Cell.h" |
1352
|
50 #include "defun.h" |
|
51 #include "error.h" |
2165
|
52 #include "gripes.h" |
1755
|
53 #include "oct-obj.h" |
3685
|
54 #include "oct-stream.h" |
1352
|
55 #include "pager.h" |
|
56 #include "pr-output.h" |
1282
|
57 #include "sysdep.h" |
1
|
58 #include "utils.h" |
1352
|
59 #include "variables.h" |
1
|
60 |
3105
|
61 // TRUE means use a scaled fixed point format for `format long' and |
|
62 // `format short'. |
5794
|
63 static bool Vfixed_point_format = false; |
3105
|
64 |
2165
|
65 // The maximum field width for a number printed by the default output |
|
66 // routines. |
5794
|
67 static int Voutput_max_field_width = 10; |
2165
|
68 |
|
69 // The precision of the numbers printed by the default output |
|
70 // routines. |
5794
|
71 static int Voutput_precision = 5; |
2165
|
72 |
5360
|
73 // TRUE means that the dimensions of empty objects should be printed |
2165
|
74 // like this: x = [](2x0). |
5794
|
75 bool Vprint_empty_dimensions = true; |
2165
|
76 |
|
77 // TRUE means that the rows of big matrices should be split into |
|
78 // smaller slices that fit on the screen. |
5794
|
79 static bool Vsplit_long_rows = true; |
2165
|
80 |
5759
|
81 // How many levels of structure elements should we print? |
5794
|
82 int Vstruct_levels_to_print = 2; |
5759
|
83 |
3018
|
84 // TRUE means don't do any fancy formatting. |
2387
|
85 static bool free_format = false; |
1
|
86 |
3018
|
87 // TRUE means print plus sign for nonzero, blank for zero. |
2387
|
88 static bool plus_format = false; |
1
|
89 |
4632
|
90 // First char for > 0, second for < 0, third for == 0. |
|
91 static std::string plus_format_chars = "+ "; |
|
92 |
3018
|
93 // TRUE means always print like dollars and cents. |
2387
|
94 static bool bank_format = false; |
1282
|
95 |
3018
|
96 // TRUE means print data in hexadecimal format. |
3608
|
97 static int hex_format = 0; |
1282
|
98 |
3018
|
99 // TRUE means print data in binary-bit-pattern format. |
1309
|
100 static int bit_format = 0; |
|
101 |
3018
|
102 // TRUE means don't put newlines around the column number headers. |
2387
|
103 static bool compact_format = false; |
1186
|
104 |
3018
|
105 // TRUE means use an e format. |
2387
|
106 static bool print_e = false; |
1
|
107 |
4509
|
108 // TRUE means use a g format. |
|
109 static bool print_g = false; |
|
110 |
3018
|
111 // TRUE means print E instead of e for exponent field. |
2387
|
112 static bool print_big_e = false; |
1
|
113 |
3608
|
114 class pr_formatted_float; |
|
115 |
4509
|
116 static int |
|
117 current_output_max_field_width (void) |
|
118 { |
|
119 return Voutput_max_field_width; |
|
120 } |
|
121 |
|
122 static int |
|
123 current_output_precision (void) |
|
124 { |
|
125 return Voutput_precision; |
|
126 } |
|
127 |
3608
|
128 class |
|
129 float_format |
|
130 { |
|
131 public: |
|
132 |
4509
|
133 float_format (int w = current_output_max_field_width (), |
|
134 int p = current_output_precision (), int f = 0) |
3608
|
135 : fw (w), prec (p), fmt (f), up (0), sp (0) { } |
|
136 |
|
137 float_format (const float_format& ff) |
|
138 : fw (ff.fw), prec (ff.prec), fmt (ff.fmt), up (ff.up), sp (ff.sp) { } |
|
139 |
|
140 float_format& operator = (const float_format& ff) |
|
141 { |
|
142 if (&ff != this) |
|
143 { |
|
144 fw = ff.fw; |
|
145 prec = ff.prec; |
|
146 fmt = ff.fmt; |
|
147 up = ff.up; |
|
148 sp = ff.sp; |
|
149 } |
|
150 |
|
151 return *this; |
|
152 } |
|
153 |
|
154 ~float_format (void) { } |
|
155 |
|
156 float_format& scientific (void) { fmt = std::ios::scientific; return *this; } |
|
157 float_format& fixed (void) { fmt = std::ios::fixed; return *this; } |
|
158 float_format& general (void) { fmt = 0; return *this; } |
|
159 |
|
160 float_format& uppercase (void) { up = std::ios::uppercase; return *this; } |
|
161 float_format& lowercase (void) { up = 0; return *this; } |
|
162 |
|
163 float_format& precision (int p) { prec = p; return *this; } |
|
164 |
|
165 float_format& width (int w) { fw = w; return *this; } |
|
166 |
|
167 float_format& trailing_zeros (bool tz = true) |
|
168 { sp = tz ? std::ios::showpoint : 0; return *this; } |
|
169 |
|
170 friend std::ostream& operator << (std::ostream& os, |
|
171 const pr_formatted_float& pff); |
|
172 |
|
173 private: |
|
174 |
|
175 // Field width. Zero means as wide as necessary. |
|
176 int fw; |
|
177 |
|
178 // Precision. |
|
179 int prec; |
|
180 |
|
181 // Format. |
|
182 int fmt; |
|
183 |
|
184 // E or e. |
|
185 int up; |
|
186 |
|
187 // Show trailing zeros. |
|
188 int sp; |
|
189 }; |
|
190 |
|
191 class |
|
192 pr_formatted_float |
|
193 { |
|
194 public: |
|
195 |
|
196 const float_format& f; |
|
197 |
|
198 double val; |
|
199 |
|
200 pr_formatted_float (const float_format& f_arg, double val_arg) |
|
201 : f (f_arg), val (val_arg) { } |
|
202 }; |
|
203 |
|
204 std::ostream& |
|
205 operator << (std::ostream& os, const pr_formatted_float& pff) |
|
206 { |
3682
|
207 if (pff.f.fw >= 0) |
3608
|
208 os << std::setw (pff.f.fw); |
|
209 |
3682
|
210 if (pff.f.prec >= 0) |
3608
|
211 os << std::setprecision (pff.f.prec); |
|
212 |
3775
|
213 std::ios::fmtflags oflags = |
|
214 os.flags (static_cast<std::ios::fmtflags> |
|
215 (pff.f.fmt | pff.f.up | pff.f.sp)); |
3608
|
216 |
|
217 os << pff.val; |
|
218 |
|
219 os.flags (oflags); |
|
220 |
|
221 return os; |
|
222 } |
|
223 |
|
224 // Current format for real numbers and the real part of complex |
|
225 // numbers. |
|
226 static float_format *curr_real_fmt = 0; |
|
227 |
|
228 // Current format for the imaginary part of complex numbers. |
|
229 static float_format *curr_imag_fmt = 0; |
1309
|
230 |
1
|
231 static double |
164
|
232 pr_max_internal (const Matrix& m) |
1
|
233 { |
5275
|
234 octave_idx_type nr = m.rows (); |
|
235 octave_idx_type nc = m.columns (); |
1
|
236 |
3130
|
237 double result = -DBL_MAX; |
1
|
238 |
5748
|
239 bool all_inf_or_nan = true; |
|
240 |
5275
|
241 for (octave_idx_type j = 0; j < nc; j++) |
|
242 for (octave_idx_type i = 0; i < nr; i++) |
1
|
243 { |
3608
|
244 double val = m(i,j); |
5388
|
245 if (xisinf (val) || xisnan (val)) |
1
|
246 continue; |
|
247 |
5748
|
248 all_inf_or_nan = false; |
|
249 |
1
|
250 if (val > result) |
|
251 result = val; |
|
252 } |
3608
|
253 |
5748
|
254 if (all_inf_or_nan) |
|
255 result = 0.0; |
|
256 |
1
|
257 return result; |
|
258 } |
|
259 |
|
260 static double |
164
|
261 pr_min_internal (const Matrix& m) |
1
|
262 { |
5275
|
263 octave_idx_type nr = m.rows (); |
|
264 octave_idx_type nc = m.columns (); |
1
|
265 |
|
266 double result = DBL_MAX; |
|
267 |
5748
|
268 bool all_inf_or_nan = true; |
|
269 |
5275
|
270 for (octave_idx_type j = 0; j < nc; j++) |
|
271 for (octave_idx_type i = 0; i < nr; i++) |
1
|
272 { |
3608
|
273 double val = m(i,j); |
5389
|
274 if (xisinf (val) || xisnan (val)) |
1
|
275 continue; |
|
276 |
5748
|
277 all_inf_or_nan = false; |
|
278 |
1
|
279 if (val < result) |
|
280 result = val; |
|
281 } |
3608
|
282 |
5748
|
283 if (all_inf_or_nan) |
|
284 result = 0.0; |
|
285 |
1
|
286 return result; |
|
287 } |
|
288 |
5775
|
289 // FIXME -- it would be nice to share more code among these |
1658
|
290 // functions,.. |
|
291 |
1
|
292 static void |
3611
|
293 set_real_format (bool sign, int digits, bool inf_or_nan, bool int_only, |
1658
|
294 int &fw) |
1
|
295 { |
3608
|
296 static float_format fmt; |
1
|
297 |
2165
|
298 int prec = Voutput_precision; |
1
|
299 |
|
300 int ld, rd; |
|
301 |
|
302 if (bank_format) |
|
303 { |
|
304 fw = digits < 0 ? 4 : digits + 3; |
5748
|
305 if (inf_or_nan && fw < 4) |
|
306 fw = 4; |
1
|
307 rd = 2; |
|
308 } |
1282
|
309 else if (hex_format) |
|
310 { |
|
311 fw = 2 * sizeof (double); |
|
312 rd = 0; |
|
313 } |
1309
|
314 else if (bit_format) |
|
315 { |
|
316 fw = 8 * sizeof (double); |
|
317 rd = 0; |
|
318 } |
3611
|
319 else if (inf_or_nan || int_only) |
1
|
320 { |
5832
|
321 fw = 1 + digits; |
5748
|
322 if (inf_or_nan && fw < 4) |
|
323 fw = 4; |
3682
|
324 rd = fw; |
1
|
325 } |
|
326 else |
|
327 { |
|
328 if (digits > 0) |
|
329 { |
|
330 ld = digits; |
1658
|
331 rd = prec > digits ? prec - digits : prec; |
1
|
332 digits++; |
|
333 } |
|
334 else |
|
335 { |
|
336 ld = 1; |
1658
|
337 rd = prec > digits ? prec - digits : prec; |
1
|
338 digits = -digits + 1; |
|
339 } |
|
340 |
5832
|
341 fw = 1 + ld + 1 + rd; |
5748
|
342 if (inf_or_nan && fw < 4) |
|
343 fw = 4; |
1
|
344 } |
|
345 |
1309
|
346 if (! (bank_format || hex_format || bit_format) |
4509
|
347 && (fw > Voutput_max_field_width || print_e || print_g)) |
1
|
348 { |
4509
|
349 if (print_g) |
|
350 fmt = float_format (); |
|
351 else |
|
352 { |
|
353 int exp_field = 4; |
|
354 if (digits > 100) |
|
355 exp_field++; |
1
|
356 |
4509
|
357 fw = 2 + prec + exp_field; |
5748
|
358 if (inf_or_nan && fw < 4) |
|
359 fw = 4; |
1
|
360 |
4509
|
361 fmt = float_format (fw, prec - 1, std::ios::scientific); |
|
362 } |
3608
|
363 |
1
|
364 if (print_big_e) |
3608
|
365 fmt.uppercase (); |
1
|
366 } |
5086
|
367 else if (! bank_format && (inf_or_nan || int_only)) |
3611
|
368 fmt = float_format (fw, rd); |
1
|
369 else |
3608
|
370 fmt = float_format (fw, rd, std::ios::fixed); |
1
|
371 |
3608
|
372 curr_real_fmt = &fmt; |
1
|
373 } |
|
374 |
1658
|
375 static void |
|
376 set_format (double d, int& fw) |
|
377 { |
|
378 curr_real_fmt = 0; |
|
379 curr_imag_fmt = 0; |
|
380 |
|
381 if (free_format) |
|
382 return; |
|
383 |
2387
|
384 bool sign = (d < 0.0); |
1658
|
385 |
5389
|
386 bool inf_or_nan = (xisinf (d) || xisnan (d)); |
1658
|
387 |
3611
|
388 bool int_only = (! inf_or_nan && D_NINT (d) == d); |
1658
|
389 |
|
390 double d_abs = d < 0.0 ? -d : d; |
|
391 |
2800
|
392 int digits = (inf_or_nan || d_abs == 0.0) |
|
393 ? 0 : static_cast<int> (floor (log10 (d_abs) + 1.0)); |
1658
|
394 |
3611
|
395 set_real_format (sign, digits, inf_or_nan, int_only, fw); |
1658
|
396 } |
|
397 |
1
|
398 static inline void |
|
399 set_format (double d) |
|
400 { |
|
401 int fw; |
|
402 set_format (d, fw); |
|
403 } |
|
404 |
|
405 static void |
2387
|
406 set_real_matrix_format (bool sign, int x_max, int x_min, |
|
407 bool inf_or_nan, int int_or_inf_or_nan, int& fw) |
1
|
408 { |
3608
|
409 static float_format fmt; |
1
|
410 |
2165
|
411 int prec = Voutput_precision; |
1
|
412 |
|
413 int ld, rd; |
|
414 |
|
415 if (bank_format) |
|
416 { |
|
417 int digits = x_max > x_min ? x_max : x_min; |
|
418 fw = digits <= 0 ? 4 : digits + 3; |
5748
|
419 if (inf_or_nan && fw < 4) |
|
420 fw = 4; |
1
|
421 rd = 2; |
|
422 } |
1282
|
423 else if (hex_format) |
|
424 { |
|
425 fw = 2 * sizeof (double); |
|
426 rd = 0; |
|
427 } |
1309
|
428 else if (bit_format) |
|
429 { |
|
430 fw = 8 * sizeof (double); |
|
431 rd = 0; |
|
432 } |
4509
|
433 else if (Vfixed_point_format && ! print_g) |
3268
|
434 { |
|
435 rd = prec; |
|
436 fw = rd + 2; |
5748
|
437 if (inf_or_nan && fw < 4) |
|
438 fw = 4; |
3268
|
439 } |
1715
|
440 else if (int_or_inf_or_nan) |
1
|
441 { |
|
442 int digits = x_max > x_min ? x_max : x_min; |
5945
|
443 fw = digits <= 0 ? 2 : digits + 1; |
5748
|
444 if (inf_or_nan && fw < 4) |
|
445 fw = 4; |
3682
|
446 rd = fw; |
1
|
447 } |
|
448 else |
|
449 { |
|
450 int ld_max, rd_max; |
|
451 if (x_max > 0) |
|
452 { |
|
453 ld_max = x_max; |
1658
|
454 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
455 x_max++; |
|
456 } |
|
457 else |
|
458 { |
|
459 ld_max = 1; |
1658
|
460 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
461 x_max = -x_max + 1; |
|
462 } |
|
463 |
|
464 int ld_min, rd_min; |
|
465 if (x_min > 0) |
|
466 { |
|
467 ld_min = x_min; |
1658
|
468 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
469 x_min++; |
|
470 } |
|
471 else |
|
472 { |
|
473 ld_min = 1; |
1658
|
474 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
475 x_min = -x_min + 1; |
|
476 } |
|
477 |
|
478 ld = ld_max > ld_min ? ld_max : ld_min; |
|
479 rd = rd_max > rd_min ? rd_max : rd_min; |
|
480 |
5832
|
481 fw = 1 + ld + 1 + rd; |
5748
|
482 if (inf_or_nan && fw < 4) |
|
483 fw = 4; |
1
|
484 } |
|
485 |
1658
|
486 if (! (bank_format || hex_format || bit_format) |
3105
|
487 && (print_e |
4509
|
488 || print_g |
3105
|
489 || (! Vfixed_point_format && fw > Voutput_max_field_width))) |
1
|
490 { |
4509
|
491 if (print_g) |
|
492 fmt = float_format (); |
|
493 else |
|
494 { |
|
495 int exp_field = 4; |
|
496 if (x_max > 100 || x_min > 100) |
|
497 exp_field++; |
1
|
498 |
4509
|
499 fw = 2 + prec + exp_field; |
5748
|
500 if (inf_or_nan && fw < 4) |
|
501 fw = 4; |
1
|
502 |
4509
|
503 fmt = float_format (fw, prec - 1, std::ios::scientific); |
|
504 } |
3608
|
505 |
1
|
506 if (print_big_e) |
3608
|
507 fmt.uppercase (); |
1
|
508 } |
5086
|
509 else if (! bank_format && int_or_inf_or_nan) |
3611
|
510 fmt = float_format (fw, rd); |
1
|
511 else |
3608
|
512 fmt = float_format (fw, rd, std::ios::fixed); |
1
|
513 |
3608
|
514 curr_real_fmt = &fmt; |
1
|
515 } |
|
516 |
1658
|
517 static void |
3105
|
518 set_format (const Matrix& m, int& fw, double& scale) |
1658
|
519 { |
|
520 curr_real_fmt = 0; |
|
521 curr_imag_fmt = 0; |
|
522 |
|
523 if (free_format) |
|
524 return; |
|
525 |
4431
|
526 bool sign = m.any_element_is_negative (true); |
1658
|
527 |
2387
|
528 bool inf_or_nan = m.any_element_is_inf_or_nan (); |
1658
|
529 |
2387
|
530 bool int_or_inf_or_nan = m.all_elements_are_int_or_inf_or_nan (); |
1658
|
531 |
2387
|
532 Matrix m_abs = m.abs (); |
1658
|
533 double max_abs = pr_max_internal (m_abs); |
|
534 double min_abs = pr_min_internal (m_abs); |
|
535 |
2800
|
536 int x_max = max_abs == 0.0 |
|
537 ? 0 : static_cast<int> (floor (log10 (max_abs) + 1.0)); |
|
538 |
|
539 int x_min = min_abs == 0.0 |
|
540 ? 0 : static_cast<int> (floor (log10 (min_abs) + 1.0)); |
1658
|
541 |
4270
|
542 scale = (x_max == 0 || int_or_inf_or_nan) ? 1.0 : std::pow (10.0, x_max - 1); |
3105
|
543 |
1658
|
544 set_real_matrix_format (sign, x_max, x_min, inf_or_nan, |
1715
|
545 int_or_inf_or_nan, fw); |
1658
|
546 } |
|
547 |
1
|
548 static inline void |
164
|
549 set_format (const Matrix& m) |
1
|
550 { |
|
551 int fw; |
3105
|
552 double scale; |
|
553 set_format (m, fw, scale); |
1
|
554 } |
|
555 |
|
556 static void |
2387
|
557 set_complex_format (bool sign, int x_max, int x_min, int r_x, |
|
558 bool inf_or_nan, int int_only, int& r_fw, int& i_fw) |
1
|
559 { |
3608
|
560 static float_format r_fmt; |
|
561 static float_format i_fmt; |
1
|
562 |
2165
|
563 int prec = Voutput_precision; |
1
|
564 |
|
565 int ld, rd; |
|
566 |
|
567 if (bank_format) |
|
568 { |
|
569 int digits = r_x; |
|
570 i_fw = 0; |
|
571 r_fw = digits <= 0 ? 4 : digits + 3; |
5748
|
572 if (inf_or_nan && r_fw < 4) |
|
573 r_fw = 4; |
1
|
574 rd = 2; |
|
575 } |
1282
|
576 else if (hex_format) |
|
577 { |
|
578 r_fw = 2 * sizeof (double); |
|
579 i_fw = 2 * sizeof (double); |
|
580 rd = 0; |
|
581 } |
1309
|
582 else if (bit_format) |
|
583 { |
|
584 r_fw = 8 * sizeof (double); |
|
585 i_fw = 8 * sizeof (double); |
|
586 rd = 0; |
|
587 } |
1658
|
588 else if (inf_or_nan || int_only) |
1
|
589 { |
|
590 int digits = x_max > x_min ? x_max : x_min; |
5945
|
591 i_fw = digits <= 0 ? 1 : digits; |
|
592 r_fw = i_fw + 1; |
|
593 if (inf_or_nan && i_fw < 3) |
|
594 { |
|
595 i_fw = 3; |
|
596 r_fw = 4; |
|
597 } |
3682
|
598 rd = r_fw; |
1
|
599 } |
|
600 else |
|
601 { |
|
602 int ld_max, rd_max; |
|
603 if (x_max > 0) |
|
604 { |
|
605 ld_max = x_max; |
1658
|
606 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
607 x_max++; |
|
608 } |
|
609 else |
|
610 { |
|
611 ld_max = 1; |
1658
|
612 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
613 x_max = -x_max + 1; |
|
614 } |
|
615 |
|
616 int ld_min, rd_min; |
|
617 if (x_min > 0) |
|
618 { |
|
619 ld_min = x_min; |
1658
|
620 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
621 x_min++; |
|
622 } |
|
623 else |
|
624 { |
|
625 ld_min = 1; |
1658
|
626 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
627 x_min = -x_min + 1; |
|
628 } |
|
629 |
|
630 ld = ld_max > ld_min ? ld_max : ld_min; |
|
631 rd = rd_max > rd_min ? rd_max : rd_min; |
|
632 |
5945
|
633 i_fw = ld + 1 + rd; |
|
634 r_fw = i_fw + 1; |
|
635 if (inf_or_nan && i_fw < 3) |
|
636 { |
|
637 i_fw = 3; |
|
638 r_fw = 4; |
|
639 } |
1
|
640 } |
|
641 |
1309
|
642 if (! (bank_format || hex_format || bit_format) |
4509
|
643 && (r_fw > Voutput_max_field_width || print_e || print_g)) |
1
|
644 { |
4509
|
645 if (print_g) |
|
646 { |
|
647 r_fmt = float_format (); |
|
648 i_fmt = float_format (); |
|
649 } |
|
650 else |
|
651 { |
|
652 int exp_field = 4; |
|
653 if (x_max > 100 || x_min > 100) |
|
654 exp_field++; |
1
|
655 |
5945
|
656 i_fw = prec + exp_field; |
|
657 r_fw = i_fw + 1; |
|
658 if (inf_or_nan && i_fw < 3) |
|
659 { |
|
660 i_fw = 3; |
|
661 r_fw = 4; |
|
662 } |
1
|
663 |
4509
|
664 r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); |
|
665 i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); |
|
666 } |
3608
|
667 |
1
|
668 if (print_big_e) |
|
669 { |
3608
|
670 r_fmt.uppercase (); |
|
671 i_fmt.uppercase (); |
1
|
672 } |
|
673 } |
5086
|
674 else if (! bank_format && (inf_or_nan || int_only)) |
3611
|
675 { |
|
676 r_fmt = float_format (r_fw, rd); |
|
677 i_fmt = float_format (i_fw, rd); |
|
678 } |
1
|
679 else |
|
680 { |
3608
|
681 r_fmt = float_format (r_fw, rd, std::ios::fixed); |
|
682 i_fmt = float_format (i_fw, rd, std::ios::fixed); |
1
|
683 } |
|
684 |
3608
|
685 curr_real_fmt = &r_fmt; |
|
686 curr_imag_fmt = &i_fmt; |
1
|
687 } |
|
688 |
1658
|
689 static void |
|
690 set_format (const Complex& c, int& r_fw, int& i_fw) |
|
691 { |
|
692 curr_real_fmt = 0; |
|
693 curr_imag_fmt = 0; |
|
694 |
|
695 if (free_format) |
|
696 return; |
|
697 |
|
698 double rp = c.real (); |
|
699 double ip = c.imag (); |
|
700 |
2387
|
701 bool sign = (rp < 0.0); |
1658
|
702 |
2387
|
703 bool inf_or_nan = (xisinf (c) || xisnan (c)); |
1658
|
704 |
2387
|
705 bool int_only = (D_NINT (rp) == rp && D_NINT (ip) == ip); |
1658
|
706 |
|
707 double r_abs = rp < 0.0 ? -rp : rp; |
|
708 double i_abs = ip < 0.0 ? -ip : ip; |
|
709 |
2800
|
710 int r_x = r_abs == 0.0 |
|
711 ? 0 : static_cast<int> (floor (log10 (r_abs) + 1.0)); |
|
712 |
|
713 int i_x = i_abs == 0.0 |
|
714 ? 0 : static_cast<int> (floor (log10 (i_abs) + 1.0)); |
1658
|
715 |
|
716 int x_max, x_min; |
|
717 |
|
718 if (r_x > i_x) |
|
719 { |
|
720 x_max = r_x; |
|
721 x_min = i_x; |
|
722 } |
|
723 else |
|
724 { |
|
725 x_max = i_x; |
|
726 x_min = r_x; |
|
727 } |
|
728 |
|
729 set_complex_format (sign, x_max, x_min, r_x, inf_or_nan, int_only, |
|
730 r_fw, i_fw); |
|
731 } |
|
732 |
1
|
733 static inline void |
164
|
734 set_format (const Complex& c) |
1
|
735 { |
|
736 int r_fw, i_fw; |
|
737 set_format (c, r_fw, i_fw); |
|
738 } |
|
739 |
|
740 static void |
2387
|
741 set_complex_matrix_format (bool sign, int x_max, int x_min, |
|
742 int r_x_max, int r_x_min, bool inf_or_nan, |
1715
|
743 int int_or_inf_or_nan, int& r_fw, int& i_fw) |
1
|
744 { |
3608
|
745 static float_format r_fmt; |
|
746 static float_format i_fmt; |
1
|
747 |
2165
|
748 int prec = Voutput_precision; |
1
|
749 |
|
750 int ld, rd; |
|
751 |
|
752 if (bank_format) |
|
753 { |
|
754 int digits = r_x_max > r_x_min ? r_x_max : r_x_min; |
|
755 i_fw = 0; |
|
756 r_fw = digits <= 0 ? 4 : digits + 3; |
5945
|
757 if (inf_or_nan && r_fw < 4) |
|
758 r_fw = 4; |
1
|
759 rd = 2; |
|
760 } |
1282
|
761 else if (hex_format) |
|
762 { |
|
763 r_fw = 2 * sizeof (double); |
|
764 i_fw = 2 * sizeof (double); |
|
765 rd = 0; |
|
766 } |
1309
|
767 else if (bit_format) |
|
768 { |
|
769 r_fw = 8 * sizeof (double); |
|
770 i_fw = 8 * sizeof (double); |
|
771 rd = 0; |
|
772 } |
4509
|
773 else if (Vfixed_point_format && ! print_g) |
3268
|
774 { |
|
775 rd = prec; |
5945
|
776 i_fw = rd + 1; |
|
777 r_fw = i_fw + 1; |
|
778 if (inf_or_nan && i_fw < 3) |
|
779 { |
|
780 i_fw = 3; |
|
781 r_fw = 4; |
|
782 } |
3268
|
783 } |
1715
|
784 else if (int_or_inf_or_nan) |
1
|
785 { |
|
786 int digits = x_max > x_min ? x_max : x_min; |
5945
|
787 i_fw = digits <= 0 ? 1 : digits; |
|
788 r_fw = i_fw + 1; |
|
789 if (inf_or_nan && i_fw < 3) |
|
790 { |
|
791 i_fw = 3; |
|
792 r_fw = 4; |
|
793 } |
3682
|
794 rd = r_fw; |
1
|
795 } |
|
796 else |
|
797 { |
|
798 int ld_max, rd_max; |
|
799 if (x_max > 0) |
|
800 { |
|
801 ld_max = x_max; |
1658
|
802 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
803 x_max++; |
|
804 } |
|
805 else |
|
806 { |
|
807 ld_max = 1; |
1658
|
808 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
809 x_max = -x_max + 1; |
|
810 } |
|
811 |
|
812 int ld_min, rd_min; |
|
813 if (x_min > 0) |
|
814 { |
|
815 ld_min = x_min; |
1658
|
816 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
817 x_min++; |
|
818 } |
|
819 else |
|
820 { |
|
821 ld_min = 1; |
1658
|
822 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
823 x_min = -x_min + 1; |
|
824 } |
|
825 |
|
826 ld = ld_max > ld_min ? ld_max : ld_min; |
|
827 rd = rd_max > rd_min ? rd_max : rd_min; |
|
828 |
5945
|
829 i_fw = ld + 1 + rd; |
|
830 r_fw = i_fw + 1; |
|
831 if (inf_or_nan && i_fw < 3) |
|
832 { |
|
833 i_fw = 3; |
|
834 r_fw = 4; |
|
835 } |
1
|
836 } |
|
837 |
1309
|
838 if (! (bank_format || hex_format || bit_format) |
3105
|
839 && (print_e |
4509
|
840 || print_g |
3105
|
841 || (! Vfixed_point_format && r_fw > Voutput_max_field_width))) |
1
|
842 { |
4509
|
843 if (print_g) |
|
844 { |
|
845 r_fmt = float_format (); |
|
846 i_fmt = float_format (); |
|
847 } |
|
848 else |
|
849 { |
|
850 int exp_field = 4; |
|
851 if (x_max > 100 || x_min > 100) |
|
852 exp_field++; |
1
|
853 |
5945
|
854 i_fw = prec + exp_field; |
|
855 r_fw = i_fw + 1; |
|
856 if (inf_or_nan && i_fw < 3) |
|
857 { |
|
858 i_fw = 3; |
|
859 r_fw = 4; |
|
860 } |
1
|
861 |
4509
|
862 r_fmt = float_format (r_fw, prec - 1, std::ios::scientific); |
|
863 i_fmt = float_format (i_fw, prec - 1, std::ios::scientific); |
|
864 } |
3608
|
865 |
1
|
866 if (print_big_e) |
|
867 { |
3608
|
868 r_fmt.uppercase (); |
|
869 i_fmt.uppercase (); |
1
|
870 } |
|
871 } |
5086
|
872 else if (! bank_format && int_or_inf_or_nan) |
3611
|
873 { |
|
874 r_fmt = float_format (r_fw, rd); |
|
875 i_fmt = float_format (i_fw, rd); |
|
876 } |
1
|
877 else |
|
878 { |
3608
|
879 r_fmt = float_format (r_fw, rd, std::ios::fixed); |
|
880 i_fmt = float_format (i_fw, rd, std::ios::fixed); |
1
|
881 } |
|
882 |
3608
|
883 curr_real_fmt = &r_fmt; |
|
884 curr_imag_fmt = &i_fmt; |
1
|
885 } |
|
886 |
1658
|
887 static void |
3105
|
888 set_format (const ComplexMatrix& cm, int& r_fw, int& i_fw, double& scale) |
1658
|
889 { |
|
890 curr_real_fmt = 0; |
|
891 curr_imag_fmt = 0; |
|
892 |
|
893 if (free_format) |
|
894 return; |
|
895 |
|
896 Matrix rp = real (cm); |
|
897 Matrix ip = imag (cm); |
|
898 |
4431
|
899 bool sign = rp.any_element_is_negative (true); |
1658
|
900 |
2387
|
901 bool inf_or_nan = cm.any_element_is_inf_or_nan (); |
1658
|
902 |
2387
|
903 bool int_or_inf_or_nan = (rp.all_elements_are_int_or_inf_or_nan () |
|
904 && ip.all_elements_are_int_or_inf_or_nan ()); |
1658
|
905 |
2387
|
906 Matrix r_m_abs = rp.abs (); |
1658
|
907 double r_max_abs = pr_max_internal (r_m_abs); |
|
908 double r_min_abs = pr_min_internal (r_m_abs); |
|
909 |
2387
|
910 Matrix i_m_abs = ip.abs (); |
1658
|
911 double i_max_abs = pr_max_internal (i_m_abs); |
|
912 double i_min_abs = pr_min_internal (i_m_abs); |
|
913 |
2800
|
914 int r_x_max = r_max_abs == 0.0 |
|
915 ? 0 : static_cast<int> (floor (log10 (r_max_abs) + 1.0)); |
|
916 |
|
917 int r_x_min = r_min_abs == 0.0 |
|
918 ? 0 : static_cast<int> (floor (log10 (r_min_abs) + 1.0)); |
1658
|
919 |
2800
|
920 int i_x_max = i_max_abs == 0.0 |
|
921 ? 0 : static_cast<int> (floor (log10 (i_max_abs) + 1.0)); |
|
922 |
|
923 int i_x_min = i_min_abs == 0.0 |
|
924 ? 0 : static_cast<int> (floor (log10 (i_min_abs) + 1.0)); |
1658
|
925 |
|
926 int x_max = r_x_max > i_x_max ? r_x_max : i_x_max; |
|
927 int x_min = r_x_min > i_x_min ? r_x_min : i_x_min; |
|
928 |
4270
|
929 scale = (x_max == 0 || int_or_inf_or_nan) ? 1.0 : std::pow (10.0, x_max - 1); |
3105
|
930 |
1658
|
931 set_complex_matrix_format (sign, x_max, x_min, r_x_max, r_x_min, |
1715
|
932 inf_or_nan, int_or_inf_or_nan, r_fw, i_fw); |
1658
|
933 } |
|
934 |
1
|
935 static inline void |
164
|
936 set_format (const ComplexMatrix& cm) |
1
|
937 { |
|
938 int r_fw, i_fw; |
3105
|
939 double scale; |
|
940 set_format (cm, r_fw, i_fw, scale); |
1
|
941 } |
|
942 |
|
943 static void |
3608
|
944 set_range_format (bool sign, int x_max, int x_min, int all_ints, int& fw) |
1
|
945 { |
3608
|
946 static float_format fmt; |
1
|
947 |
2165
|
948 int prec = Voutput_precision; |
1
|
949 |
|
950 int ld, rd; |
|
951 |
|
952 if (bank_format) |
|
953 { |
|
954 int digits = x_max > x_min ? x_max : x_min; |
|
955 fw = sign + digits < 0 ? 4 : digits + 3; |
|
956 rd = 2; |
|
957 } |
1282
|
958 else if (hex_format) |
|
959 { |
|
960 fw = 2 * sizeof (double); |
|
961 rd = 0; |
|
962 } |
1309
|
963 else if (bit_format) |
|
964 { |
|
965 fw = 8 * sizeof (double); |
|
966 rd = 0; |
|
967 } |
1658
|
968 else if (all_ints) |
1
|
969 { |
|
970 int digits = x_max > x_min ? x_max : x_min; |
|
971 fw = sign + digits; |
3682
|
972 rd = fw; |
1
|
973 } |
4509
|
974 else if (Vfixed_point_format && ! print_g) |
3105
|
975 { |
|
976 rd = prec; |
|
977 fw = rd + 2 + sign; |
|
978 } |
1
|
979 else |
|
980 { |
|
981 int ld_max, rd_max; |
|
982 if (x_max > 0) |
|
983 { |
|
984 ld_max = x_max; |
1658
|
985 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
986 x_max++; |
|
987 } |
|
988 else |
|
989 { |
|
990 ld_max = 1; |
1658
|
991 rd_max = prec > x_max ? prec - x_max : prec; |
1
|
992 x_max = -x_max + 1; |
|
993 } |
|
994 |
|
995 int ld_min, rd_min; |
|
996 if (x_min > 0) |
|
997 { |
|
998 ld_min = x_min; |
1658
|
999 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
1000 x_min++; |
|
1001 } |
|
1002 else |
|
1003 { |
|
1004 ld_min = 1; |
1658
|
1005 rd_min = prec > x_min ? prec - x_min : prec; |
1
|
1006 x_min = -x_min + 1; |
|
1007 } |
|
1008 |
|
1009 ld = ld_max > ld_min ? ld_max : ld_min; |
|
1010 rd = rd_max > rd_min ? rd_max : rd_min; |
|
1011 |
5832
|
1012 fw = sign + 1 + ld + 1 + rd; |
1
|
1013 } |
|
1014 |
1309
|
1015 if (! (bank_format || hex_format || bit_format) |
3105
|
1016 && (print_e |
4509
|
1017 || print_g |
3105
|
1018 || (! Vfixed_point_format && fw > Voutput_max_field_width))) |
1
|
1019 { |
4509
|
1020 if (print_g) |
|
1021 fmt = float_format (); |
|
1022 else |
|
1023 { |
|
1024 int exp_field = 4; |
|
1025 if (x_max > 100 || x_min > 100) |
|
1026 exp_field++; |
1
|
1027 |
4509
|
1028 fw = sign + 2 + prec + exp_field; |
1
|
1029 |
4509
|
1030 fmt = float_format (fw, prec - 1, std::ios::scientific); |
|
1031 } |
3608
|
1032 |
1
|
1033 if (print_big_e) |
3608
|
1034 fmt.uppercase (); |
1
|
1035 } |
5086
|
1036 else if (! bank_format && all_ints) |
3611
|
1037 fmt = float_format (fw, rd); |
1
|
1038 else |
3608
|
1039 fmt = float_format (fw, rd, std::ios::fixed); |
1
|
1040 |
3608
|
1041 curr_real_fmt = &fmt; |
1
|
1042 } |
|
1043 |
1658
|
1044 static void |
3105
|
1045 set_format (const Range& r, int& fw, double& scale) |
1658
|
1046 { |
|
1047 curr_real_fmt = 0; |
|
1048 curr_imag_fmt = 0; |
|
1049 |
|
1050 if (free_format) |
|
1051 return; |
|
1052 |
|
1053 double r_min = r.base (); |
|
1054 double r_max = r.limit (); |
|
1055 |
|
1056 if (r_max < r_min) |
|
1057 { |
|
1058 double tmp = r_max; |
|
1059 r_max = r_min; |
|
1060 r_min = tmp; |
|
1061 } |
|
1062 |
2387
|
1063 bool sign = (r_min < 0.0); |
1658
|
1064 |
2387
|
1065 bool all_ints = r.all_elements_are_ints (); |
1658
|
1066 |
|
1067 double max_abs = r_max < 0.0 ? -r_max : r_max; |
|
1068 double min_abs = r_min < 0.0 ? -r_min : r_min; |
|
1069 |
2800
|
1070 int x_max = max_abs == 0.0 |
|
1071 ? 0 : static_cast<int> (floor (log10 (max_abs) + 1.0)); |
|
1072 |
|
1073 int x_min = min_abs == 0.0 |
|
1074 ? 0 : static_cast<int> (floor (log10 (min_abs) + 1.0)); |
1658
|
1075 |
4270
|
1076 scale = (x_max == 0 || all_ints) ? 1.0 : std::pow (10.0, x_max - 1); |
3105
|
1077 |
1658
|
1078 set_range_format (sign, x_max, x_min, all_ints, fw); |
|
1079 } |
|
1080 |
1
|
1081 static inline void |
164
|
1082 set_format (const Range& r) |
1
|
1083 { |
|
1084 int fw; |
3105
|
1085 double scale; |
|
1086 set_format (r, fw, scale); |
1
|
1087 } |
|
1088 |
1282
|
1089 union equiv |
|
1090 { |
|
1091 double d; |
|
1092 unsigned char i[sizeof (double)]; |
|
1093 }; |
|
1094 |
1309
|
1095 #define PRINT_CHAR_BITS(os, c) \ |
|
1096 do \ |
|
1097 { \ |
|
1098 unsigned char ctmp = c; \ |
|
1099 char stmp[9]; \ |
1488
|
1100 stmp[0] = (ctmp & 0x80) ? '1' : '0'; \ |
|
1101 stmp[1] = (ctmp & 0x40) ? '1' : '0'; \ |
|
1102 stmp[2] = (ctmp & 0x20) ? '1' : '0'; \ |
|
1103 stmp[3] = (ctmp & 0x10) ? '1' : '0'; \ |
|
1104 stmp[4] = (ctmp & 0x08) ? '1' : '0'; \ |
|
1105 stmp[5] = (ctmp & 0x04) ? '1' : '0'; \ |
|
1106 stmp[6] = (ctmp & 0x02) ? '1' : '0'; \ |
|
1107 stmp[7] = (ctmp & 0x01) ? '1' : '0'; \ |
1309
|
1108 stmp[8] = '\0'; \ |
3013
|
1109 os << stmp; \ |
1309
|
1110 } \ |
|
1111 while (0) |
|
1112 |
|
1113 #define PRINT_CHAR_BITS_SWAPPED(os, c) \ |
|
1114 do \ |
|
1115 { \ |
|
1116 unsigned char ctmp = c; \ |
|
1117 char stmp[9]; \ |
1488
|
1118 stmp[0] = (ctmp & 0x01) ? '1' : '0'; \ |
|
1119 stmp[1] = (ctmp & 0x02) ? '1' : '0'; \ |
|
1120 stmp[2] = (ctmp & 0x04) ? '1' : '0'; \ |
|
1121 stmp[3] = (ctmp & 0x08) ? '1' : '0'; \ |
|
1122 stmp[4] = (ctmp & 0x10) ? '1' : '0'; \ |
|
1123 stmp[5] = (ctmp & 0x20) ? '1' : '0'; \ |
|
1124 stmp[6] = (ctmp & 0x40) ? '1' : '0'; \ |
|
1125 stmp[7] = (ctmp & 0x80) ? '1' : '0'; \ |
1309
|
1126 stmp[8] = '\0'; \ |
3013
|
1127 os << stmp; \ |
1309
|
1128 } \ |
|
1129 while (0) |
|
1130 |
2522
|
1131 static void |
3608
|
1132 pr_any_float (const float_format *fmt, std::ostream& os, double d, int fw = 0) |
1
|
1133 { |
529
|
1134 if (fmt) |
1
|
1135 { |
5544
|
1136 // Unless explicitly asked for, always print in big-endian |
|
1137 // format for hex and bit formats. |
|
1138 // |
|
1139 // {bit,hex}_format == 1: print big-endian |
|
1140 // {bit,hex}_format == 2: print native |
|
1141 |
1282
|
1142 if (hex_format) |
|
1143 { |
|
1144 equiv tmp; |
|
1145 tmp.d = d; |
|
1146 |
|
1147 // Unless explicitly asked for, always print in big-endian |
|
1148 // format. |
|
1149 |
5775
|
1150 // FIXME -- is it correct to swap bytes for VAX |
1282
|
1151 // formats and not for Cray? |
|
1152 |
5775
|
1153 // FIXME -- will bad things happen if we are |
3013
|
1154 // interrupted before resetting the format flags and fill |
|
1155 // character? |
|
1156 |
2317
|
1157 oct_mach_info::float_format flt_fmt = |
|
1158 oct_mach_info::native_float_format (); |
|
1159 |
3013
|
1160 char ofill = os.fill ('0'); |
|
1161 |
3608
|
1162 std::ios::fmtflags oflags |
|
1163 = os.flags (std::ios::right | std::ios::hex); |
3013
|
1164 |
1282
|
1165 if (hex_format > 1 |
4574
|
1166 || flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian |
|
1167 || flt_fmt == oct_mach_info::flt_fmt_cray |
|
1168 || flt_fmt == oct_mach_info::flt_fmt_unknown) |
1282
|
1169 { |
1322
|
1170 for (size_t i = 0; i < sizeof (double); i++) |
3548
|
1171 os << std::setw (2) << static_cast<int> (tmp.i[i]); |
1282
|
1172 } |
|
1173 else |
|
1174 { |
1328
|
1175 for (int i = sizeof (double) - 1; i >= 0; i--) |
3548
|
1176 os << std::setw (2) << static_cast<int> (tmp.i[i]); |
1282
|
1177 } |
3013
|
1178 |
|
1179 os.fill (ofill); |
|
1180 os.setf (oflags); |
1282
|
1181 } |
1309
|
1182 else if (bit_format) |
|
1183 { |
|
1184 equiv tmp; |
|
1185 tmp.d = d; |
|
1186 |
5775
|
1187 // FIXME -- is it correct to swap bytes for VAX |
1309
|
1188 // formats and not for Cray? |
|
1189 |
2317
|
1190 oct_mach_info::float_format flt_fmt = |
|
1191 oct_mach_info::native_float_format (); |
|
1192 |
4574
|
1193 if (flt_fmt == oct_mach_info::flt_fmt_ieee_big_endian |
|
1194 || flt_fmt == oct_mach_info::flt_fmt_cray |
|
1195 || flt_fmt == oct_mach_info::flt_fmt_unknown) |
1309
|
1196 { |
1322
|
1197 for (size_t i = 0; i < sizeof (double); i++) |
1309
|
1198 PRINT_CHAR_BITS (os, tmp.i[i]); |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 if (bit_format > 1) |
|
1203 { |
1328
|
1204 for (size_t i = 0; i < sizeof (double); i++) |
1309
|
1205 PRINT_CHAR_BITS_SWAPPED (os, tmp.i[i]); |
|
1206 } |
|
1207 else |
|
1208 { |
|
1209 for (int i = sizeof (double) - 1; i >= 0; i--) |
|
1210 PRINT_CHAR_BITS (os, tmp.i[i]); |
|
1211 } |
|
1212 } |
|
1213 } |
1282
|
1214 else if (xisinf (d)) |
1
|
1215 { |
2804
|
1216 const char *s; |
1
|
1217 if (d < 0.0) |
|
1218 s = "-Inf"; |
|
1219 else |
|
1220 s = "Inf"; |
|
1221 |
|
1222 if (fw > 0) |
3548
|
1223 os << std::setw (fw) << s; |
1
|
1224 else |
|
1225 os << s; |
|
1226 } |
4025
|
1227 else if (octave_is_NA (d)) |
|
1228 { |
|
1229 if (fw > 0) |
|
1230 os << std::setw (fw) << "NA"; |
|
1231 else |
|
1232 os << "NA"; |
|
1233 } |
1
|
1234 else if (xisnan (d)) |
|
1235 { |
|
1236 if (fw > 0) |
3548
|
1237 os << std::setw (fw) << "NaN"; |
1
|
1238 else |
|
1239 os << "NaN"; |
|
1240 } |
|
1241 else |
3608
|
1242 os << pr_formatted_float (*fmt, d); |
1
|
1243 } |
529
|
1244 else |
|
1245 os << d; |
1
|
1246 } |
|
1247 |
|
1248 static inline void |
3608
|
1249 pr_float (std::ostream& os, double d, int fw = 0, double scale = 1.0) |
1
|
1250 { |
4509
|
1251 if (Vfixed_point_format && ! print_g && scale != 1.0) |
3608
|
1252 d /= scale; |
|
1253 |
1
|
1254 pr_any_float (curr_real_fmt, os, d, fw); |
|
1255 } |
|
1256 |
|
1257 static inline void |
3523
|
1258 pr_imag_float (std::ostream& os, double d, int fw = 0) |
1
|
1259 { |
|
1260 pr_any_float (curr_imag_fmt, os, d, fw); |
|
1261 } |
|
1262 |
2522
|
1263 static void |
3608
|
1264 pr_complex (std::ostream& os, const Complex& c, int r_fw = 0, |
|
1265 int i_fw = 0, double scale = 1.0) |
1
|
1266 { |
4509
|
1267 Complex tmp |
|
1268 = (Vfixed_point_format && ! print_g && scale != 1.0) ? c / scale : c; |
3608
|
1269 |
|
1270 double r = tmp.real (); |
|
1271 |
1
|
1272 pr_float (os, r, r_fw); |
3608
|
1273 |
1
|
1274 if (! bank_format) |
|
1275 { |
3608
|
1276 double i = tmp.imag (); |
4349
|
1277 if (! (hex_format || bit_format) && lo_ieee_signbit (i)) |
1
|
1278 { |
|
1279 os << " - "; |
|
1280 i = -i; |
|
1281 pr_imag_float (os, i, i_fw); |
|
1282 } |
|
1283 else |
|
1284 { |
1309
|
1285 if (hex_format || bit_format) |
1282
|
1286 os << " "; |
|
1287 else |
|
1288 os << " + "; |
|
1289 |
1
|
1290 pr_imag_float (os, i, i_fw); |
|
1291 } |
|
1292 os << "i"; |
|
1293 } |
|
1294 } |
|
1295 |
626
|
1296 static void |
5275
|
1297 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc, bool pr_as_read_syntax) |
626
|
1298 { |
|
1299 assert (nr == 0 || nc == 0); |
|
1300 |
|
1301 if (pr_as_read_syntax) |
|
1302 { |
|
1303 if (nr == 0 && nc == 0) |
|
1304 os << "[]"; |
|
1305 else |
|
1306 os << "zeros (" << nr << ", " << nc << ")"; |
|
1307 } |
|
1308 else |
|
1309 { |
|
1310 os << "[]"; |
4559
|
1311 |
2165
|
1312 if (Vprint_empty_dimensions) |
626
|
1313 os << "(" << nr << "x" << nc << ")"; |
|
1314 } |
|
1315 } |
|
1316 |
1186
|
1317 static void |
4559
|
1318 print_empty_nd_array (std::ostream& os, const dim_vector& dims, |
|
1319 bool pr_as_read_syntax) |
|
1320 { |
|
1321 assert (dims.any_zero ()); |
|
1322 |
|
1323 if (pr_as_read_syntax) |
|
1324 os << "zeros (" << dims.str (',') << ")"; |
|
1325 else |
|
1326 { |
|
1327 os << "[]"; |
|
1328 |
|
1329 if (Vprint_empty_dimensions) |
|
1330 os << "(" << dims.str () << ")"; |
|
1331 } |
|
1332 } |
|
1333 |
|
1334 static void |
3523
|
1335 pr_scale_header (std::ostream& os, double scale) |
3105
|
1336 { |
4509
|
1337 if (Vfixed_point_format && ! print_g && scale != 1.0) |
3105
|
1338 { |
3568
|
1339 os << " " |
|
1340 << std::setw (8) << std::setprecision (1) |
|
1341 << std::setiosflags (std::ios::scientific|std::ios::left) |
|
1342 << scale |
|
1343 << std::resetiosflags (std::ios::scientific|std::ios::left) |
|
1344 << " *\n"; |
3105
|
1345 |
|
1346 if (! compact_format) |
|
1347 os << "\n"; |
|
1348 } |
|
1349 } |
|
1350 |
|
1351 static void |
5275
|
1352 pr_col_num_header (std::ostream& os, octave_idx_type total_width, int max_width, |
|
1353 octave_idx_type lim, octave_idx_type col, int extra_indent) |
1186
|
1354 { |
2165
|
1355 if (total_width > max_width && Vsplit_long_rows) |
1186
|
1356 { |
4833
|
1357 if (col != 0) |
|
1358 { |
|
1359 if (compact_format) |
|
1360 os << "\n"; |
|
1361 else |
|
1362 os << "\n\n"; |
|
1363 } |
1186
|
1364 |
5275
|
1365 octave_idx_type num_cols = lim - col; |
1186
|
1366 |
3548
|
1367 os << std::setw (extra_indent) << ""; |
1972
|
1368 |
1186
|
1369 if (num_cols == 1) |
|
1370 os << " Column " << col + 1 << ":\n"; |
|
1371 else if (num_cols == 2) |
|
1372 os << " Columns " << col + 1 << " and " << lim << ":\n"; |
|
1373 else |
|
1374 os << " Columns " << col + 1 << " through " << lim << ":\n"; |
2915
|
1375 |
|
1376 if (! compact_format) |
|
1377 os << "\n"; |
1186
|
1378 } |
|
1379 } |
|
1380 |
5030
|
1381 template <class T> |
6018
|
1382 /* static */ inline void |
5030
|
1383 pr_plus_format (std::ostream& os, const T& val) |
3248
|
1384 { |
5030
|
1385 if (val > T (0)) |
4632
|
1386 os << plus_format_chars[0]; |
5030
|
1387 else if (val < T (0)) |
4632
|
1388 os << plus_format_chars[1]; |
3248
|
1389 else |
4632
|
1390 os << plus_format_chars[2]; |
3248
|
1391 } |
|
1392 |
1
|
1393 void |
4661
|
1394 octave_print_internal (std::ostream& os, double d, |
|
1395 bool /* pr_as_read_syntax */) |
1
|
1396 { |
|
1397 if (plus_format) |
|
1398 { |
3608
|
1399 pr_plus_format (os, d); |
1
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 set_format (d); |
|
1404 if (free_format) |
|
1405 os << d; |
|
1406 else |
|
1407 pr_float (os, d); |
|
1408 } |
|
1409 } |
|
1410 |
|
1411 void |
3608
|
1412 octave_print_internal (std::ostream& os, const Matrix& m, |
|
1413 bool pr_as_read_syntax, int extra_indent) |
1
|
1414 { |
5275
|
1415 octave_idx_type nr = m.rows (); |
|
1416 octave_idx_type nc = m.columns (); |
1
|
1417 |
2408
|
1418 if (nr == 0 || nc == 0) |
626
|
1419 print_empty_matrix (os, nr, nc, pr_as_read_syntax); |
|
1420 else if (plus_format && ! pr_as_read_syntax) |
1
|
1421 { |
5275
|
1422 for (octave_idx_type i = 0; i < nr; i++) |
1
|
1423 { |
5275
|
1424 for (octave_idx_type j = 0; j < nc; j++) |
1
|
1425 { |
4153
|
1426 OCTAVE_QUIT; |
|
1427 |
3608
|
1428 pr_plus_format (os, m(i,j)); |
1
|
1429 } |
2907
|
1430 |
|
1431 if (i < nr - 1) |
|
1432 os << "\n"; |
1
|
1433 } |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 int fw; |
3105
|
1438 double scale = 1.0; |
|
1439 set_format (m, fw, scale); |
1
|
1440 int column_width = fw + 2; |
5275
|
1441 octave_idx_type total_width = nc * column_width; |
|
1442 octave_idx_type max_width = command_editor::terminal_cols (); |
1
|
1443 |
626
|
1444 if (pr_as_read_syntax) |
|
1445 max_width -= 4; |
1972
|
1446 else |
|
1447 max_width -= extra_indent; |
|
1448 |
|
1449 if (max_width < 0) |
|
1450 max_width = 0; |
626
|
1451 |
1
|
1452 if (free_format) |
|
1453 { |
626
|
1454 if (pr_as_read_syntax) |
|
1455 os << "[\n"; |
|
1456 |
1
|
1457 os << m; |
626
|
1458 |
|
1459 if (pr_as_read_syntax) |
|
1460 os << "]"; |
|
1461 |
1
|
1462 return; |
|
1463 } |
|
1464 |
5275
|
1465 octave_idx_type inc = nc; |
2165
|
1466 if (total_width > max_width && Vsplit_long_rows) |
1
|
1467 { |
|
1468 inc = max_width / column_width; |
|
1469 if (inc == 0) |
|
1470 inc++; |
|
1471 } |
|
1472 |
626
|
1473 if (pr_as_read_syntax) |
1
|
1474 { |
5275
|
1475 for (octave_idx_type i = 0; i < nr; i++) |
1
|
1476 { |
5275
|
1477 octave_idx_type col = 0; |
626
|
1478 while (col < nc) |
1
|
1479 { |
5275
|
1480 octave_idx_type lim = col + inc < nc ? col + inc : nc; |
|
1481 |
|
1482 for (octave_idx_type j = col; j < lim; j++) |
626
|
1483 { |
4153
|
1484 OCTAVE_QUIT; |
|
1485 |
626
|
1486 if (i == 0 && j == 0) |
|
1487 os << "[ "; |
|
1488 else |
|
1489 { |
|
1490 if (j > col && j < lim) |
|
1491 os << ", "; |
|
1492 else |
|
1493 os << " "; |
|
1494 } |
|
1495 |
3608
|
1496 pr_float (os, m(i,j)); |
626
|
1497 } |
|
1498 |
|
1499 col += inc; |
|
1500 |
|
1501 if (col >= nc) |
|
1502 { |
|
1503 if (i == nr - 1) |
|
1504 os << " ]"; |
|
1505 else |
|
1506 os << ";\n"; |
|
1507 } |
|
1508 else |
|
1509 os << " ...\n"; |
1
|
1510 } |
|
1511 } |
626
|
1512 } |
|
1513 else |
|
1514 { |
3105
|
1515 pr_scale_header (os, scale); |
|
1516 |
5275
|
1517 for (octave_idx_type col = 0; col < nc; col += inc) |
626
|
1518 { |
5275
|
1519 octave_idx_type lim = col + inc < nc ? col + inc : nc; |
626
|
1520 |
1972
|
1521 pr_col_num_header (os, total_width, max_width, lim, col, |
|
1522 extra_indent); |
626
|
1523 |
5275
|
1524 for (octave_idx_type i = 0; i < nr; i++) |
626
|
1525 { |
3548
|
1526 os << std::setw (extra_indent) << ""; |
1972
|
1527 |
5275
|
1528 for (octave_idx_type j = col; j < lim; j++) |
626
|
1529 { |
4153
|
1530 OCTAVE_QUIT; |
|
1531 |
626
|
1532 os << " "; |
|
1533 |
3608
|
1534 pr_float (os, m(i,j), fw, scale); |
626
|
1535 } |
|
1536 |
2907
|
1537 if (i < nr - 1) |
|
1538 os << "\n"; |
626
|
1539 } |
|
1540 } |
1
|
1541 } |
|
1542 } |
|
1543 } |
|
1544 |
4532
|
1545 #define PRINT_ND_ARRAY(os, nda, NDA_T, ELT_T, MAT_T) \ |
|
1546 do \ |
|
1547 { \ |
4559
|
1548 if (nda.is_empty ()) \ |
|
1549 print_empty_nd_array (os, nda.dims (), pr_as_read_syntax); \ |
|
1550 else \ |
|
1551 { \ |
4532
|
1552 \ |
4559
|
1553 int ndims = nda.ndims (); \ |
|
1554 \ |
|
1555 dim_vector dims = nda.dims (); \ |
4532
|
1556 \ |
5275
|
1557 Array<octave_idx_type> ra_idx (ndims, 0); \ |
4532
|
1558 \ |
5275
|
1559 octave_idx_type m = 1; \ |
4532
|
1560 \ |
4559
|
1561 for (int i = 2; i < ndims; i++) \ |
|
1562 m *= dims(i); \ |
|
1563 \ |
5275
|
1564 octave_idx_type nr = dims(0); \ |
|
1565 octave_idx_type nc = dims(1); \ |
4532
|
1566 \ |
5275
|
1567 for (octave_idx_type i = 0; i < m; i++) \ |
4559
|
1568 { \ |
4655
|
1569 OCTAVE_QUIT; \ |
|
1570 \ |
4559
|
1571 std::string nm = "ans"; \ |
4532
|
1572 \ |
4559
|
1573 if (m > 1) \ |
|
1574 { \ |
|
1575 nm += "(:,:,"; \ |
4532
|
1576 \ |
5765
|
1577 std::ostringstream buf; \ |
4532
|
1578 \ |
4559
|
1579 for (int k = 2; k < ndims; k++) \ |
|
1580 { \ |
|
1581 buf << ra_idx(k) + 1; \ |
4532
|
1582 \ |
4559
|
1583 if (k < ndims - 1) \ |
|
1584 buf << ","; \ |
|
1585 else \ |
|
1586 buf << ")"; \ |
|
1587 } \ |
4532
|
1588 \ |
5765
|
1589 nm += buf.str (); \ |
4559
|
1590 } \ |
4532
|
1591 \ |
4559
|
1592 Array<idx_vector> idx (ndims); \ |
4532
|
1593 \ |
4559
|
1594 idx(0) = idx_vector (':'); \ |
|
1595 idx(1) = idx_vector (':'); \ |
|
1596 \ |
|
1597 for (int k = 2; k < ndims; k++) \ |
|
1598 idx(k) = idx_vector (ra_idx(k) + 1); \ |
4532
|
1599 \ |
4559
|
1600 octave_value page \ |
|
1601 = MAT_T (Array2<ELT_T> (nda.index (idx), nr, nc)); \ |
|
1602 \ |
|
1603 page.print_with_name (os, nm); \ |
4532
|
1604 \ |
4559
|
1605 if (i < m) \ |
|
1606 NDA_T::increment_index (ra_idx, dims, 2); \ |
|
1607 } \ |
|
1608 } \ |
4532
|
1609 } \ |
|
1610 while (0) |
|
1611 |
4513
|
1612 void |
|
1613 octave_print_internal (std::ostream& os, const NDArray& nda, |
|
1614 bool pr_as_read_syntax, int extra_indent) |
|
1615 { |
|
1616 switch (nda.ndims ()) |
|
1617 { |
|
1618 case 1: |
|
1619 case 2: |
|
1620 octave_print_internal (os, nda.matrix_value (), |
|
1621 pr_as_read_syntax, extra_indent); |
|
1622 break; |
|
1623 |
|
1624 default: |
4532
|
1625 PRINT_ND_ARRAY (os, nda, NDArray, double, Matrix); |
4513
|
1626 break; |
|
1627 } |
|
1628 } |
|
1629 |
5030
|
1630 template <> |
6018
|
1631 /* static */ inline void |
6015
|
1632 pr_plus_format<> (std::ostream& os, const Complex& c) |
3248
|
1633 { |
|
1634 double rp = c.real (); |
|
1635 double ip = c.imag (); |
|
1636 |
|
1637 if (rp == 0.0) |
|
1638 { |
|
1639 if (ip == 0.0) |
|
1640 os << " "; |
|
1641 else |
|
1642 os << "i"; |
|
1643 } |
|
1644 else if (ip == 0.0) |
3608
|
1645 pr_plus_format (os, rp); |
3248
|
1646 else |
|
1647 os << "c"; |
|
1648 } |
|
1649 |
1
|
1650 void |
3523
|
1651 octave_print_internal (std::ostream& os, const Complex& c, |
4661
|
1652 bool /* pr_as_read_syntax */) |
1
|
1653 { |
|
1654 if (plus_format) |
|
1655 { |
3608
|
1656 pr_plus_format (os, c); |
1
|
1657 } |
|
1658 else |
|
1659 { |
|
1660 set_format (c); |
|
1661 if (free_format) |
|
1662 os << c; |
|
1663 else |
|
1664 pr_complex (os, c); |
|
1665 } |
|
1666 } |
|
1667 |
|
1668 void |
3523
|
1669 octave_print_internal (std::ostream& os, const ComplexMatrix& cm, |
1972
|
1670 bool pr_as_read_syntax, int extra_indent) |
1
|
1671 { |
5275
|
1672 octave_idx_type nr = cm.rows (); |
|
1673 octave_idx_type nc = cm.columns (); |
1
|
1674 |
2408
|
1675 if (nr == 0 || nc == 0) |
626
|
1676 print_empty_matrix (os, nr, nc, pr_as_read_syntax); |
|
1677 else if (plus_format && ! pr_as_read_syntax) |
1
|
1678 { |
5275
|
1679 for (octave_idx_type i = 0; i < nr; i++) |
1
|
1680 { |
5275
|
1681 for (octave_idx_type j = 0; j < nc; j++) |
1
|
1682 { |
4153
|
1683 OCTAVE_QUIT; |
|
1684 |
3608
|
1685 pr_plus_format (os, cm(i,j)); |
1
|
1686 } |
2907
|
1687 |
|
1688 if (i < nr - 1) |
|
1689 os << "\n"; |
1
|
1690 } |
|
1691 } |
|
1692 else |
|
1693 { |
|
1694 int r_fw, i_fw; |
3105
|
1695 double scale = 1.0; |
|
1696 set_format (cm, r_fw, i_fw, scale); |
1
|
1697 int column_width = i_fw + r_fw; |
1309
|
1698 column_width += (bank_format || hex_format|| bit_format) ? 2 : 7; |
5275
|
1699 octave_idx_type total_width = nc * column_width; |
|
1700 octave_idx_type max_width = command_editor::terminal_cols (); |
1
|
1701 |
626
|
1702 if (pr_as_read_syntax) |
|
1703 max_width -= 4; |
1972
|
1704 else |
|
1705 max_width -= extra_indent; |
|
1706 |
|
1707 if (max_width < 0) |
|
1708 max_width = 0; |
626
|
1709 |
1
|
1710 if (free_format) |
|
1711 { |
626
|
1712 if (pr_as_read_syntax) |
|
1713 os << "[\n"; |
|
1714 |
1
|
1715 os << cm; |
626
|
1716 |
|
1717 if (pr_as_read_syntax) |
|
1718 os << "]"; |
|
1719 |
1
|
1720 return; |
|
1721 } |
|
1722 |
5275
|
1723 octave_idx_type inc = nc; |
2165
|
1724 if (total_width > max_width && Vsplit_long_rows) |
1
|
1725 { |
|
1726 inc = max_width / column_width; |
|
1727 if (inc == 0) |
|
1728 inc++; |
|
1729 } |
|
1730 |
626
|
1731 if (pr_as_read_syntax) |
1
|
1732 { |
5275
|
1733 for (octave_idx_type i = 0; i < nr; i++) |
1
|
1734 { |
5275
|
1735 octave_idx_type col = 0; |
626
|
1736 while (col < nc) |
1
|
1737 { |
5275
|
1738 octave_idx_type lim = col + inc < nc ? col + inc : nc; |
|
1739 |
|
1740 for (octave_idx_type j = col; j < lim; j++) |
626
|
1741 { |
4153
|
1742 OCTAVE_QUIT; |
|
1743 |
626
|
1744 if (i == 0 && j == 0) |
|
1745 os << "[ "; |
|
1746 else |
|
1747 { |
|
1748 if (j > col && j < lim) |
|
1749 os << ", "; |
|
1750 else |
|
1751 os << " "; |
|
1752 } |
|
1753 |
3608
|
1754 pr_complex (os, cm(i,j)); |
626
|
1755 } |
|
1756 |
|
1757 col += inc; |
|
1758 |
|
1759 if (col >= nc) |
|
1760 { |
|
1761 if (i == nr - 1) |
|
1762 os << " ]"; |
|
1763 else |
|
1764 os << ";\n"; |
|
1765 } |
1
|
1766 else |
626
|
1767 os << " ...\n"; |
1
|
1768 } |
|
1769 } |
626
|
1770 } |
|
1771 else |
|
1772 { |
3105
|
1773 pr_scale_header (os, scale); |
|
1774 |
5275
|
1775 for (octave_idx_type col = 0; col < nc; col += inc) |
626
|
1776 { |
5275
|
1777 octave_idx_type lim = col + inc < nc ? col + inc : nc; |
626
|
1778 |
1972
|
1779 pr_col_num_header (os, total_width, max_width, lim, col, |
|
1780 extra_indent); |
626
|
1781 |
5275
|
1782 for (octave_idx_type i = 0; i < nr; i++) |
626
|
1783 { |
3548
|
1784 os << std::setw (extra_indent) << ""; |
1972
|
1785 |
5275
|
1786 for (octave_idx_type j = col; j < lim; j++) |
626
|
1787 { |
4153
|
1788 OCTAVE_QUIT; |
|
1789 |
626
|
1790 os << " "; |
|
1791 |
3608
|
1792 pr_complex (os, cm(i,j), r_fw, i_fw, scale); |
626
|
1793 } |
2907
|
1794 |
|
1795 if (i < nr - 1) |
|
1796 os << "\n"; |
626
|
1797 } |
|
1798 } |
1
|
1799 } |
|
1800 } |
|
1801 } |
|
1802 |
|
1803 void |
4513
|
1804 octave_print_internal (std::ostream& os, const ComplexNDArray& nda, |
|
1805 bool pr_as_read_syntax, int extra_indent) |
|
1806 { |
|
1807 switch (nda.ndims ()) |
|
1808 { |
|
1809 case 1: |
|
1810 case 2: |
|
1811 octave_print_internal (os, nda.matrix_value (), |
|
1812 pr_as_read_syntax, extra_indent); |
|
1813 break; |
|
1814 |
|
1815 default: |
4532
|
1816 PRINT_ND_ARRAY (os, nda, ComplexNDArray, Complex, ComplexMatrix); |
4513
|
1817 break; |
|
1818 } |
|
1819 } |
|
1820 |
|
1821 void |
3523
|
1822 octave_print_internal (std::ostream& os, const Range& r, |
1972
|
1823 bool pr_as_read_syntax, int extra_indent) |
1
|
1824 { |
626
|
1825 double base = r.base (); |
1
|
1826 double increment = r.inc (); |
626
|
1827 double limit = r.limit (); |
5275
|
1828 octave_idx_type num_elem = r.nelem (); |
1
|
1829 |
626
|
1830 if (plus_format && ! pr_as_read_syntax) |
1
|
1831 { |
5275
|
1832 for (octave_idx_type i = 0; i < num_elem; i++) |
1
|
1833 { |
4153
|
1834 OCTAVE_QUIT; |
|
1835 |
626
|
1836 double val = base + i * increment; |
4632
|
1837 |
|
1838 pr_plus_format (os, val); |
1
|
1839 } |
|
1840 } |
|
1841 else |
|
1842 { |
|
1843 int fw; |
3105
|
1844 double scale = 1.0; |
|
1845 set_format (r, fw, scale); |
1
|
1846 |
626
|
1847 if (pr_as_read_syntax) |
1
|
1848 { |
626
|
1849 if (free_format) |
|
1850 { |
|
1851 os << base << " : "; |
|
1852 if (increment != 1.0) |
|
1853 os << increment << " : "; |
|
1854 os << limit; |
|
1855 } |
|
1856 else |
|
1857 { |
|
1858 pr_float (os, base, fw); |
|
1859 os << " : "; |
|
1860 if (increment != 1.0) |
|
1861 { |
|
1862 pr_float (os, increment, fw); |
|
1863 os << " : "; |
|
1864 } |
|
1865 pr_float (os, limit, fw); |
|
1866 } |
1
|
1867 } |
626
|
1868 else |
|
1869 { |
|
1870 int column_width = fw + 2; |
5275
|
1871 octave_idx_type total_width = num_elem * column_width; |
|
1872 octave_idx_type max_width = command_editor::terminal_cols (); |
1
|
1873 |
626
|
1874 if (free_format) |
|
1875 { |
|
1876 os << r; |
|
1877 return; |
|
1878 } |
1
|
1879 |
5275
|
1880 octave_idx_type inc = num_elem; |
2165
|
1881 if (total_width > max_width && Vsplit_long_rows) |
1
|
1882 { |
626
|
1883 inc = max_width / column_width; |
|
1884 if (inc == 0) |
|
1885 inc++; |
1
|
1886 } |
|
1887 |
1972
|
1888 max_width -= extra_indent; |
|
1889 |
|
1890 if (max_width < 0) |
|
1891 max_width = 0; |
|
1892 |
3105
|
1893 pr_scale_header (os, scale); |
|
1894 |
5275
|
1895 octave_idx_type col = 0; |
626
|
1896 while (col < num_elem) |
1
|
1897 { |
5275
|
1898 octave_idx_type lim = col + inc < num_elem ? col + inc : num_elem; |
626
|
1899 |
1972
|
1900 pr_col_num_header (os, total_width, max_width, lim, col, |
|
1901 extra_indent); |
|
1902 |
3548
|
1903 os << std::setw (extra_indent) << ""; |
626
|
1904 |
5275
|
1905 for (octave_idx_type i = col; i < lim; i++) |
626
|
1906 { |
4153
|
1907 OCTAVE_QUIT; |
|
1908 |
626
|
1909 double val = base + i * increment; |
3105
|
1910 |
4791
|
1911 if (i == num_elem - 1) |
|
1912 { |
|
1913 // See the comments in Range::matrix_value. |
|
1914 |
|
1915 if ((increment > 0 && val > limit) |
|
1916 || (increment < 0 && val < limit)) |
|
1917 val = limit; |
|
1918 } |
|
1919 |
626
|
1920 os << " "; |
3105
|
1921 |
3608
|
1922 pr_float (os, val, fw, scale); |
626
|
1923 } |
|
1924 |
2907
|
1925 col += inc; |
1
|
1926 } |
|
1927 } |
|
1928 } |
|
1929 } |
|
1930 |
1343
|
1931 void |
3523
|
1932 octave_print_internal (std::ostream& os, const boolMatrix& bm, |
3215
|
1933 bool pr_as_read_syntax, |
|
1934 int extra_indent) |
|
1935 { |
|
1936 Matrix tmp (bm); |
|
1937 octave_print_internal (os, tmp, pr_as_read_syntax, extra_indent); |
|
1938 } |
|
1939 |
|
1940 void |
4513
|
1941 octave_print_internal (std::ostream& os, const boolNDArray& nda, |
|
1942 bool pr_as_read_syntax, |
|
1943 int extra_indent) |
|
1944 { |
|
1945 switch (nda.ndims ()) |
|
1946 { |
|
1947 case 1: |
|
1948 case 2: |
|
1949 octave_print_internal (os, nda.matrix_value (), |
|
1950 pr_as_read_syntax, extra_indent); |
|
1951 break; |
|
1952 |
|
1953 default: |
4532
|
1954 PRINT_ND_ARRAY (os, nda, boolNDArray, bool, boolMatrix); |
4513
|
1955 break; |
|
1956 } |
|
1957 } |
|
1958 |
|
1959 void |
3523
|
1960 octave_print_internal (std::ostream& os, const charMatrix& chm, |
3215
|
1961 bool pr_as_read_syntax, |
5775
|
1962 int /* extra_indent FIXME */, |
3215
|
1963 bool pr_as_string) |
1343
|
1964 { |
1572
|
1965 if (pr_as_string) |
|
1966 { |
5275
|
1967 octave_idx_type nstr = chm.rows (); |
1343
|
1968 |
1572
|
1969 if (pr_as_read_syntax && nstr > 1) |
|
1970 os << "[ "; |
1343
|
1971 |
2907
|
1972 if (nstr != 0) |
1343
|
1973 { |
5275
|
1974 for (octave_idx_type i = 0; i < nstr; i++) |
1572
|
1975 { |
4153
|
1976 OCTAVE_QUIT; |
|
1977 |
3523
|
1978 std::string row = chm.row_as_string (i); |
2664
|
1979 |
|
1980 if (pr_as_read_syntax) |
|
1981 { |
|
1982 os << "\"" << undo_string_escapes (row) << "\""; |
1343
|
1983 |
2664
|
1984 if (i < nstr - 1) |
|
1985 os << "; "; |
|
1986 } |
|
1987 else |
2907
|
1988 { |
|
1989 os << row; |
|
1990 |
|
1991 if (i < nstr - 1) |
|
1992 os << "\n"; |
|
1993 } |
1572
|
1994 } |
1343
|
1995 } |
1572
|
1996 |
|
1997 if (pr_as_read_syntax && nstr > 1) |
|
1998 os << " ]"; |
1343
|
1999 } |
1572
|
2000 else |
|
2001 { |
|
2002 os << "sorry, printing char matrices not implemented yet\n"; |
|
2003 } |
1343
|
2004 } |
|
2005 |
4513
|
2006 void |
|
2007 octave_print_internal (std::ostream& os, const charNDArray& nda, |
4663
|
2008 bool pr_as_read_syntax, int extra_indent, |
4513
|
2009 bool pr_as_string) |
|
2010 { |
|
2011 switch (nda.ndims ()) |
|
2012 { |
|
2013 case 1: |
|
2014 case 2: |
|
2015 octave_print_internal (os, nda.matrix_value (), |
|
2016 pr_as_read_syntax, extra_indent, pr_as_string); |
|
2017 break; |
|
2018 |
|
2019 default: |
4532
|
2020 PRINT_ND_ARRAY (os, nda, charNDArray, char, charMatrix); |
4513
|
2021 break; |
|
2022 } |
|
2023 } |
|
2024 |
4655
|
2025 void |
4925
|
2026 octave_print_internal (std::ostream& os, const std::string& s, |
|
2027 bool pr_as_read_syntax, int extra_indent) |
|
2028 { |
|
2029 ArrayN<std::string> nda (dim_vector (1, 1), s); |
|
2030 |
|
2031 octave_print_internal (os, nda, pr_as_read_syntax, extra_indent); |
|
2032 } |
|
2033 |
|
2034 void |
4655
|
2035 octave_print_internal (std::ostream& os, const ArrayN<std::string>& nda, |
4663
|
2036 bool pr_as_read_syntax, int /* extra_indent */) |
4655
|
2037 { |
5775
|
2038 // FIXME -- this mostly duplicates the code in the |
4655
|
2039 // PRINT_ND_ARRAY macro. |
|
2040 |
|
2041 if (nda.is_empty ()) |
|
2042 print_empty_nd_array (os, nda.dims (), pr_as_read_syntax); |
|
2043 else if (nda.length () == 1) |
|
2044 { |
|
2045 os << nda(0); |
|
2046 } |
|
2047 else |
|
2048 { |
|
2049 int ndims = nda.ndims (); |
|
2050 |
|
2051 dim_vector dims = nda.dims (); |
|
2052 |
5275
|
2053 Array<octave_idx_type> ra_idx (ndims, 0); |
|
2054 |
|
2055 octave_idx_type m = 1; |
4655
|
2056 |
|
2057 for (int i = 2; i < ndims; i++) |
|
2058 m *= dims(i); |
|
2059 |
5275
|
2060 octave_idx_type nr = dims(0); |
|
2061 octave_idx_type nc = dims(1); |
|
2062 |
|
2063 for (octave_idx_type i = 0; i < m; i++) |
4655
|
2064 { |
|
2065 std::string nm = "ans"; |
|
2066 |
|
2067 if (m > 1) |
|
2068 { |
|
2069 nm += "(:,:,"; |
|
2070 |
5765
|
2071 std::ostringstream buf; |
4655
|
2072 |
|
2073 for (int k = 2; k < ndims; k++) |
|
2074 { |
|
2075 buf << ra_idx(k) + 1; |
|
2076 |
|
2077 if (k < ndims - 1) |
|
2078 buf << ","; |
|
2079 else |
|
2080 buf << ")"; |
|
2081 } |
|
2082 |
5765
|
2083 nm += buf.str (); |
4655
|
2084 } |
|
2085 |
|
2086 Array<idx_vector> idx (ndims); |
|
2087 |
|
2088 idx(0) = idx_vector (':'); |
|
2089 idx(1) = idx_vector (':'); |
|
2090 |
|
2091 for (int k = 2; k < ndims; k++) |
|
2092 idx(k) = idx_vector (ra_idx(k) + 1); |
|
2093 |
|
2094 Array2<std::string> page (nda.index (idx), nr, nc); |
|
2095 |
5775
|
2096 // FIXME -- need to do some more work to put these |
4655
|
2097 // in neatly aligned columns... |
|
2098 |
5275
|
2099 octave_idx_type n_rows = page.rows (); |
|
2100 octave_idx_type n_cols = page.cols (); |
4655
|
2101 |
|
2102 os << nm << " =\n\n"; |
|
2103 |
5275
|
2104 for (octave_idx_type ii = 0; ii < n_rows; ii++) |
4655
|
2105 { |
5275
|
2106 for (octave_idx_type jj = 0; jj < n_cols; jj++) |
4655
|
2107 os << " " << page(ii,jj); |
|
2108 |
|
2109 os << "\n"; |
|
2110 } |
|
2111 |
|
2112 if (i < m - 1) |
|
2113 os << "\n"; |
|
2114 |
|
2115 if (i < m) |
|
2116 increment_index (ra_idx, dims, 2); |
|
2117 } |
|
2118 } |
|
2119 } |
|
2120 |
4901
|
2121 template <class T> |
|
2122 class |
|
2123 octave_print_conv |
|
2124 { |
|
2125 public: |
|
2126 typedef T print_conv_type; |
|
2127 }; |
|
2128 |
|
2129 #define PRINT_CONV(T1, T2) \ |
|
2130 template <> \ |
|
2131 class \ |
|
2132 octave_print_conv<T1> \ |
|
2133 { \ |
|
2134 public: \ |
|
2135 typedef T2 print_conv_type; \ |
|
2136 } |
|
2137 |
|
2138 PRINT_CONV (octave_int8, octave_int16); |
|
2139 PRINT_CONV (octave_uint8, octave_uint16); |
|
2140 |
|
2141 #undef PRINT_CONV |
|
2142 |
|
2143 template <class T> |
6018
|
2144 /* static */ inline void |
4949
|
2145 pr_int (std::ostream& os, const T& d, int fw = 0) |
|
2146 { |
|
2147 size_t sz = d.byte_size(); |
|
2148 const unsigned char * tmpi = d.iptr(); |
|
2149 |
5544
|
2150 // Unless explicitly asked for, always print in big-endian |
|
2151 // format for hex and bit formats. |
|
2152 // |
|
2153 // {bit,hex}_format == 1: print big-endian |
|
2154 // {bit,hex}_format == 2: print native |
|
2155 |
4949
|
2156 if (hex_format) |
|
2157 { |
|
2158 char ofill = os.fill ('0'); |
|
2159 |
|
2160 std::ios::fmtflags oflags |
|
2161 = os.flags (std::ios::right | std::ios::hex); |
|
2162 |
|
2163 if (hex_format > 1 || oct_mach_info::words_big_endian ()) |
|
2164 { |
|
2165 for (size_t i = 0; i < sz; i++) |
|
2166 os << std::setw (2) << static_cast<int> (tmpi[i]); |
|
2167 } |
|
2168 else |
|
2169 { |
|
2170 for (int i = sz - 1; i >= 0; i--) |
|
2171 os << std::setw (2) << static_cast<int> (tmpi[i]); |
|
2172 } |
|
2173 |
|
2174 os.fill (ofill); |
|
2175 os.setf (oflags); |
|
2176 } |
|
2177 else if (bit_format) |
|
2178 { |
5544
|
2179 if (oct_mach_info::words_big_endian ()) |
4949
|
2180 { |
|
2181 for (size_t i = 0; i < sz; i++) |
5544
|
2182 PRINT_CHAR_BITS (os, tmpi[i]); |
4949
|
2183 } |
|
2184 else |
|
2185 { |
5544
|
2186 if (bit_format > 1) |
|
2187 { |
|
2188 for (size_t i = 0; i < sz; i++) |
|
2189 PRINT_CHAR_BITS_SWAPPED (os, tmpi[i]); |
|
2190 } |
|
2191 else |
|
2192 { |
|
2193 for (int i = sz - 1; i >= 0; i--) |
|
2194 PRINT_CHAR_BITS (os, tmpi[i]); |
|
2195 } |
4949
|
2196 } |
|
2197 } |
|
2198 else |
|
2199 { |
|
2200 os << std::setw (fw) |
|
2201 << typename octave_print_conv<T>::print_conv_type (d); |
|
2202 |
|
2203 if (bank_format) |
|
2204 os << ".00"; |
|
2205 } |
|
2206 } |
|
2207 |
|
2208 template <class T> |
6018
|
2209 /* static */ inline T |
6008
|
2210 abs (T x) |
|
2211 { |
|
2212 return x; |
|
2213 } |
|
2214 |
6018
|
2215 #define INSTANTIATE_ABS(T) template /* static */ inline T abs (T x) |
6008
|
2216 |
|
2217 INSTANTIATE_ABS (unsigned int); |
|
2218 INSTANTIATE_ABS (unsigned short); |
|
2219 INSTANTIATE_ABS (unsigned long); |
|
2220 INSTANTIATE_ABS (unsigned long long); |
|
2221 |
|
2222 template <class T> |
4901
|
2223 void |
|
2224 octave_print_internal (std::ostream& os, const intNDArray<T>& nda, |
4949
|
2225 bool pr_as_read_syntax, int extra_indent) |
4901
|
2226 { |
5775
|
2227 // FIXME -- this mostly duplicates the code in the |
4901
|
2228 // PRINT_ND_ARRAY macro. |
|
2229 |
|
2230 if (nda.is_empty ()) |
|
2231 print_empty_nd_array (os, nda.dims (), pr_as_read_syntax); |
|
2232 else if (nda.length () == 1) |
4949
|
2233 octave_print_internal (os, nda (0), pr_as_read_syntax); |
|
2234 else if (plus_format && ! pr_as_read_syntax) |
4901
|
2235 { |
|
2236 int ndims = nda.ndims (); |
|
2237 |
5275
|
2238 Array<octave_idx_type> ra_idx (ndims, 0); |
4949
|
2239 |
4901
|
2240 dim_vector dims = nda.dims (); |
|
2241 |
5275
|
2242 octave_idx_type m = 1; |
4901
|
2243 |
|
2244 for (int i = 2; i < ndims; i++) |
|
2245 m *= dims(i); |
|
2246 |
5275
|
2247 octave_idx_type nr = dims(0); |
|
2248 octave_idx_type nc = dims(1); |
|
2249 |
|
2250 for (octave_idx_type i = 0; i < m; i++) |
4901
|
2251 { |
|
2252 if (m > 1) |
|
2253 { |
4949
|
2254 std::string nm = "ans(:,:,"; |
4901
|
2255 |
5765
|
2256 std::ostringstream buf; |
4901
|
2257 |
|
2258 for (int k = 2; k < ndims; k++) |
|
2259 { |
|
2260 buf << ra_idx(k) + 1; |
|
2261 |
|
2262 if (k < ndims - 1) |
|
2263 buf << ","; |
|
2264 else |
|
2265 buf << ")"; |
|
2266 } |
|
2267 |
5765
|
2268 nm += buf.str (); |
4949
|
2269 |
|
2270 os << nm << " =\n\n"; |
4901
|
2271 } |
|
2272 |
|
2273 Array<idx_vector> idx (ndims); |
|
2274 |
|
2275 idx(0) = idx_vector (':'); |
|
2276 idx(1) = idx_vector (':'); |
|
2277 |
|
2278 for (int k = 2; k < ndims; k++) |
|
2279 idx(k) = idx_vector (ra_idx(k) + 1); |
|
2280 |
|
2281 Array2<T> page (nda.index (idx), nr, nc); |
|
2282 |
5275
|
2283 for (octave_idx_type ii = 0; ii < nr; ii++) |
4901
|
2284 { |
5275
|
2285 for (octave_idx_type jj = 0; jj < nc; jj++) |
4949
|
2286 { |
|
2287 OCTAVE_QUIT; |
|
2288 |
|
2289 pr_plus_format (os, page(ii,jj)); |
|
2290 } |
|
2291 |
|
2292 if ((ii < nr - 1) || (i < m -1)) |
|
2293 os << "\n"; |
4901
|
2294 } |
|
2295 |
|
2296 if (i < m - 1) |
4949
|
2297 { |
|
2298 os << "\n"; |
|
2299 increment_index (ra_idx, dims, 2); |
|
2300 } |
|
2301 } |
|
2302 } |
|
2303 else |
|
2304 { |
|
2305 int ndims = nda.ndims (); |
|
2306 |
|
2307 dim_vector dims = nda.dims (); |
|
2308 |
5275
|
2309 Array<octave_idx_type> ra_idx (ndims, 0); |
|
2310 |
|
2311 octave_idx_type m = 1; |
4949
|
2312 |
|
2313 for (int i = 2; i < ndims; i++) |
|
2314 m *= dims(i); |
|
2315 |
5275
|
2316 octave_idx_type nr = dims(0); |
|
2317 octave_idx_type nc = dims(1); |
4949
|
2318 |
|
2319 int fw = 0; |
|
2320 if (hex_format) |
|
2321 fw = 2 * nda(0).byte_size (); |
|
2322 else if (bit_format) |
|
2323 fw = nda(0).nbits (); |
|
2324 else |
|
2325 { |
|
2326 bool isneg = false; |
|
2327 int digits = 0; |
|
2328 |
5275
|
2329 for (octave_idx_type i = 0; i < dims.numel (); i++) |
4949
|
2330 { |
|
2331 int new_digits = static_cast<int> |
|
2332 (floor (log10 (double (abs (nda(i).value ()))) + 1.0)); |
|
2333 |
|
2334 if (new_digits > digits) |
|
2335 digits = new_digits; |
|
2336 |
|
2337 if (! isneg) |
|
2338 isneg = (abs (nda(i).value ()) != nda(i).value ()); |
|
2339 } |
|
2340 |
|
2341 fw = digits + isneg; |
|
2342 } |
|
2343 |
|
2344 int column_width = fw + (bank_format ? 5 : 2); |
5275
|
2345 octave_idx_type total_width = nc * column_width; |
4949
|
2346 int max_width = command_editor::terminal_cols () - extra_indent; |
5275
|
2347 octave_idx_type inc = nc; |
4949
|
2348 if (total_width > max_width && Vsplit_long_rows) |
|
2349 { |
|
2350 inc = max_width / column_width; |
|
2351 if (inc == 0) |
|
2352 inc++; |
|
2353 } |
|
2354 |
5275
|
2355 for (octave_idx_type i = 0; i < m; i++) |
4949
|
2356 { |
|
2357 if (m > 1) |
|
2358 { |
|
2359 std::string nm = "ans(:,:,"; |
|
2360 |
5765
|
2361 std::ostringstream buf; |
4949
|
2362 |
|
2363 for (int k = 2; k < ndims; k++) |
|
2364 { |
|
2365 buf << ra_idx(k) + 1; |
|
2366 |
|
2367 if (k < ndims - 1) |
|
2368 buf << ","; |
|
2369 else |
|
2370 buf << ")"; |
|
2371 } |
|
2372 |
5765
|
2373 nm += buf.str (); |
4949
|
2374 |
|
2375 os << nm << " =\n\n"; |
|
2376 } |
|
2377 |
|
2378 Array<idx_vector> idx (ndims); |
|
2379 |
|
2380 idx(0) = idx_vector (':'); |
|
2381 idx(1) = idx_vector (':'); |
|
2382 |
|
2383 for (int k = 2; k < ndims; k++) |
|
2384 idx(k) = idx_vector (ra_idx(k) + 1); |
|
2385 |
|
2386 Array2<T> page (nda.index (idx), nr, nc); |
|
2387 |
|
2388 if (free_format) |
|
2389 { |
|
2390 if (pr_as_read_syntax) |
|
2391 os << "[\n"; |
|
2392 |
5275
|
2393 for (octave_idx_type ii = 0; ii < nr; ii++) |
4949
|
2394 { |
5275
|
2395 for (octave_idx_type jj = 0; jj < nc; jj++) |
4949
|
2396 { |
|
2397 OCTAVE_QUIT; |
|
2398 os << " "; |
|
2399 os << typename octave_print_conv<T>::print_conv_type (page(ii,jj)); |
|
2400 } |
|
2401 os << "\n"; |
|
2402 } |
|
2403 |
|
2404 if (pr_as_read_syntax) |
|
2405 os << "]"; |
|
2406 } |
|
2407 else |
|
2408 { |
5275
|
2409 octave_idx_type n_rows = page.rows (); |
|
2410 octave_idx_type n_cols = page.cols (); |
|
2411 |
|
2412 for (octave_idx_type col = 0; col < n_cols; col += inc) |
4949
|
2413 { |
5275
|
2414 octave_idx_type lim = col + inc < n_cols ? col + inc : n_cols; |
4949
|
2415 |
|
2416 pr_col_num_header (os, total_width, max_width, lim, col, |
|
2417 extra_indent); |
|
2418 |
5275
|
2419 for (octave_idx_type ii = 0; ii < n_rows; ii++) |
4949
|
2420 { |
|
2421 os << std::setw (extra_indent) << ""; |
|
2422 |
5275
|
2423 for (octave_idx_type jj = col; jj < lim; jj++) |
4949
|
2424 { |
|
2425 OCTAVE_QUIT; |
|
2426 os << " "; |
|
2427 pr_int (os, page(ii,jj), fw); |
|
2428 } |
|
2429 if ((ii < n_rows - 1) || (i < m -1)) |
|
2430 os << "\n"; |
|
2431 } |
|
2432 } |
|
2433 } |
|
2434 |
|
2435 if (i < m - 1) |
|
2436 { |
|
2437 os << "\n"; |
|
2438 increment_index (ra_idx, dims, 2); |
|
2439 } |
4901
|
2440 } |
|
2441 } |
|
2442 } |
|
2443 |
5775
|
2444 // FIXME -- this is not the right spot for this... |
4901
|
2445 |
|
2446 template void |
4949
|
2447 pr_int (std::ostream&, const octave_int8&, int); |
|
2448 |
|
2449 template void |
|
2450 pr_int (std::ostream&, const octave_int16&, int); |
|
2451 |
|
2452 template void |
|
2453 pr_int (std::ostream&, const octave_int32&, int); |
|
2454 |
|
2455 template void |
|
2456 pr_int (std::ostream&, const octave_int64&, int); |
|
2457 |
|
2458 template void |
|
2459 pr_int (std::ostream&, const octave_uint8&, int); |
|
2460 |
|
2461 template void |
|
2462 pr_int (std::ostream&, const octave_uint16&, int); |
|
2463 |
|
2464 template void |
|
2465 pr_int (std::ostream&, const octave_uint32&, int); |
|
2466 |
|
2467 template void |
|
2468 pr_int (std::ostream&, const octave_uint64&, int); |
|
2469 |
6109
|
2470 template OCTINTERP_API void |
4901
|
2471 octave_print_internal (std::ostream&, const intNDArray<octave_int8>&, |
|
2472 bool, int); |
|
2473 |
6109
|
2474 template OCTINTERP_API void |
4901
|
2475 octave_print_internal (std::ostream&, const intNDArray<octave_int16>&, |
|
2476 bool, int); |
|
2477 |
6109
|
2478 template OCTINTERP_API void |
4901
|
2479 octave_print_internal (std::ostream&, const intNDArray<octave_int32>&, |
|
2480 bool, int); |
|
2481 |
6109
|
2482 template OCTINTERP_API void |
4901
|
2483 octave_print_internal (std::ostream&, const intNDArray<octave_int64>&, |
|
2484 bool, int); |
|
2485 |
6109
|
2486 template OCTINTERP_API void |
4901
|
2487 octave_print_internal (std::ostream&, const intNDArray<octave_uint8>&, |
|
2488 bool, int); |
|
2489 |
6109
|
2490 template OCTINTERP_API void |
4901
|
2491 octave_print_internal (std::ostream&, const intNDArray<octave_uint16>&, |
|
2492 bool, int); |
|
2493 |
6109
|
2494 template OCTINTERP_API void |
4901
|
2495 octave_print_internal (std::ostream&, const intNDArray<octave_uint32>&, |
|
2496 bool, int); |
|
2497 |
6109
|
2498 template OCTINTERP_API void |
4901
|
2499 octave_print_internal (std::ostream&, const intNDArray<octave_uint64>&, |
|
2500 bool, int); |
|
2501 |
|
2502 template <class T> |
|
2503 void |
4933
|
2504 octave_print_internal (std::ostream& os, const octave_int<T>& val, bool) |
4901
|
2505 { |
4949
|
2506 if (plus_format) |
|
2507 { |
|
2508 pr_plus_format (os, val); |
|
2509 } |
|
2510 else |
|
2511 { |
|
2512 if (free_format) |
5030
|
2513 os << typename octave_print_conv<octave_int<T> >::print_conv_type (val); |
4949
|
2514 else |
|
2515 pr_int (os, val); |
|
2516 } |
4901
|
2517 } |
|
2518 |
5775
|
2519 // FIXME -- this is not the right spot for this... |
4901
|
2520 |
6109
|
2521 template OCTINTERP_API void |
4901
|
2522 octave_print_internal (std::ostream&, const octave_int8&, bool); |
|
2523 |
6109
|
2524 template OCTINTERP_API void |
4901
|
2525 octave_print_internal (std::ostream&, const octave_int16&, bool); |
|
2526 |
6109
|
2527 template OCTINTERP_API void |
4901
|
2528 octave_print_internal (std::ostream&, const octave_int32&, bool); |
|
2529 |
6109
|
2530 template OCTINTERP_API void |
4901
|
2531 octave_print_internal (std::ostream&, const octave_int64&, bool); |
|
2532 |
6109
|
2533 template OCTINTERP_API void |
4901
|
2534 octave_print_internal (std::ostream&, const octave_uint8&, bool); |
|
2535 |
6109
|
2536 template OCTINTERP_API void |
4901
|
2537 octave_print_internal (std::ostream&, const octave_uint16&, bool); |
|
2538 |
6109
|
2539 template OCTINTERP_API void |
4901
|
2540 octave_print_internal (std::ostream&, const octave_uint32&, bool); |
|
2541 |
6109
|
2542 template OCTINTERP_API void |
4901
|
2543 octave_print_internal (std::ostream&, const octave_uint64&, bool); |
|
2544 |
3933
|
2545 extern void |
|
2546 octave_print_internal (std::ostream&, const Cell&, bool, int, bool) |
3928
|
2547 { |
3933
|
2548 panic_impossible (); |
3928
|
2549 } |
|
2550 |
3685
|
2551 DEFUN (disp, args, nargout, |
|
2552 "-*- texinfo -*-\n\ |
|
2553 @deftypefn {Built-in Function} {} disp (@var{x})\n\ |
|
2554 Display the value of @var{x}. For example,\n\ |
|
2555 \n\ |
|
2556 @example\n\ |
|
2557 disp (\"The value of pi is:\"), disp (pi)\n\ |
|
2558 \n\ |
|
2559 @print{} the value of pi is:\n\ |
|
2560 @print{} 3.1416\n\ |
|
2561 @end example\n\ |
|
2562 \n\ |
|
2563 @noindent\n\ |
|
2564 Note that the output from @code{disp} always ends with a newline.\n\ |
|
2565 \n\ |
|
2566 If an output value is requested, @code{disp} prints nothing and\n\ |
|
2567 returns the formatted output in a string.\n\ |
5642
|
2568 @seealso{fdisp}\n\ |
|
2569 @end deftypefn") |
3685
|
2570 { |
|
2571 octave_value retval; |
|
2572 |
|
2573 int nargin = args.length (); |
|
2574 |
|
2575 if (nargin == 1 && nargout < 2) |
|
2576 { |
|
2577 if (nargout == 0) |
|
2578 args(0).print (octave_stdout); |
|
2579 else |
|
2580 { |
5765
|
2581 std::ostringstream buf; |
3685
|
2582 args(0).print (buf); |
5765
|
2583 retval = buf.str (); |
3685
|
2584 } |
|
2585 } |
|
2586 else |
5823
|
2587 print_usage (); |
3685
|
2588 |
|
2589 return retval; |
|
2590 } |
|
2591 |
|
2592 DEFUN (fdisp, args, , |
|
2593 "-*- texinfo -*-\n\ |
|
2594 @deftypefn {Built-in Function} {} fdisp (@var{fid}, @var{x})\n\ |
|
2595 Display the value of @var{x} on the stream @var{fid}. For example,\n\ |
|
2596 \n\ |
|
2597 @example\n\ |
4869
|
2598 fdisp (stdout, \"The value of pi is:\"), fdisp (stdout, pi)\n\ |
3685
|
2599 \n\ |
|
2600 @print{} the value of pi is:\n\ |
|
2601 @print{} 3.1416\n\ |
|
2602 @end example\n\ |
|
2603 \n\ |
|
2604 @noindent\n\ |
4869
|
2605 Note that the output from @code{fdisp} always ends with a newline.\n\ |
5642
|
2606 @seealso{disp}\n\ |
|
2607 @end deftypefn") |
3685
|
2608 { |
|
2609 octave_value retval; |
|
2610 |
|
2611 int nargin = args.length (); |
|
2612 |
|
2613 if (nargin == 2) |
|
2614 { |
|
2615 int fid = octave_stream_list::get_file_number (args (0)); |
|
2616 |
|
2617 octave_stream os = octave_stream_list::lookup (fid, "fdisp"); |
|
2618 |
|
2619 if (! error_state) |
|
2620 { |
3769
|
2621 std::ostream *osp = os.output_stream (); |
3685
|
2622 |
|
2623 if (osp) |
|
2624 args(1).print (*osp); |
|
2625 else |
|
2626 error ("fdisp: stream not open for writing"); |
|
2627 } |
|
2628 } |
|
2629 else |
5823
|
2630 print_usage (); |
3685
|
2631 |
|
2632 return retval; |
|
2633 } |
|
2634 |
1
|
2635 static void |
|
2636 init_format_state (void) |
|
2637 { |
2387
|
2638 free_format = false; |
|
2639 plus_format = false; |
|
2640 bank_format = false; |
3608
|
2641 hex_format = 0; |
1309
|
2642 bit_format = 0; |
4833
|
2643 compact_format = false; |
2387
|
2644 print_e = false; |
|
2645 print_big_e = false; |
4509
|
2646 print_g = false; |
1
|
2647 } |
|
2648 |
|
2649 static void |
|
2650 set_output_prec_and_fw (int prec, int fw) |
|
2651 { |
5794
|
2652 Voutput_precision = prec; |
|
2653 Voutput_max_field_width = fw; |
1
|
2654 } |
|
2655 |
1755
|
2656 static void |
|
2657 set_format_style (int argc, const string_vector& argv) |
1
|
2658 { |
1755
|
2659 int idx = 1; |
|
2660 |
1899
|
2661 if (--argc > 0) |
1
|
2662 { |
3523
|
2663 std::string arg = argv[idx++]; |
2584
|
2664 |
1755
|
2665 if (arg == "short") |
1
|
2666 { |
1755
|
2667 if (--argc > 0) |
1
|
2668 { |
1755
|
2669 arg = argv[idx++]; |
|
2670 |
|
2671 if (arg == "e") |
1
|
2672 { |
1755
|
2673 init_format_state (); |
2387
|
2674 print_e = true; |
1755
|
2675 } |
|
2676 else if (arg == "E") |
|
2677 { |
|
2678 init_format_state (); |
2387
|
2679 print_e = true; |
|
2680 print_big_e = true; |
1
|
2681 } |
4509
|
2682 else if (arg == "g") |
|
2683 { |
|
2684 init_format_state (); |
|
2685 print_g = true; |
|
2686 } |
|
2687 else if (arg == "G") |
|
2688 { |
|
2689 init_format_state (); |
|
2690 print_g = true; |
|
2691 print_big_e = true; |
|
2692 } |
1
|
2693 else |
|
2694 { |
1755
|
2695 error ("format: unrecognized option `short %s'", |
|
2696 arg.c_str ()); |
|
2697 return; |
|
2698 } |
|
2699 } |
|
2700 else |
|
2701 init_format_state (); |
|
2702 |
4509
|
2703 set_output_prec_and_fw (5, 10); |
1755
|
2704 } |
|
2705 else if (arg == "long") |
|
2706 { |
|
2707 if (--argc > 0) |
|
2708 { |
|
2709 arg = argv[idx++]; |
|
2710 |
|
2711 if (arg == "e") |
|
2712 { |
|
2713 init_format_state (); |
2387
|
2714 print_e = true; |
1755
|
2715 } |
|
2716 else if (arg == "E") |
|
2717 { |
|
2718 init_format_state (); |
2387
|
2719 print_e = true; |
|
2720 print_big_e = true; |
1
|
2721 } |
4509
|
2722 else if (arg == "g") |
|
2723 { |
|
2724 init_format_state (); |
|
2725 print_g = true; |
|
2726 } |
|
2727 else if (arg == "G") |
|
2728 { |
|
2729 init_format_state (); |
|
2730 print_g = true; |
|
2731 print_big_e = true; |
|
2732 } |
1
|
2733 else |
1755
|
2734 { |
|
2735 error ("format: unrecognized option `long %s'", |
|
2736 arg.c_str ()); |
|
2737 return; |
|
2738 } |
1186
|
2739 } |
1
|
2740 else |
1755
|
2741 init_format_state (); |
|
2742 |
4509
|
2743 set_output_prec_and_fw (15, 20); |
1755
|
2744 } |
|
2745 else if (arg == "hex") |
|
2746 { |
|
2747 init_format_state (); |
3608
|
2748 hex_format = 1; |
1755
|
2749 } |
|
2750 else if (arg == "native-hex") |
|
2751 { |
|
2752 init_format_state (); |
|
2753 hex_format = 2; |
|
2754 } |
|
2755 else if (arg == "bit") |
|
2756 { |
|
2757 init_format_state (); |
|
2758 bit_format = 1; |
|
2759 } |
|
2760 else if (arg == "native-bit") |
|
2761 { |
|
2762 init_format_state (); |
|
2763 bit_format = 2; |
|
2764 } |
|
2765 else if (arg == "+" || arg == "plus") |
|
2766 { |
4632
|
2767 if (--argc > 0) |
|
2768 { |
|
2769 arg = argv[idx++]; |
|
2770 |
|
2771 if (arg.length () == 3) |
|
2772 plus_format_chars = arg; |
|
2773 else |
|
2774 { |
|
2775 error ("format: invalid option for plus format"); |
|
2776 return; |
|
2777 } |
|
2778 } |
|
2779 else |
|
2780 plus_format_chars = "+ "; |
|
2781 |
1755
|
2782 init_format_state (); |
2387
|
2783 plus_format = true; |
1755
|
2784 } |
|
2785 else if (arg == "bank") |
|
2786 { |
|
2787 init_format_state (); |
2387
|
2788 bank_format = true; |
1755
|
2789 } |
|
2790 else if (arg == "free") |
|
2791 { |
|
2792 init_format_state (); |
2387
|
2793 free_format = true; |
1755
|
2794 } |
|
2795 else if (arg == "none") |
|
2796 { |
|
2797 init_format_state (); |
2387
|
2798 free_format = true; |
1755
|
2799 } |
|
2800 else if (arg == "compact") |
|
2801 { |
2387
|
2802 compact_format = true; |
1755
|
2803 } |
|
2804 else if (arg == "loose") |
|
2805 { |
2387
|
2806 compact_format = false; |
1
|
2807 } |
|
2808 else |
1755
|
2809 error ("format: unrecognized format state `%s'", arg.c_str ()); |
1
|
2810 } |
|
2811 else |
|
2812 { |
|
2813 init_format_state (); |
|
2814 set_output_prec_and_fw (5, 10); |
|
2815 } |
|
2816 } |
|
2817 |
4208
|
2818 DEFCMD (format, args, , |
3372
|
2819 "-*- texinfo -*-\n\ |
|
2820 @deffn {Command} format options\n\ |
|
2821 Control the format of the output produced by @code{disp} and Octave's\n\ |
|
2822 normal echoing mechanism. Valid options are listed in the following\n\ |
|
2823 table.\n\ |
|
2824 \n\ |
|
2825 @table @code\n\ |
|
2826 @item short\n\ |
|
2827 Octave will try to print numbers with at\n\ |
4509
|
2828 least 5 significant figures within a field that is a maximum of 10\n\ |
|
2829 characters wide (not counting additional spacing that is added between\n\ |
|
2830 columns of a matrix).\n\ |
3372
|
2831 \n\ |
|
2832 If Octave is unable to format a matrix so that columns line up on the\n\ |
|
2833 decimal point and all the numbers fit within the maximum field width,\n\ |
|
2834 it switches to an @samp{e} format.\n\ |
|
2835 \n\ |
|
2836 @item long\n\ |
|
2837 Octave will try to print numbers with at least 15 significant figures\n\ |
4509
|
2838 within a field that is a maximum of 20 characters wide (not counting\n\ |
|
2839 additional spacing that is added between columns of a matrix).\n\ |
3372
|
2840 \n\ |
|
2841 As will the @samp{short} format, Octave will switch to an @samp{e}\n\ |
|
2842 format if it is unable to format a matrix so that columns line up on the\n\ |
|
2843 decimal point and all the numbers fit within the maximum field width.\n\ |
|
2844 \n\ |
|
2845 @item long e\n\ |
|
2846 @itemx short e\n\ |
|
2847 The same as @samp{format long} or @samp{format short} but always display\n\ |
|
2848 output with an @samp{e} format. For example, with the @samp{short e}\n\ |
4509
|
2849 format, @code{pi} is displayed as @code{3.14e+00}.\n\ |
3372
|
2850 \n\ |
|
2851 @item long E\n\ |
|
2852 @itemx short E\n\ |
|
2853 The same as @samp{format long e} or @samp{format short e} but always\n\ |
|
2854 display output with an uppercase @samp{E} format. For example, with\n\ |
4509
|
2855 the @samp{long E} format, @code{pi} is displayed as\n\ |
3372
|
2856 @code{3.14159265358979E+00}.\n\ |
4509
|
2857 @item long g\n\ |
|
2858 @itemx short g\n\ |
|
2859 Choose between normal @samp{long} (or @samp{short}) and and\n\ |
|
2860 @samp{long e} (or @samp{short e}) formats based on the magnitude\n\ |
|
2861 of the number. For example, with the @samp{short g} format,\n\ |
|
2862 @code{pi .^ [2; 4; 8; 16; 32]} is displayed as\n\ |
|
2863 \n\ |
|
2864 @example\n\ |
|
2865 @group\n\ |
|
2866 ans =\n\ |
|
2867 \n\ |
|
2868 3.1416\n\ |
|
2869 9.8696\n\ |
|
2870 97.409\n\ |
|
2871 9488.5\n\ |
|
2872 9.0032e+07\n\ |
|
2873 8.1058e+15\n\ |
|
2874 @end group\n\ |
|
2875 @end example\n\ |
|
2876 \n\ |
|
2877 @item long G\n\ |
|
2878 @itemx short G\n\ |
|
2879 The same as @samp{format long g} or @samp{format short g} but use an\n\ |
|
2880 uppercase @samp{E} format. For example, with the @samp{short G} format,\n\ |
|
2881 @code{pi .^ [2; 4; 8; 16; 32]} is displayed as\n\ |
|
2882 \n\ |
|
2883 @example\n\ |
|
2884 @group\n\ |
|
2885 ans =\n\ |
|
2886 \n\ |
|
2887 3.1416\n\ |
|
2888 9.8696\n\ |
|
2889 97.409\n\ |
|
2890 9488.5\n\ |
|
2891 9.0032E+07\n\ |
|
2892 8.1058E+15\n\ |
|
2893 @end group\n\ |
|
2894 @end example\n\ |
3372
|
2895 \n\ |
|
2896 @item free\n\ |
|
2897 @itemx none\n\ |
|
2898 Print output in free format, without trying to line up columns of\n\ |
|
2899 matrices on the decimal point. This also causes complex numbers to be\n\ |
|
2900 formatted like this @samp{(0.604194, 0.607088)} instead of like this\n\ |
|
2901 @samp{0.60419 + 0.60709i}.\n\ |
529
|
2902 \n\ |
3372
|
2903 @item bank\n\ |
|
2904 Print in a fixed format with two places to the right of the decimal\n\ |
|
2905 point.\n\ |
|
2906 \n\ |
|
2907 @item +\n\ |
4632
|
2908 @itemx + @var{chars}\n\ |
|
2909 @itemx plus\n\ |
|
2910 @itemx plus @var{chars}\n\ |
3372
|
2911 Print a @samp{+} symbol for nonzero matrix elements and a space for zero\n\ |
|
2912 matrix elements. This format can be very useful for examining the\n\ |
|
2913 structure of a large matrix.\n\ |
|
2914 \n\ |
4632
|
2915 The optional argument @var{chars} specifies a list of 3 characters to use\n\ |
|
2916 for printing values greater than zero, less than zero and equal to zero.\n\ |
|
2917 For example, with the @samp{+ \"+-.\"} format, @code{[1, 0, -1; -1, 0, 1]}\n\ |
|
2918 is displayed as\n\ |
|
2919 \n\ |
|
2920 @example\n\ |
|
2921 @group\n\ |
|
2922 ans =\n\ |
|
2923 \n\ |
|
2924 +.-\n\ |
|
2925 -.+\n\ |
|
2926 @end group\n\ |
|
2927 @end example\n\ |
|
2928 \n\ |
4833
|
2929 @itemx native-hex\n\ |
3372
|
2930 Print the hexadecimal representation numbers as they are stored in\n\ |
|
2931 memory. For example, on a workstation which stores 8 byte real values\n\ |
|
2932 in IEEE format with the least significant byte first, the value of\n\ |
|
2933 @code{pi} when printed in @code{hex} format is @code{400921fb54442d18}.\n\ |
|
2934 This format only works for numeric values.\n\ |
|
2935 \n\ |
4833
|
2936 @item hex\n\ |
|
2937 The same as @code{native-hex}, but always print the most significant\n\ |
|
2938 byte first.\n\ |
|
2939 @item native-bit\n\ |
3372
|
2940 Print the bit representation of numbers as stored in memory.\n\ |
|
2941 For example, the value of @code{pi} is\n\ |
|
2942 \n\ |
|
2943 @example\n\ |
|
2944 @group\n\ |
|
2945 01000000000010010010000111111011\n\ |
|
2946 01010100010001000010110100011000\n\ |
|
2947 @end group\n\ |
|
2948 @end example\n\ |
|
2949 \n\ |
|
2950 (shown here in two 32 bit sections for typesetting purposes) when\n\ |
|
2951 printed in bit format on a workstation which stores 8 byte real values\n\ |
|
2952 in IEEE format with the least significant byte first. This format only\n\ |
|
2953 works for numeric types.\n\ |
4833
|
2954 @item bit\n\ |
|
2955 The same as @code{native-bit}, but always print the most significant\n\ |
|
2956 bits first.\n\ |
|
2957 @item compact\n\ |
|
2958 Remove extra blank space around column number labels.\n\ |
|
2959 @item loose\n\ |
|
2960 Insert blank lines above and below column number labels (this is the\n\ |
|
2961 default).\n\ |
3372
|
2962 @end table\n\ |
|
2963 \n\ |
|
2964 By default, Octave will try to print numbers with at least 5 significant\n\ |
|
2965 figures within a field that is a maximum of 10 characters wide.\n\ |
|
2966 \n\ |
|
2967 If Octave is unable to format a matrix so that columns line up on the\n\ |
|
2968 decimal point and all the numbers fit within the maximum field width,\n\ |
|
2969 it switches to an @samp{e} format.\n\ |
|
2970 \n\ |
|
2971 If @code{format} is invoked without any options, the default format\n\ |
|
2972 state is restored.\n\ |
|
2973 @end deffn") |
529
|
2974 { |
2086
|
2975 octave_value_list retval; |
529
|
2976 |
1755
|
2977 int argc = args.length () + 1; |
|
2978 |
1968
|
2979 string_vector argv = args.make_argv ("format"); |
1755
|
2980 |
|
2981 if (error_state) |
|
2982 return retval; |
529
|
2983 |
|
2984 set_format_style (argc, argv); |
|
2985 |
|
2986 return retval; |
|
2987 } |
|
2988 |
5794
|
2989 DEFUN (fixed_point_format, args, nargout, |
|
2990 "-*- texinfo -*-\n\ |
|
2991 @deftypefn {Built-in Function} {@var{val} =} fixed_point_format ()\n\ |
|
2992 @deftypefnx {Built-in Function} {@var{old_val} =} fixed_point_format (@var{new_val})\n\ |
|
2993 Query or set the internal variable that controls whether Octave will\n\ |
|
2994 use a scaled format to print matrix values such that the largest\n\ |
|
2995 element may be written with a single leading digit with the scaling\n\ |
|
2996 factor is printed on the first line of output. For example,\n\ |
3321
|
2997 \n\ |
|
2998 @example\n\ |
|
2999 @group\n\ |
|
3000 octave:1> logspace (1, 7, 5)'\n\ |
|
3001 ans =\n\ |
|
3002 \n\ |
|
3003 1.0e+07 *\n\ |
|
3004 \n\ |
|
3005 0.00000\n\ |
|
3006 0.00003\n\ |
|
3007 0.00100\n\ |
|
3008 0.03162\n\ |
|
3009 1.00000\n\ |
|
3010 @end group\n\ |
|
3011 @end example\n\ |
|
3012 \n\ |
|
3013 @noindent\n\ |
|
3014 Notice that first value appears to be zero when it is actually 1. For\n\ |
|
3015 this reason, you should be careful when setting\n\ |
|
3016 @code{fixed_point_format} to a nonzero value.\n\ |
5794
|
3017 @end deftypefn") |
|
3018 { |
|
3019 return SET_INTERNAL_VARIABLE (fixed_point_format); |
|
3020 } |
|
3021 |
|
3022 DEFUN (print_empty_dimensions, args, nargout, |
|
3023 "-*- texinfo -*-\n\ |
|
3024 @deftypefn {Built-in Function} {@var{val} =} print_empty_dimensions ()\n\ |
|
3025 @deftypefnx {Built-in Function} {@var{old_val} =} print_empty_dimensions (@var{new_val})\n\ |
|
3026 Query or set the internal varaible that controls whether the\n\ |
3321
|
3027 dimensions of empty matrices are printed along with the empty matrix\n\ |
|
3028 symbol, @samp{[]}. For example, the expression\n\ |
|
3029 \n\ |
|
3030 @example\n\ |
|
3031 zeros (3, 0)\n\ |
|
3032 @end example\n\ |
|
3033 \n\ |
|
3034 @noindent\n\ |
|
3035 will print\n\ |
|
3036 \n\ |
|
3037 @example\n\ |
|
3038 ans = [](3x0)\n\ |
|
3039 @end example\n\ |
5794
|
3040 @end deftypefn") |
|
3041 { |
|
3042 return SET_INTERNAL_VARIABLE (print_empty_dimensions); |
|
3043 } |
|
3044 |
|
3045 DEFUN (split_long_rows, args, nargout, |
|
3046 "-*- texinfo -*-\n\ |
|
3047 @deftypefn {Built-in Function} {@var{val} =} split_long_rows ()\n\ |
|
3048 @deftypefnx {Built-in Function} {@var{old_val} =} split_long_rows (@var{new_val})\n\ |
|
3049 Query or set the internal variable that controls whether rows of a matrix\n\ |
|
3050 may be split when displayed to a terminal window. If the rows are split,\n\ |
|
3051 Octave will display the matrix in a series of smaller pieces, each of\n\ |
|
3052 which can fit within the limits of your terminal width and each set of\n\ |
|
3053 rows is labeled so that you can easily see which columns are currently\n\ |
|
3054 being displayed. For example:\n\ |
3321
|
3055 \n\ |
|
3056 @smallexample\n\ |
|
3057 @group\n\ |
|
3058 octave:13> rand (2,10)\n\ |
|
3059 ans =\n\ |
|
3060 \n\ |
|
3061 Columns 1 through 6:\n\ |
|
3062 \n\ |
|
3063 0.75883 0.93290 0.40064 0.43818 0.94958 0.16467\n\ |
|
3064 0.75697 0.51942 0.40031 0.61784 0.92309 0.40201\n\ |
|
3065 \n\ |
|
3066 Columns 7 through 10:\n\ |
|
3067 \n\ |
|
3068 0.90174 0.11854 0.72313 0.73326\n\ |
|
3069 0.44672 0.94303 0.56564 0.82150\n\ |
|
3070 @end group\n\ |
|
3071 @end smallexample\n\ |
5794
|
3072 @end deftypefn") |
|
3073 { |
|
3074 return SET_INTERNAL_VARIABLE (split_long_rows); |
|
3075 } |
|
3076 |
|
3077 DEFUN (output_max_field_width, args, nargout, |
|
3078 "-*- texinfo -*-\n\ |
|
3079 @deftypefn {Built-in Function} {@var{val} =} output_max_field_width ()\n\ |
|
3080 @deftypefnx {Built-in Function} {@var{old_val} =} output_max_field_width (@var{new_val})\n\ |
|
3081 Query or set the internal variable that specifies the maximum width\n\ |
|
3082 of a numeric output field.\n\ |
|
3083 @seealso{format, output_precision}\n\ |
|
3084 @end deftypefn") |
|
3085 { |
|
3086 return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_precision, 0, INT_MAX); |
|
3087 } |
|
3088 |
|
3089 DEFUN (output_precision, args, nargout, |
|
3090 "-*- texinfo -*-\n\ |
|
3091 @deftypefn {Built-in Function} {@var{val} =} output_precision ()\n\ |
|
3092 @deftypefnx {Built-in Function} {@var{old_val} =} output_precision (@var{new_val})\n\ |
|
3093 Query or set the internal variable that specifies the minimum number of\n\ |
|
3094 significant figures to display for numeric output.\n\ |
|
3095 @seealso{format, output_max_field_width}\n\ |
|
3096 @end deftypefn") |
|
3097 { |
|
3098 return SET_INTERNAL_VARIABLE_WITH_LIMITS (output_precision, -1, INT_MAX); |
|
3099 } |
|
3100 |
|
3101 DEFUN (struct_levels_to_print, args, nargout, |
|
3102 "-*- texinfo -*-\n\ |
|
3103 @deftypefn {Built-in Function} {@var{val} =} struct_levels_to_print ()\n\ |
|
3104 @deftypefnx {Built-in Function} {@var{old_val} =} struct_levels_to_print (@var{new_val})\n\ |
|
3105 Query or set the internal variable that specifies the number of\n\ |
|
3106 structure levels to display.\n\ |
|
3107 @end deftypefn") |
|
3108 { |
|
3109 return SET_INTERNAL_VARIABLE_WITH_LIMITS (struct_levels_to_print, |
|
3110 -1, INT_MAX); |
2165
|
3111 } |
|
3112 |
1
|
3113 /* |
|
3114 ;;; Local Variables: *** |
|
3115 ;;; mode: C++ *** |
|
3116 ;;; End: *** |
|
3117 */ |