1
|
1 // pr-output.cc -*- C++ -*- |
|
2 /* |
|
3 |
296
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
1
|
26 #endif |
|
27 |
|
28 #include <iostream.h> |
|
29 #include <strstream.h> |
|
30 #include <string.h> |
|
31 #include <math.h> |
|
32 #include <float.h> |
|
33 #include <Complex.h> |
|
34 |
453
|
35 #include "dMatrix.h" |
|
36 #include "CMatrix.h" |
1
|
37 #include "Range.h" |
|
38 |
|
39 #include "tree-const.h" |
|
40 #include "variables.h" |
|
41 #include "user-prefs.h" |
|
42 #include "pr-output.h" |
|
43 #include "mappers.h" |
|
44 #include "pager.h" |
542
|
45 #include "help.h" |
1
|
46 #include "error.h" |
|
47 #include "utils.h" |
529
|
48 #include "defun.h" |
1
|
49 |
|
50 // Current format string for real numbers and the real part of complex |
|
51 // numbers. |
529
|
52 static char *curr_real_fmt = 0; |
1
|
53 |
|
54 // Current format string for the imaginary part of complex numbers. |
529
|
55 static char *curr_imag_fmt = 0; |
1
|
56 |
|
57 // Nonzero means don\'t do any fancy formatting. |
|
58 static int free_format = 0; |
|
59 |
|
60 // Nonzero means print plus sign for nonzero, blank for zero. |
|
61 static int plus_format = 0; |
|
62 |
|
63 // Nonzero means always print like dollars and cents. |
|
64 static int bank_format = 0; |
|
65 |
|
66 // Nonzero means use an e format. |
|
67 static int print_e = 0; |
|
68 |
|
69 // Nonzero means print E instead of e for exponent field. |
|
70 static int print_big_e = 0; |
|
71 |
|
72 static int |
|
73 any_element_is_negative (const Matrix& a) |
|
74 { |
|
75 int nr = a.rows (); |
|
76 int nc = a.columns (); |
|
77 for (int j = 0; j < nc; j++) |
|
78 for (int i = 0; i < nr; i++) |
|
79 if (a.elem (i, j) < 0.0) |
|
80 return 1; |
|
81 return 0; |
|
82 } |
|
83 |
|
84 static int |
|
85 any_element_is_inf_or_nan (const Matrix& a) |
|
86 { |
|
87 int nr = a.rows (); |
|
88 int nc = a.columns (); |
|
89 for (int j = 0; j < nc; j++) |
|
90 for (int i = 0; i < nr; i++) |
|
91 { |
|
92 double val = a.elem (i, j); |
|
93 if (xisinf (val) || xisnan (val)) |
|
94 return 1; |
|
95 } |
|
96 return 0; |
|
97 } |
|
98 |
|
99 static int |
|
100 any_element_is_inf_or_nan (const ComplexMatrix& a) |
|
101 { |
|
102 int nr = a.rows (); |
|
103 int nc = a.columns (); |
|
104 for (int j = 0; j < nc; j++) |
|
105 for (int i = 0; i < nr; i++) |
|
106 { |
|
107 Complex val = a.elem (i, j); |
|
108 if (xisinf (val) || xisnan (val)) |
|
109 return 1; |
|
110 } |
|
111 return 0; |
|
112 } |
|
113 |
|
114 static int |
|
115 all_elements_are_int_or_inf_or_nan (const Matrix& a) |
|
116 { |
|
117 int nr = a.rows (); |
|
118 int nc = a.columns (); |
|
119 for (int j = 0; j < nc; j++) |
|
120 for (int i = 0; i < nr; i++) |
|
121 { |
|
122 double val = a.elem (i, j); |
|
123 if (xisnan (val) || D_NINT (val) == val) |
|
124 continue; |
|
125 else |
|
126 return 0; |
|
127 } |
|
128 return 1; |
|
129 } |
|
130 |
|
131 static Matrix |
|
132 abs (const Matrix& a) |
|
133 { |
|
134 int nr = a.rows (); |
|
135 int nc = a.columns (); |
|
136 Matrix retval (nr, nc); |
|
137 for (int j = 0; j < nc; j++) |
|
138 for (int i = 0; i < nr; i++) |
|
139 retval.elem (i, j) = fabs (a.elem (i, j)); |
|
140 return retval; |
|
141 } |
|
142 |
|
143 static double |
164
|
144 pr_max_internal (const Matrix& m) |
1
|
145 { |
|
146 int nr = m.rows (); |
|
147 int nc = m.columns (); |
|
148 |
|
149 double result = DBL_MIN; |
|
150 |
|
151 for (int j = 0; j < nc; j++) |
|
152 for (int i = 0; i < nr; i++) |
|
153 { |
|
154 double val = m.elem (i, j); |
|
155 if (xisinf (val) || xisnan (val)) |
|
156 continue; |
|
157 |
|
158 if (val > result) |
|
159 result = val; |
|
160 } |
|
161 return result; |
|
162 } |
|
163 |
|
164 static double |
164
|
165 pr_min_internal (const Matrix& m) |
1
|
166 { |
|
167 int nr = m.rows (); |
|
168 int nc = m.columns (); |
|
169 |
|
170 double result = DBL_MAX; |
|
171 |
|
172 for (int j = 0; j < nc; j++) |
|
173 for (int i = 0; i < nr; i++) |
|
174 { |
|
175 double val = m.elem (i, j); |
|
176 if (xisinf (val) || xisnan (val)) |
|
177 continue; |
|
178 |
|
179 if (val < result) |
|
180 result = val; |
|
181 } |
|
182 return result; |
|
183 } |
|
184 |
|
185 static void |
|
186 set_format (double d, int& fw) |
|
187 { |
529
|
188 curr_real_fmt = 0; |
|
189 curr_imag_fmt = 0; |
1
|
190 |
|
191 if (free_format) |
|
192 return; |
|
193 |
278
|
194 static char fmt_buf[128]; |
1
|
195 |
|
196 int sign = (d < 0.0); |
|
197 |
|
198 int inf_or_nan = (xisinf (d) || xisnan (d)); |
|
199 |
|
200 double d_abs = d < 0.0 ? -d : d; |
|
201 |
575
|
202 int digits = (inf_or_nan || d_abs == 0.0) ? 0 |
|
203 : (int) floor (log10 (d_abs) + 1.0); |
1
|
204 |
|
205 int prec = user_pref.output_precision; |
|
206 |
|
207 int ld, rd; |
|
208 |
|
209 if (bank_format) |
|
210 { |
|
211 fw = digits < 0 ? 4 : digits + 3; |
|
212 if (inf_or_nan && fw < 3) |
|
213 fw = 3; |
|
214 fw += sign; |
|
215 rd = 2; |
|
216 } |
|
217 else if (xisnan (d) || D_NINT (d) == d) |
|
218 { |
|
219 fw = digits; |
|
220 if (inf_or_nan && fw < 3) |
|
221 fw = 3; |
|
222 fw += sign; |
|
223 rd = 0; |
|
224 } |
|
225 else |
|
226 { |
|
227 if (digits > 0) |
|
228 { |
|
229 ld = digits; |
|
230 rd = prec - digits; |
|
231 digits++; |
|
232 } |
|
233 else |
|
234 { |
|
235 ld = 1; |
|
236 rd = prec - digits; |
|
237 digits = -digits + 1; |
|
238 } |
|
239 |
|
240 fw = ld + 1 + rd; |
|
241 if (inf_or_nan && fw < 3) |
|
242 fw = 3; |
|
243 fw += sign; |
|
244 } |
|
245 |
|
246 if (! bank_format && (fw > user_pref.output_max_field_width || print_e)) |
|
247 { |
|
248 int exp_field = 4; |
|
249 if (digits > 100) |
|
250 exp_field++; |
|
251 |
|
252 fw = 2 + prec + exp_field; |
|
253 if (inf_or_nan && fw < 3) |
|
254 fw = 3; |
|
255 fw += sign; |
|
256 |
|
257 if (print_big_e) |
|
258 sprintf (fmt_buf, "%%%d.%dE", fw, prec - 1); |
|
259 else |
|
260 sprintf (fmt_buf, "%%%d.%de", fw, prec - 1); |
|
261 } |
|
262 else |
|
263 { |
|
264 sprintf (fmt_buf, "%%%d.%df", fw, rd); |
|
265 } |
|
266 |
|
267 curr_real_fmt = &fmt_buf[0]; |
|
268 } |
|
269 |
|
270 static inline void |
|
271 set_format (double d) |
|
272 { |
|
273 int fw; |
|
274 set_format (d, fw); |
|
275 } |
|
276 |
|
277 static void |
164
|
278 set_format (const Matrix& m, int& fw) |
1
|
279 { |
529
|
280 curr_real_fmt = 0; |
|
281 curr_imag_fmt = 0; |
1
|
282 |
|
283 if (free_format) |
|
284 return; |
|
285 |
278
|
286 static char fmt_buf[128]; |
1
|
287 |
|
288 int sign = any_element_is_negative (m); |
|
289 |
|
290 int inf_or_nan = any_element_is_inf_or_nan (m); |
|
291 |
|
292 Matrix m_abs = abs (m); |
|
293 double max_abs = pr_max_internal (m_abs); |
|
294 double min_abs = pr_min_internal (m_abs); |
|
295 |
|
296 int x_max = max_abs == 0.0 ? 0 : (int) floor (log10 (max_abs) + 1.0); |
|
297 int x_min = min_abs == 0.0 ? 0 : (int) floor (log10 (min_abs) + 1.0); |
|
298 |
|
299 int prec = user_pref.output_precision; |
|
300 |
|
301 int ld, rd; |
|
302 |
|
303 if (bank_format) |
|
304 { |
|
305 int digits = x_max > x_min ? x_max : x_min; |
|
306 fw = digits <= 0 ? 4 : digits + 3; |
|
307 if (inf_or_nan && fw < 3) |
|
308 fw = 3; |
|
309 fw += sign; |
|
310 rd = 2; |
|
311 } |
|
312 else if (all_elements_are_int_or_inf_or_nan (m)) |
|
313 { |
|
314 int digits = x_max > x_min ? x_max : x_min; |
|
315 fw = digits <= 0 ? 1 : digits; |
|
316 if (inf_or_nan && fw < 3) |
|
317 fw = 3; |
|
318 fw += sign; |
|
319 rd = 0; |
|
320 } |
|
321 else |
|
322 { |
|
323 int ld_max, rd_max; |
|
324 if (x_max > 0) |
|
325 { |
|
326 ld_max = x_max; |
|
327 rd_max = prec - x_max; |
|
328 x_max++; |
|
329 } |
|
330 else |
|
331 { |
|
332 ld_max = 1; |
|
333 rd_max = prec - x_max; |
|
334 x_max = -x_max + 1; |
|
335 } |
|
336 |
|
337 int ld_min, rd_min; |
|
338 if (x_min > 0) |
|
339 { |
|
340 ld_min = x_min; |
|
341 rd_min = prec - x_min; |
|
342 x_min++; |
|
343 } |
|
344 else |
|
345 { |
|
346 ld_min = 1; |
|
347 rd_min = prec - x_min; |
|
348 x_min = -x_min + 1; |
|
349 } |
|
350 |
|
351 ld = ld_max > ld_min ? ld_max : ld_min; |
|
352 rd = rd_max > rd_min ? rd_max : rd_min; |
|
353 |
|
354 fw = ld + 1 + rd; |
|
355 if (inf_or_nan && fw < 3) |
|
356 fw = 3; |
|
357 fw += sign; |
|
358 } |
|
359 |
|
360 if (! bank_format && (fw > user_pref.output_max_field_width || print_e)) |
|
361 { |
|
362 int exp_field = 4; |
|
363 if (x_max > 100 || x_min > 100) |
|
364 exp_field++; |
|
365 |
|
366 fw = 2 + prec + exp_field; |
|
367 if (inf_or_nan && fw < 3) |
|
368 fw = 3; |
|
369 fw += sign; |
|
370 |
|
371 if (print_big_e) |
|
372 sprintf (fmt_buf, "%%%d.%dE", fw, prec - 1); |
|
373 else |
|
374 sprintf (fmt_buf, "%%%d.%de", fw, prec - 1); |
|
375 } |
|
376 else |
|
377 { |
|
378 sprintf (fmt_buf, "%%%d.%df", fw, rd); |
|
379 } |
|
380 |
|
381 curr_real_fmt = &fmt_buf[0]; |
|
382 } |
|
383 |
|
384 static inline void |
164
|
385 set_format (const Matrix& m) |
1
|
386 { |
|
387 int fw; |
|
388 set_format (m, fw); |
|
389 } |
|
390 |
|
391 static void |
164
|
392 set_format (const Complex& c, int& r_fw, int& i_fw) |
1
|
393 { |
529
|
394 curr_real_fmt = 0; |
|
395 curr_imag_fmt = 0; |
1
|
396 |
|
397 if (free_format) |
|
398 return; |
|
399 |
278
|
400 static char r_fmt_buf[128]; |
|
401 static char i_fmt_buf[128]; |
1
|
402 |
|
403 double rp = c.real (); |
|
404 double ip = c.imag (); |
|
405 |
|
406 int sign = (rp < 0.0); |
|
407 |
|
408 int inf_or_nan = (xisinf (c) || xisnan (c)); |
|
409 |
|
410 double r_abs = rp < 0.0 ? -rp : rp; |
|
411 double i_abs = ip < 0.0 ? -ip : ip; |
|
412 |
|
413 int r_x = r_abs == 0.0 ? 0 : (int) floor (log10 (r_abs) + 1.0); |
|
414 int i_x = i_abs == 0.0 ? 0 : (int) floor (log10 (i_abs) + 1.0); |
|
415 |
|
416 int x_max, x_min; |
|
417 |
|
418 if (r_x > i_x) |
|
419 { |
|
420 x_max = r_x; |
|
421 x_min = i_x; |
|
422 } |
|
423 else |
|
424 { |
|
425 x_max = i_x; |
|
426 x_min = r_x; |
|
427 } |
|
428 |
|
429 int prec = user_pref.output_precision; |
|
430 |
|
431 int ld, rd; |
|
432 |
|
433 if (bank_format) |
|
434 { |
|
435 int digits = r_x; |
|
436 i_fw = 0; |
|
437 r_fw = digits <= 0 ? 4 : digits + 3; |
|
438 if (inf_or_nan && r_fw < 3) |
|
439 r_fw = 3; |
|
440 r_fw += sign; |
|
441 rd = 2; |
|
442 } |
|
443 else if (inf_or_nan || (D_NINT (rp) == rp && D_NINT (ip) == ip)) |
|
444 { |
|
445 int digits = x_max > x_min ? x_max : x_min; |
|
446 i_fw = r_fw = digits <= 0 ? 1 : digits; |
|
447 if (inf_or_nan && i_fw < 3) |
|
448 i_fw = r_fw = 3; |
|
449 r_fw += sign; |
|
450 rd = 0; |
|
451 } |
|
452 else |
|
453 { |
|
454 int ld_max, rd_max; |
|
455 if (x_max > 0) |
|
456 { |
|
457 ld_max = x_max; |
|
458 rd_max = prec - x_max; |
|
459 x_max++; |
|
460 } |
|
461 else |
|
462 { |
|
463 ld_max = 1; |
|
464 rd_max = prec - x_max; |
|
465 x_max = -x_max + 1; |
|
466 } |
|
467 |
|
468 int ld_min, rd_min; |
|
469 if (x_min > 0) |
|
470 { |
|
471 ld_min = x_min; |
|
472 rd_min = prec - x_min; |
|
473 x_min++; |
|
474 } |
|
475 else |
|
476 { |
|
477 ld_min = 1; |
|
478 rd_min = prec - x_min; |
|
479 x_min = -x_min + 1; |
|
480 } |
|
481 |
|
482 ld = ld_max > ld_min ? ld_max : ld_min; |
|
483 rd = rd_max > rd_min ? rd_max : rd_min; |
|
484 |
|
485 i_fw = r_fw = ld + 1 + rd; |
|
486 if (inf_or_nan && i_fw < 3) |
|
487 i_fw = r_fw = 3; |
|
488 r_fw += sign; |
|
489 } |
|
490 |
|
491 if (! bank_format && (r_fw > user_pref.output_max_field_width || print_e)) |
|
492 { |
|
493 int exp_field = 4; |
|
494 if (x_max > 100 || x_min > 100) |
|
495 exp_field++; |
|
496 |
|
497 i_fw = r_fw = 1 + prec + exp_field; |
|
498 if (inf_or_nan && i_fw < 3) |
|
499 i_fw = r_fw = 3; |
|
500 r_fw += sign; |
|
501 |
|
502 if (print_big_e) |
|
503 { |
|
504 sprintf (r_fmt_buf, "%%%d.%dE", r_fw, prec - 1); |
|
505 sprintf (i_fmt_buf, "%%%d.%dE", i_fw, prec - 1); |
|
506 } |
|
507 else |
|
508 { |
|
509 sprintf (r_fmt_buf, "%%%d.%de", r_fw, prec - 1); |
|
510 sprintf (i_fmt_buf, "%%%d.%de", i_fw, prec - 1); |
|
511 } |
|
512 } |
|
513 else |
|
514 { |
|
515 sprintf (r_fmt_buf, "%%%d.%df", r_fw, rd); |
|
516 sprintf (i_fmt_buf, "%%%d.%df", i_fw, rd); |
|
517 } |
|
518 |
|
519 curr_real_fmt = &r_fmt_buf[0]; |
|
520 curr_imag_fmt = &i_fmt_buf[0]; |
|
521 } |
|
522 |
|
523 static inline void |
164
|
524 set_format (const Complex& c) |
1
|
525 { |
|
526 int r_fw, i_fw; |
|
527 set_format (c, r_fw, i_fw); |
|
528 } |
|
529 |
|
530 static void |
164
|
531 set_format (const ComplexMatrix& cm, int& r_fw, int& i_fw) |
1
|
532 { |
529
|
533 curr_real_fmt = 0; |
|
534 curr_imag_fmt = 0; |
1
|
535 |
|
536 if (free_format) |
|
537 return; |
|
538 |
278
|
539 static char r_fmt_buf[128]; |
|
540 static char i_fmt_buf[128]; |
1
|
541 |
|
542 Matrix rp = real (cm); |
|
543 Matrix ip = imag (cm); |
|
544 |
|
545 int sign = any_element_is_negative (rp); |
|
546 |
|
547 int inf_or_nan = any_element_is_inf_or_nan (cm); |
|
548 |
|
549 Matrix r_m_abs = abs (rp); |
|
550 double r_max_abs = pr_max_internal (r_m_abs); |
|
551 double r_min_abs = pr_min_internal (r_m_abs); |
|
552 |
|
553 Matrix i_m_abs = abs (ip); |
|
554 double i_max_abs = pr_max_internal (i_m_abs); |
|
555 double i_min_abs = pr_min_internal (i_m_abs); |
|
556 |
|
557 int r_x_max = r_max_abs == 0.0 ? 0 : (int) floor (log10 (r_max_abs) + 1.0); |
|
558 int r_x_min = r_min_abs == 0.0 ? 0 : (int) floor (log10 (r_min_abs) + 1.0); |
|
559 |
|
560 int i_x_max = i_max_abs == 0.0 ? 0 : (int) floor (log10 (i_max_abs) + 1.0); |
|
561 int i_x_min = i_min_abs == 0.0 ? 0 : (int) floor (log10 (i_min_abs) + 1.0); |
|
562 |
|
563 int x_max = r_x_max > i_x_max ? r_x_max : i_x_max; |
|
564 int x_min = r_x_min > i_x_min ? r_x_min : i_x_min; |
|
565 |
|
566 int prec = user_pref.output_precision; |
|
567 |
|
568 int ld, rd; |
|
569 |
|
570 if (bank_format) |
|
571 { |
|
572 int digits = r_x_max > r_x_min ? r_x_max : r_x_min; |
|
573 i_fw = 0; |
|
574 r_fw = digits <= 0 ? 4 : digits + 3; |
|
575 if (inf_or_nan && i_fw < 3) |
|
576 i_fw = r_fw = 3; |
|
577 r_fw += sign; |
|
578 rd = 2; |
|
579 } |
|
580 else if (all_elements_are_int_or_inf_or_nan (rp) |
|
581 && all_elements_are_int_or_inf_or_nan (ip)) |
|
582 { |
|
583 int digits = x_max > x_min ? x_max : x_min; |
|
584 i_fw = r_fw = digits <= 0 ? 1 : digits; |
|
585 if (inf_or_nan && i_fw < 3) |
|
586 i_fw = r_fw = 3; |
|
587 r_fw += sign; |
|
588 rd = 0; |
|
589 } |
|
590 else |
|
591 { |
|
592 int ld_max, rd_max; |
|
593 if (x_max > 0) |
|
594 { |
|
595 ld_max = x_max; |
|
596 rd_max = prec - x_max; |
|
597 x_max++; |
|
598 } |
|
599 else |
|
600 { |
|
601 ld_max = 1; |
|
602 rd_max = prec - x_max; |
|
603 x_max = -x_max + 1; |
|
604 } |
|
605 |
|
606 int ld_min, rd_min; |
|
607 if (x_min > 0) |
|
608 { |
|
609 ld_min = x_min; |
|
610 rd_min = prec - x_min; |
|
611 x_min++; |
|
612 } |
|
613 else |
|
614 { |
|
615 ld_min = 1; |
|
616 rd_min = prec - x_min; |
|
617 x_min = -x_min + 1; |
|
618 } |
|
619 |
|
620 ld = ld_max > ld_min ? ld_max : ld_min; |
|
621 rd = rd_max > rd_min ? rd_max : rd_min; |
|
622 |
|
623 i_fw = r_fw = ld + 1 + rd; |
|
624 if (inf_or_nan && i_fw < 3) |
|
625 i_fw = r_fw = 3; |
|
626 r_fw += sign; |
|
627 } |
|
628 |
|
629 if (! bank_format && (r_fw > user_pref.output_max_field_width || print_e)) |
|
630 { |
|
631 int exp_field = 4; |
|
632 if (x_max > 100 || x_min > 100) |
|
633 exp_field++; |
|
634 |
|
635 i_fw = r_fw = 1 + prec + exp_field; |
|
636 if (inf_or_nan && i_fw < 3) |
|
637 i_fw = r_fw = 3; |
|
638 r_fw += sign; |
|
639 |
|
640 if (print_big_e) |
|
641 { |
|
642 sprintf (r_fmt_buf, "%%%d.%dE", r_fw, prec - 1); |
|
643 sprintf (i_fmt_buf, "%%%d.%dE", i_fw, prec - 1); |
|
644 } |
|
645 else |
|
646 { |
|
647 sprintf (r_fmt_buf, "%%%d.%de", r_fw, prec - 1); |
|
648 sprintf (i_fmt_buf, "%%%d.%de", i_fw, prec - 1); |
|
649 } |
|
650 } |
|
651 else |
|
652 { |
|
653 sprintf (r_fmt_buf, "%%%d.%df", r_fw, rd); |
|
654 sprintf (i_fmt_buf, "%%%d.%df", i_fw, rd); |
|
655 } |
|
656 |
|
657 curr_real_fmt = &r_fmt_buf[0]; |
|
658 curr_imag_fmt = &i_fmt_buf[0]; |
|
659 } |
|
660 |
|
661 static int |
164
|
662 all_elements_are_ints (const Range& r) |
1
|
663 { |
|
664 // If the base and increment are ints, the final value in the range |
|
665 // will also be an integer, even if the limit is not. |
|
666 |
|
667 double b = r.base (); |
|
668 double i = r.inc (); |
|
669 |
|
670 return ((double) NINT (b) == b && (double) NINT (i) == i); |
|
671 } |
|
672 |
|
673 static inline void |
164
|
674 set_format (const ComplexMatrix& cm) |
1
|
675 { |
|
676 int r_fw, i_fw; |
|
677 set_format (cm, r_fw, i_fw); |
|
678 } |
|
679 |
|
680 static void |
164
|
681 set_format (const Range& r, int& fw) |
1
|
682 { |
529
|
683 curr_real_fmt = 0; |
|
684 curr_imag_fmt = 0; |
1
|
685 |
|
686 if (free_format) |
|
687 return; |
|
688 |
278
|
689 static char fmt_buf[128]; |
1
|
690 |
|
691 double r_min = r.base (); |
|
692 double r_max = r.limit (); |
|
693 |
|
694 if (r_max < r_min) |
|
695 { |
|
696 double tmp = r_max; |
|
697 r_max = r_min; |
|
698 r_min = tmp; |
|
699 } |
|
700 |
|
701 int sign = (r_min < 0.0); |
|
702 |
|
703 double max_abs = r_max < 0.0 ? -r_max : r_max; |
|
704 double min_abs = r_min < 0.0 ? -r_min : r_min; |
|
705 |
|
706 int x_max = max_abs == 0.0 ? 0 : (int) floor (log10 (max_abs) + 1.0); |
|
707 int x_min = min_abs == 0.0 ? 0 : (int) floor (log10 (min_abs) + 1.0); |
|
708 |
|
709 int prec = user_pref.output_precision; |
|
710 |
|
711 int ld, rd; |
|
712 |
|
713 if (bank_format) |
|
714 { |
|
715 int digits = x_max > x_min ? x_max : x_min; |
|
716 fw = sign + digits < 0 ? 4 : digits + 3; |
|
717 rd = 2; |
|
718 } |
|
719 else if (all_elements_are_ints (r)) |
|
720 { |
|
721 int digits = x_max > x_min ? x_max : x_min; |
|
722 fw = sign + digits; |
|
723 rd = 0; |
|
724 } |
|
725 else |
|
726 { |
|
727 int ld_max, rd_max; |
|
728 if (x_max > 0) |
|
729 { |
|
730 ld_max = x_max; |
|
731 rd_max = prec - x_max; |
|
732 x_max++; |
|
733 } |
|
734 else |
|
735 { |
|
736 ld_max = 1; |
|
737 rd_max = prec - x_max; |
|
738 x_max = -x_max + 1; |
|
739 } |
|
740 |
|
741 int ld_min, rd_min; |
|
742 if (x_min > 0) |
|
743 { |
|
744 ld_min = x_min; |
|
745 rd_min = prec - x_min; |
|
746 x_min++; |
|
747 } |
|
748 else |
|
749 { |
|
750 ld_min = 1; |
|
751 rd_min = prec - x_min; |
|
752 x_min = -x_min + 1; |
|
753 } |
|
754 |
|
755 ld = ld_max > ld_min ? ld_max : ld_min; |
|
756 rd = rd_max > rd_min ? rd_max : rd_min; |
|
757 |
|
758 fw = sign + ld + 1 + rd; |
|
759 } |
|
760 |
|
761 if (! bank_format && (fw > user_pref.output_max_field_width || print_e)) |
|
762 { |
|
763 int exp_field = 4; |
|
764 if (x_max > 100 || x_min > 100) |
|
765 exp_field++; |
|
766 |
|
767 fw = sign + 2 + prec + exp_field; |
|
768 |
|
769 if (print_big_e) |
|
770 sprintf (fmt_buf, "%%%d.%dE", fw, prec - 1); |
|
771 else |
|
772 sprintf (fmt_buf, "%%%d.%de", fw, prec - 1); |
|
773 } |
|
774 else |
|
775 { |
|
776 sprintf (fmt_buf, "%%%d.%df", fw, rd); |
|
777 } |
|
778 |
|
779 curr_real_fmt = &fmt_buf[0]; |
|
780 } |
|
781 |
|
782 static inline void |
164
|
783 set_format (const Range& r) |
1
|
784 { |
|
785 int fw; |
|
786 set_format (r, fw); |
|
787 } |
|
788 |
|
789 static inline void |
626
|
790 pr_any_float (const char *fmt, ostream& os, double d, int fw = 0) |
1
|
791 { |
|
792 if (d == -0.0) |
|
793 d = 0.0; |
|
794 |
529
|
795 if (fmt) |
1
|
796 { |
|
797 if (xisinf (d)) |
|
798 { |
|
799 char *s; |
|
800 if (d < 0.0) |
|
801 s = "-Inf"; |
|
802 else |
|
803 s = "Inf"; |
|
804 |
|
805 if (fw > 0) |
|
806 os.form ("%*s", fw, s); |
|
807 else |
|
808 os << s; |
|
809 } |
|
810 else if (xisnan (d)) |
|
811 { |
|
812 if (fw > 0) |
|
813 os.form ("%*s", fw, "NaN"); |
|
814 else |
|
815 os << "NaN"; |
|
816 } |
|
817 else |
|
818 os.form (fmt, d); |
|
819 } |
529
|
820 else |
|
821 os << d; |
1
|
822 } |
|
823 |
|
824 static inline void |
626
|
825 pr_float (ostream& os, double d, int fw = 0) |
1
|
826 { |
|
827 pr_any_float (curr_real_fmt, os, d, fw); |
|
828 } |
|
829 |
|
830 static inline void |
626
|
831 pr_imag_float (ostream& os, double d, int fw = 0) |
1
|
832 { |
|
833 pr_any_float (curr_imag_fmt, os, d, fw); |
|
834 } |
|
835 |
|
836 static inline void |
626
|
837 pr_complex (ostream& os, const Complex& c, int r_fw = 0, int i_fw = 0) |
1
|
838 { |
|
839 double r = c.real (); |
|
840 pr_float (os, r, r_fw); |
|
841 if (! bank_format) |
|
842 { |
|
843 double i = c.imag (); |
|
844 if (i < 0) |
|
845 { |
|
846 os << " - "; |
|
847 i = -i; |
|
848 pr_imag_float (os, i, i_fw); |
|
849 } |
|
850 else |
|
851 { |
|
852 os << " + "; |
|
853 pr_imag_float (os, i, i_fw); |
|
854 } |
|
855 os << "i"; |
|
856 } |
|
857 } |
|
858 |
626
|
859 static void |
|
860 print_empty_matrix (ostream& os, int nr, int nc, int pr_as_read_syntax) |
|
861 { |
|
862 assert (nr == 0 || nc == 0); |
|
863 |
|
864 if (pr_as_read_syntax) |
|
865 { |
|
866 if (nr == 0 && nc == 0) |
|
867 os << "[]"; |
|
868 else |
|
869 os << "zeros (" << nr << ", " << nc << ")"; |
|
870 } |
|
871 else |
|
872 { |
|
873 os << "[]"; |
|
874 if (user_pref.print_empty_dimensions) |
|
875 os << "(" << nr << "x" << nc << ")"; |
|
876 os << "\n"; |
|
877 } |
|
878 } |
|
879 |
1
|
880 void |
719
|
881 octave_print_internal (ostream& os, double d, int pr_as_read_syntax) |
1
|
882 { |
|
883 if (plus_format) |
|
884 { |
|
885 if (d == 0.0) |
|
886 os << " "; |
|
887 else |
|
888 os << "+"; |
|
889 } |
|
890 else |
|
891 { |
|
892 set_format (d); |
|
893 if (free_format) |
|
894 os << d; |
|
895 else |
|
896 pr_float (os, d); |
|
897 } |
626
|
898 |
|
899 if (! pr_as_read_syntax) |
|
900 os << "\n"; |
1
|
901 } |
|
902 |
|
903 void |
719
|
904 octave_print_internal (ostream& os, const Matrix& m, int pr_as_read_syntax) |
1
|
905 { |
|
906 int nr = m.rows (); |
|
907 int nc = m.columns (); |
|
908 |
626
|
909 if (nr == 0 || nc == 0) |
|
910 print_empty_matrix (os, nr, nc, pr_as_read_syntax); |
|
911 else if (plus_format && ! pr_as_read_syntax) |
1
|
912 { |
|
913 for (int i = 0; i < nr; i++) |
|
914 { |
|
915 for (int j = 0; j < nc; j++) |
|
916 { |
|
917 if (j == 0) |
|
918 os << " "; |
|
919 |
|
920 if (m.elem (i, j) == 0.0) |
|
921 os << " "; |
|
922 else |
|
923 os << "+"; |
|
924 } |
|
925 os << "\n"; |
|
926 } |
|
927 } |
|
928 else |
|
929 { |
|
930 int fw; |
|
931 set_format (m, fw); |
|
932 int column_width = fw + 2; |
|
933 int total_width = nc * column_width; |
|
934 int max_width = terminal_columns (); |
|
935 |
626
|
936 if (pr_as_read_syntax) |
|
937 max_width -= 4; |
|
938 |
1
|
939 if (free_format) |
|
940 { |
626
|
941 if (pr_as_read_syntax) |
|
942 os << "[\n"; |
|
943 |
1
|
944 os << m; |
626
|
945 |
|
946 if (pr_as_read_syntax) |
|
947 os << "]"; |
|
948 |
1
|
949 return; |
|
950 } |
|
951 |
|
952 int inc = nc; |
|
953 if (total_width > max_width && user_pref.split_long_rows) |
|
954 { |
|
955 inc = max_width / column_width; |
|
956 if (inc == 0) |
|
957 inc++; |
|
958 } |
|
959 |
626
|
960 if (pr_as_read_syntax) |
1
|
961 { |
|
962 for (int i = 0; i < nr; i++) |
|
963 { |
626
|
964 int col = 0; |
|
965 while (col < nc) |
1
|
966 { |
626
|
967 int lim = col + inc < nc ? col + inc : nc; |
|
968 |
|
969 for (int j = col; j < lim; j++) |
|
970 { |
|
971 if (i == 0 && j == 0) |
|
972 os << "[ "; |
|
973 else |
|
974 { |
|
975 if (j > col && j < lim) |
|
976 os << ", "; |
|
977 else |
|
978 os << " "; |
|
979 } |
|
980 |
|
981 pr_float (os, m.elem (i, j)); |
|
982 } |
|
983 |
|
984 col += inc; |
|
985 |
|
986 if (col >= nc) |
|
987 { |
|
988 if (i == nr - 1) |
|
989 os << " ]"; |
|
990 else |
|
991 os << ";\n"; |
|
992 } |
|
993 else |
|
994 os << " ...\n"; |
1
|
995 } |
|
996 } |
626
|
997 } |
|
998 else |
|
999 { |
|
1000 for (int col = 0; col < nc; col += inc) |
|
1001 { |
|
1002 int lim = col + inc < nc ? col + inc : nc; |
|
1003 |
|
1004 if (total_width > max_width && user_pref.split_long_rows) |
|
1005 { |
|
1006 if (col != 0) |
|
1007 os << "\n"; |
|
1008 |
|
1009 int num_cols = lim - col; |
|
1010 if (num_cols == 1) |
|
1011 os << " Column " << col + 1 << ":\n\n"; |
|
1012 else if (num_cols == 2) |
|
1013 os << " Columns " << col + 1 << " and " << lim |
|
1014 << ":\n\n"; |
|
1015 else |
|
1016 os << " Columns " << col + 1 << " through " << lim |
|
1017 << ":\n\n"; |
|
1018 } |
|
1019 |
|
1020 for (int i = 0; i < nr; i++) |
|
1021 { |
|
1022 for (int j = col; j < lim; j++) |
|
1023 { |
|
1024 os << " "; |
|
1025 |
|
1026 pr_float (os, m.elem (i, j), fw); |
|
1027 } |
|
1028 |
|
1029 os << "\n"; |
|
1030 } |
|
1031 } |
1
|
1032 } |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 void |
626
|
1037 octave_print_internal (ostream& os, const Complex& c, |
|
1038 int pr_as_read_syntax) |
1
|
1039 { |
|
1040 if (plus_format) |
|
1041 { |
|
1042 if (c == 0.0) |
|
1043 os << " "; |
|
1044 else |
|
1045 os << "+"; |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 set_format (c); |
|
1050 if (free_format) |
|
1051 os << c; |
|
1052 else |
|
1053 pr_complex (os, c); |
|
1054 } |
626
|
1055 |
|
1056 if (! pr_as_read_syntax) |
|
1057 os << "\n"; |
1
|
1058 } |
|
1059 |
|
1060 void |
626
|
1061 octave_print_internal (ostream& os, const ComplexMatrix& cm, |
|
1062 int pr_as_read_syntax) |
1
|
1063 { |
|
1064 int nr = cm.rows (); |
|
1065 int nc = cm.columns (); |
|
1066 |
626
|
1067 if (nr == 0 || nc == 0) |
|
1068 print_empty_matrix (os, nr, nc, pr_as_read_syntax); |
|
1069 else if (plus_format && ! pr_as_read_syntax) |
1
|
1070 { |
|
1071 for (int i = 0; i < nr; i++) |
|
1072 { |
|
1073 for (int j = 0; j < nc; j++) |
|
1074 { |
|
1075 if (j == 0) |
|
1076 os << " "; |
|
1077 |
|
1078 if (cm.elem (i, j) == 0.0) |
|
1079 os << " "; |
|
1080 else |
|
1081 os << "+"; |
|
1082 } |
|
1083 os << "\n"; |
|
1084 } |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 int r_fw, i_fw; |
|
1089 set_format (cm, r_fw, i_fw); |
|
1090 int column_width = i_fw + r_fw; |
|
1091 column_width += bank_format ? 2 : 7; |
|
1092 int total_width = nc * column_width; |
|
1093 int max_width = terminal_columns (); |
|
1094 |
626
|
1095 if (pr_as_read_syntax) |
|
1096 max_width -= 4; |
|
1097 |
1
|
1098 if (free_format) |
|
1099 { |
626
|
1100 if (pr_as_read_syntax) |
|
1101 os << "[\n"; |
|
1102 |
1
|
1103 os << cm; |
626
|
1104 |
|
1105 if (pr_as_read_syntax) |
|
1106 os << "]"; |
|
1107 |
1
|
1108 return; |
|
1109 } |
|
1110 |
|
1111 int inc = nc; |
|
1112 if (total_width > max_width && user_pref.split_long_rows) |
|
1113 { |
|
1114 inc = max_width / column_width; |
|
1115 if (inc == 0) |
|
1116 inc++; |
|
1117 } |
|
1118 |
626
|
1119 if (pr_as_read_syntax) |
1
|
1120 { |
|
1121 for (int i = 0; i < nr; i++) |
|
1122 { |
626
|
1123 int col = 0; |
|
1124 while (col < nc) |
1
|
1125 { |
626
|
1126 int lim = col + inc < nc ? col + inc : nc; |
|
1127 |
|
1128 for (int j = col; j < lim; j++) |
|
1129 { |
|
1130 if (i == 0 && j == 0) |
|
1131 os << "[ "; |
|
1132 else |
|
1133 { |
|
1134 if (j > col && j < lim) |
|
1135 os << ", "; |
|
1136 else |
|
1137 os << " "; |
|
1138 } |
|
1139 |
|
1140 pr_complex (os, cm.elem (i, j)); |
|
1141 } |
|
1142 |
|
1143 col += inc; |
|
1144 |
|
1145 if (col >= nc) |
|
1146 { |
|
1147 if (i == nr - 1) |
|
1148 os << " ]"; |
|
1149 else |
|
1150 os << ";\n"; |
|
1151 } |
1
|
1152 else |
626
|
1153 os << " ...\n"; |
1
|
1154 } |
|
1155 } |
626
|
1156 } |
|
1157 else |
|
1158 { |
|
1159 for (int col = 0; col < nc; col += inc) |
|
1160 { |
|
1161 int lim = col + inc < nc ? col + inc : nc; |
|
1162 |
|
1163 if (total_width > max_width && user_pref.split_long_rows) |
|
1164 { |
|
1165 if (col != 0) |
|
1166 os << "\n"; |
|
1167 |
|
1168 int num_cols = lim - col; |
|
1169 if (num_cols == 1) |
|
1170 os << " Column " << col + 1 << ":\n\n"; |
|
1171 else if (num_cols == 2) |
|
1172 os << " Columns " << col + 1 << " and " << lim |
|
1173 << ":\n\n"; |
|
1174 else |
|
1175 os << " Columns " << col + 1 << " through " << lim |
|
1176 << ":\n\n"; |
|
1177 } |
|
1178 |
|
1179 for (int i = 0; i < nr; i++) |
|
1180 { |
|
1181 for (int j = col; j < lim; j++) |
|
1182 { |
|
1183 os << " "; |
|
1184 |
|
1185 pr_complex (os, cm.elem (i, j)); |
|
1186 } |
|
1187 os << "\n"; |
|
1188 } |
|
1189 } |
1
|
1190 } |
|
1191 } |
|
1192 } |
|
1193 |
|
1194 void |
626
|
1195 octave_print_internal (ostream& os, const Range& r, |
|
1196 int pr_as_read_syntax) |
1
|
1197 { |
626
|
1198 double base = r.base (); |
1
|
1199 double increment = r.inc (); |
626
|
1200 double limit = r.limit (); |
1
|
1201 int num_elem = r.nelem (); |
|
1202 |
626
|
1203 if (plus_format && ! pr_as_read_syntax) |
1
|
1204 { |
|
1205 os << " "; |
|
1206 for (int i = 0; i < num_elem; i++) |
|
1207 { |
626
|
1208 double val = base + i * increment; |
1
|
1209 if (val == 0.0) |
|
1210 os << " "; |
|
1211 else |
|
1212 os << "+"; |
|
1213 } |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 int fw; |
|
1218 set_format (r, fw); |
|
1219 |
626
|
1220 if (pr_as_read_syntax) |
1
|
1221 { |
626
|
1222 |
|
1223 if (free_format) |
|
1224 { |
|
1225 os << base << " : "; |
|
1226 if (increment != 1.0) |
|
1227 os << increment << " : "; |
|
1228 os << limit; |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 pr_float (os, base, fw); |
|
1233 os << " : "; |
|
1234 if (increment != 1.0) |
|
1235 { |
|
1236 pr_float (os, increment, fw); |
|
1237 os << " : "; |
|
1238 } |
|
1239 pr_float (os, limit, fw); |
|
1240 } |
1
|
1241 } |
626
|
1242 else |
|
1243 { |
|
1244 int column_width = fw + 2; |
|
1245 int total_width = num_elem * column_width; |
|
1246 int max_width = terminal_columns (); |
1
|
1247 |
626
|
1248 if (free_format) |
|
1249 { |
|
1250 os << r; |
|
1251 return; |
|
1252 } |
1
|
1253 |
626
|
1254 int inc = num_elem; |
1
|
1255 if (total_width > max_width && user_pref.split_long_rows) |
|
1256 { |
626
|
1257 inc = max_width / column_width; |
|
1258 if (inc == 0) |
|
1259 inc++; |
1
|
1260 } |
|
1261 |
626
|
1262 int col = 0; |
|
1263 while (col < num_elem) |
1
|
1264 { |
626
|
1265 int lim = col + inc < num_elem ? col + inc : num_elem; |
|
1266 |
|
1267 if (total_width > max_width && user_pref.split_long_rows) |
|
1268 { |
|
1269 if (col != 0) |
|
1270 os << "\n"; |
|
1271 |
|
1272 int num_cols = lim - col; |
|
1273 if (num_cols == 1) |
|
1274 os << " Column " << col + 1 << ":\n\n"; |
|
1275 else if (num_cols == 2) |
|
1276 os << " Columns " << col + 1 << " and " << lim |
|
1277 << ":\n\n"; |
|
1278 else |
|
1279 os << " Columns " << col + 1 << " through " << lim |
|
1280 << ":\n\n"; |
|
1281 } |
|
1282 |
|
1283 for (int i = col; i < lim; i++) |
|
1284 { |
|
1285 double val = base + i * increment; |
|
1286 os << " "; |
|
1287 pr_float (os, val, fw); |
|
1288 } |
|
1289 |
|
1290 os << "\n"; |
|
1291 |
|
1292 col += inc; |
1
|
1293 } |
|
1294 } |
|
1295 } |
|
1296 } |
|
1297 |
712
|
1298 DEFUN ("disp", Fdisp, Sdisp, 1, 1, |
529
|
1299 "disp (X): display value without name tag") |
|
1300 { |
|
1301 Octave_object retval; |
|
1302 |
|
1303 int nargin = args.length (); |
|
1304 |
712
|
1305 if (nargin == 1) |
|
1306 args(0).eval (1); |
529
|
1307 else |
|
1308 print_usage ("disp"); |
|
1309 |
|
1310 return retval; |
|
1311 } |
|
1312 |
1
|
1313 static void |
|
1314 init_format_state (void) |
|
1315 { |
|
1316 free_format = 0; |
|
1317 plus_format = 0; |
|
1318 bank_format = 0; |
|
1319 print_e = 0; |
|
1320 print_big_e = 0; |
|
1321 } |
|
1322 |
|
1323 static void |
|
1324 set_output_prec_and_fw (int prec, int fw) |
|
1325 { |
529
|
1326 tree_constant *tmp = 0; |
1
|
1327 |
|
1328 tmp = new tree_constant ((double) prec); |
195
|
1329 bind_builtin_variable ("output_precision", tmp); |
1
|
1330 |
|
1331 tmp = new tree_constant ((double) fw); |
195
|
1332 bind_builtin_variable ("output_max_field_width", tmp); |
1
|
1333 } |
|
1334 |
|
1335 void |
|
1336 set_format_style (int argc, char **argv) |
|
1337 { |
|
1338 if (--argc > 0) |
|
1339 { |
|
1340 argv++; |
|
1341 if (*argv[0]) |
|
1342 { |
|
1343 if (strcmp (*argv, "short") == 0) |
|
1344 { |
|
1345 if (--argc > 0) |
|
1346 { |
|
1347 argv++; |
|
1348 if (strcmp (*argv, "e") == 0) |
|
1349 { |
|
1350 init_format_state (); |
|
1351 print_e = 1; |
|
1352 } |
|
1353 else if (strcmp (*argv, "E") == 0) |
|
1354 { |
|
1355 init_format_state (); |
|
1356 print_e = 1; |
|
1357 print_big_e = 1; |
|
1358 } |
|
1359 else |
|
1360 { |
217
|
1361 error ("format: unrecognized option `short %s'", *argv); |
1
|
1362 return; |
|
1363 } |
|
1364 } |
|
1365 else |
|
1366 init_format_state (); |
|
1367 |
|
1368 set_output_prec_and_fw (3, 8); |
|
1369 } |
|
1370 else if (strcmp (*argv, "long") == 0) |
|
1371 { |
|
1372 if (--argc > 0) |
|
1373 { |
|
1374 argv++; |
|
1375 if (strcmp (*argv, "e") == 0) |
|
1376 { |
|
1377 init_format_state (); |
|
1378 print_e = 1; |
|
1379 } |
|
1380 else if (strcmp (*argv, "E") == 0) |
|
1381 { |
|
1382 init_format_state (); |
|
1383 print_e = 1; |
|
1384 print_big_e = 1; |
|
1385 } |
|
1386 else |
|
1387 { |
217
|
1388 error ("format: unrecognized option `long %s'", *argv); |
1
|
1389 return; |
|
1390 } |
|
1391 } |
|
1392 else |
|
1393 init_format_state (); |
|
1394 |
|
1395 set_output_prec_and_fw (15, 24); |
|
1396 } |
|
1397 else if (strcmp (*argv, "hex") == 0) |
217
|
1398 error ("format: format state `hex' not implemented yet"); |
1
|
1399 else if (strcmp (*argv, "+") == 0) |
|
1400 { |
|
1401 init_format_state (); |
|
1402 plus_format = 1; |
|
1403 } |
|
1404 else if (strcmp (*argv, "bank") == 0) |
|
1405 { |
|
1406 init_format_state (); |
|
1407 bank_format = 1; |
|
1408 } |
|
1409 else if (strcmp (*argv, "free") == 0) |
|
1410 { |
|
1411 init_format_state (); |
|
1412 free_format = 1; |
|
1413 } |
|
1414 else if (strcmp (*argv, "none") == 0) |
|
1415 { |
|
1416 init_format_state (); |
|
1417 free_format = 1; |
|
1418 } |
|
1419 else if (strcmp (*argv, "compact") == 0) |
217
|
1420 error ("format: format state `compact' not implemented yet"); |
1
|
1421 else if (strcmp (*argv, "loose") == 0) |
217
|
1422 error ("format: format state `loose' not implemented yet"); |
1
|
1423 else |
217
|
1424 error ("format: unrecognized format state `%s'", *argv); |
1
|
1425 } |
|
1426 else |
|
1427 usage ("format [format_state]"); |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 init_format_state (); |
|
1432 set_output_prec_and_fw (5, 10); |
|
1433 } |
|
1434 } |
|
1435 |
529
|
1436 DEFUN_TEXT ("format", Fformat, Sformat, -1, 1, |
|
1437 "format [style]\n\ |
|
1438 \n\ |
|
1439 set output formatting style") |
|
1440 { |
|
1441 Octave_object retval; |
|
1442 |
|
1443 DEFINE_ARGV("format"); |
|
1444 |
|
1445 set_format_style (argc, argv); |
|
1446 |
|
1447 DELETE_ARGV; |
|
1448 |
|
1449 return retval; |
|
1450 } |
|
1451 |
1
|
1452 /* |
|
1453 ;;; Local Variables: *** |
|
1454 ;;; mode: C++ *** |
|
1455 ;;; page-delimiter: "^/\\*" *** |
|
1456 ;;; End: *** |
|
1457 */ |