core/vnl/vnl_matlab_print.h
Go to the documentation of this file.
00001 // This is core/vnl/vnl_matlab_print.h
00002 #ifndef vnl_matlab_print_h_
00003 #define vnl_matlab_print_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 //  \file
00009 //  \brief Print matrices and vectors in nice MATLAB format.
00010 //  \author fsm, from awf's MatOps code.
00011 
00012 #include <vcl_iosfwd.h>
00013 #include <vnl/vnl_fwd.h>
00014 
00015 #include <vnl/vnl_matlab_print_format.h>
00016 
00017 // If a variable name (e.g. "foo") is given, the raw data will be preceded by
00018 //   "foo = diag([ " for a vnl_diag_matrix
00019 //   "foo = [ ...\n" for a vnl_matrix and
00020 //   "foo = [ "      for a vnl_vector
00021 // and followed by "])\n", "]\n" and "]\n" respectively. If the variable name
00022 // is a null pointer, the data is printed as is.
00023 
00024 //-------------------- "unnamed" forms.
00025 
00026 //: print a 1D array.
00027 template <class T>
00028 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00029                               T const *array,
00030                               unsigned length,
00031                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00032 
00033 //: print a 2D array.
00034 template <class T>
00035 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00036                               T const * const *array,
00037                               unsigned rows, unsigned cols,
00038                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00039 
00040 //-------------------- "named" forms.
00041 
00042 //: print a vnl_diagonal_matrix<T>.
00043 //  \relatesalso vnl_diag_matrix
00044 template <class T>
00045 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00046                               vnl_diag_matrix<T> const&,
00047                               char const *variable_name =0,
00048                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00049 
00050 //: print a vnl_matrix<T>.
00051 //  \relatesalso vnl_matrix
00052 template <class T>
00053 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00054                               vnl_matrix<T> const&,
00055                               char const *variable_name =0,
00056                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00057 
00058 //: print a vnl_matrix_fixed<T>.
00059 //  \relatesalso vnl_matrix_fixed
00060 template <class T, unsigned int n, unsigned int m>
00061 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00062                               vnl_matrix_fixed<T,n,m> const&,
00063                               char const *variable_name =0,
00064                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00065 
00066 //: print a vnl_matrix_ref<T>.
00067 //  \relatesalso vnl_matrix_ref
00068 template <class T>
00069 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00070                               vnl_matrix_ref<T> const &,
00071                               char const *variable_name =0,
00072                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00073 
00074 //: print a vnl_vector<T>.
00075 //  \relatesalso vnl_vector
00076 template <class T>
00077 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00078                               vnl_vector<T> const &,
00079                               char const *variable_name =0,
00080                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00081 
00082 //: print a vnl_vector_fixed<T>.
00083 //  \relatesalso vnl_vector_fixed
00084 template <class T, unsigned int n>
00085 vcl_ostream &vnl_matlab_print(vcl_ostream &,
00086                               vnl_vector_fixed<T,n> const &,
00087                               char const *variable_name =0,
00088                               vnl_matlab_print_format =vnl_matlab_print_format_default);
00089 
00090 
00091 //: naughty naming-convention-defying-but-handy macro.
00092 #define MATLABPRINT(X) (vnl_matlab_print(vcl_cerr, (X).as_ref(), #X))
00093 
00094 #endif // vnl_matlab_print_h_