save.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_CORE_DATA_SAVE_HPP
15 #define MLPACK_CORE_DATA_SAVE_HPP
16 
17 #include <mlpack/core/util/log.hpp>
18 #include <mlpack/core/arma_extend/arma_extend.hpp> // Includes Armadillo.
19 #include <string>
20 
21 #include "format.hpp"
22 #include "image_info.hpp"
23 #include "detect_file_type.hpp"
24 
25 namespace mlpack {
26 namespace data {
27 
63 template<typename eT>
64 bool Save(const std::string& filename,
65  const arma::Mat<eT>& matrix,
66  const bool fatal = false,
67  bool transpose = true,
68  FileType inputSaveType = FileType::AutoDetect);
69 
95 template<typename eT>
96 bool Save(const std::string& filename,
97  const arma::SpMat<eT>& matrix,
98  const bool fatal = false,
99  bool transpose = true);
100 
126 template<typename T>
127 bool Save(const std::string& filename,
128  const std::string& name,
129  T& t,
130  const bool fatal = false,
132 
142 template<typename eT>
143 bool Save(const std::string& filename,
144  arma::Mat<eT>& matrix,
145  ImageInfo& info,
146  const bool fatal = false);
147 
157 template<typename eT>
158 bool Save(const std::vector<std::string>& files,
159  arma::Mat<eT>& matrix,
160  ImageInfo& info,
161  const bool fatal = false);
162 
166 bool SaveImage(const std::string& filename,
167  arma::Mat<unsigned char>& image,
168  ImageInfo& info,
169  const bool fatal = false);
170 
171 } // namespace data
172 } // namespace mlpack
173 
174 // Include implementation.
175 #include "save_impl.hpp"
176 
177 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
bool SaveImage(const std::string &filename, arma::Mat< unsigned char > &image, ImageInfo &info, const bool fatal=false)
Helper function to save files.
format
Define the formats we can read through cereal.
Definition: format.hpp:20
constexpr auto data(Container const &container) noexcept -> decltype(container.data())
Definition: iterator.hpp:79
attempt to automatically detect the file type
bool Save(const std::string &filename, const arma::Mat< eT > &matrix, const bool fatal=false, bool transpose=true, FileType inputSaveType=FileType::AutoDetect)
Saves a matrix to file, guessing the filetype from the extension.