vnl_matlab_print_format.cxx
Go to the documentation of this file.
1 // This is core/vnl/vnl_matlab_print_format.cxx
2 #include <iostream>
3 #include <vector>
5 //:
6 // \file
7 
8 //: Choose precision in printouts.
9 //
10 // vnl_matlab_format(vnl_matops::fmt_long) selects 16-digit precision
11 //
12 // vnl_matlab_format(vnl_matops::fmt_short) selects 4-digit precision
13 
14 //: this variable is the current top of the stack.
16 //: the rest of the stack is stored in this vector.
17 static std::vector<int> *format_stack = nullptr;
18 //: call this to initialize the format stack.
19 static void vnl_matlab_print_format_init()
20 { if (!format_stack) format_stack = new std::vector<int>; }
21 
23 {
24  vnl_matlab_print_format_init();
25  format_stack->push_back(the_format);
26  the_format = f;
27 }
28 
30 {
31  vnl_matlab_print_format_init();
32  if (format_stack->empty())
33  std::cerr << __FILE__ ": format stack empty\n";
34  else {
35  the_format = vnl_matlab_print_format(format_stack->back());
36  format_stack->pop_back();
37  }
38 }
39 
41 {
42  vnl_matlab_print_format_init();
43  vnl_matlab_print_format old = the_format;
44  the_format = f;
45  return old;
46 }
47 
49 {
50  return the_format;
51 }
void vnl_matlab_print_format_pop()
vnl_matlab_print_format vnl_matlab_print_format_set(vnl_matlab_print_format f)
set new, get old format at top of stack :.
vnl_matlab_print_format
pretty-printing matlab formats.
void vnl_matlab_print_format_push(vnl_matlab_print_format f)
push/pop the top of the stack :.
vnl_matlab_print_format vnl_matlab_print_format_top()
get top of stack :.