vnl_matlab_print.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_matlab_print.h
2 #ifndef vnl_matlab_print_h_
3 #define vnl_matlab_print_h_
4 //:
5 // \file
6 // \brief Print matrices and vectors in nice MATLAB format.
7 // \author fsm, from awf's MatOps code.
8 
9 #include <iosfwd>
10 #ifdef _MSC_VER
11 # include <vcl_msvc_warnings.h>
12 #endif
13 #include <vnl/vnl_fwd.h>
14 
16 #include "vnl/vnl_export.h"
17 
18 // If a variable name (e.g. "foo") is given, the raw data will be preceded by
19 // "foo = diag([ " for a vnl_diag_matrix
20 // "foo = [ ...\n" for a vnl_matrix and
21 // "foo = [ " for a vnl_vector
22 // and followed by "])\n", "]\n" and "]\n" respectively. If the variable name
23 // is a null pointer, the data is printed as is.
24 
25 //-------------------- "unnamed" forms.
26 
27 //: print a 1D array.
28 template <class T> VNL_EXPORT
29 std::ostream &vnl_matlab_print(std::ostream &,
30  T const *array,
31  unsigned length,
33 
34 //: print a 2D array.
35 template <class T> VNL_EXPORT
36 std::ostream &vnl_matlab_print(std::ostream &,
37  T const * const *array,
38  unsigned rows, unsigned cols,
40 
41 //-------------------- "named" forms.
42 
43 //: print a vnl_diagonal_matrix<T>.
44 // \relatesalso vnl_diag_matrix
45 template <class T> VNL_EXPORT
46 std::ostream &vnl_matlab_print(std::ostream &,
47  vnl_diag_matrix<T> const&,
48  char const *variable_name =nullptr,
50 
51 //: print a vnl_matrix<T>.
52 // \relatesalso vnl_matrix
53 template <class T> VNL_EXPORT
54 std::ostream &vnl_matlab_print(std::ostream &,
55  vnl_matrix<T> const&,
56  char const *variable_name =nullptr,
58 
59 //: print a vnl_matrix_fixed<T>.
60 // \relatesalso vnl_matrix_fixed
61 template <class T, unsigned int n, unsigned int m> VNL_EXPORT
62 std::ostream &vnl_matlab_print(std::ostream &,
64  char const *variable_name =nullptr,
66 
67 //: print a vnl_matrix_ref<T>.
68 // \relatesalso vnl_matrix_ref
69 template <class T> VNL_EXPORT
70 std::ostream &vnl_matlab_print(std::ostream &,
71  vnl_matrix_ref<T> const &,
72  char const *variable_name =nullptr,
74 
75 //: print a vnl_vector<T>.
76 // \relatesalso vnl_vector
77 template <class T> VNL_EXPORT
78 std::ostream &vnl_matlab_print(std::ostream &,
79  vnl_vector<T> const &,
80  char const *variable_name =nullptr,
82 
83 //: print a vnl_vector_fixed<T>.
84 // \relatesalso vnl_vector_fixed
85 template <class T, unsigned int n> VNL_EXPORT
86 std::ostream &vnl_matlab_print(std::ostream &,
87  vnl_vector_fixed<T,n> const &,
88  char const *variable_name =nullptr,
90 
91 
92 //: naughty naming-convention-defying-but-handy macro.
93 #define MATLABPRINT(X) (vnl_matlab_print(std::cerr, (X).as_ref(), #X))
94 
95 #endif // vnl_matlab_print_h_
VNL_EXPORT std::ostream & vnl_matlab_print(std::ostream &, vnl_diag_matrix< T > const &, char const *variable_name=nullptr, vnl_matlab_print_format=vnl_matlab_print_format_default)
print a vnl_diagonal_matrix<T>.
Fixed size, stack-stored, space-efficient matrix.
Definition: vnl_fwd.h:23
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22
vnl_matlab_print_format
pretty-printing matlab formats.
Mathematical vector class, templated by type of element.
Definition: vnl_fwd.h:16
Fixed length stack-stored, space-efficient vector.
Definition: vnl_fwd.h:22
stores a diagonal matrix as a single vector.
vnl_matrix reference to user-supplied storage.
Definition: vnl_fwd.h:20