vnl_matlab_filewrite.h
Go to the documentation of this file.
1 // This is core/vnl/vnl_matlab_filewrite.h
2 #ifndef vnl_matlab_filewrite_h_
3 #define vnl_matlab_filewrite_h_
4 //:
5 // \file
6 // \author David Capel, Oxford RRG
7 // \date 17 August 1998
8 //
9 // \verbatim
10 // Modifications
11 // LSB (Manchester) 23/3/01 Tidied documentation
12 // Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
13 // \endverbatim
14 
15 #include <string>
16 #include <fstream>
17 #include <complex>
18 #ifdef _MSC_VER
19 # include <vcl_msvc_warnings.h>
20 #endif
21 
22 #include <vnl/vnl_vector.h>
23 #include <vnl/vnl_matrix.h>
24 #include "vnl/vnl_export.h"
25 
26 //: Code to perform MATLAB binary file operations
27 // vnl_matlab_filewrite is a collection of I/O functions for reading/writing
28 // matrices in the compact MATLAB binary format (.mat)
29 
30 class VNL_EXPORT vnl_matlab_filewrite
31 {
32  public:
33  vnl_matlab_filewrite (char const* file_name, char const *basename = nullptr);
34 
35  //: Add scalar/vector/matrix variable to the MAT file using specified variable name.
36  // If no name is given, variables will be generated by
37  // appending 0,1,2 etc to the given basename.
38  void write(double v, char const* variable_name = nullptr);
39 
40  void write(vnl_vector<double> const & v, char const* variable_name = nullptr);
41  void write(vnl_vector<std::complex<double> > const & v, char const* variable_name = nullptr);
42 
43  void write(vnl_matrix<float> const & M, char const* variable_name = nullptr);
44  void write(vnl_matrix<double> const & M, char const* variable_name = nullptr);
45  void write(vnl_matrix<std::complex<float> > const & M, char const* variable_name = nullptr);
46  void write(vnl_matrix<std::complex<double> > const & M, char const* variable_name = nullptr);
47 
48  void write(double const * const *M, int rows, int cols, char const* variable_name = nullptr);
49 
50  protected:
51  std::string basename_;
53  std::fstream out_;
54 
55  std::string make_var_name(char const* variable_name);
56 };
57 
58 #endif // vnl_matlab_filewrite_h_
An ordinary mathematical matrix.
Code to perform MATLAB binary file operations.
#define v
Definition: vnl_vector.h:42
An ordinary mathematical matrix.
Definition: vnl_adjugate.h:22