13 #ifndef MLPACK_UTIL_SIZE_CHECKS_HPP 14 #define MLPACK_UTIL_SIZE_CHECKS_HPP 30 template<
typename DataType,
typename LabelsType>
32 const LabelsType& label,
33 const std::string& callerDescription,
34 const std::string& addInfo =
"labels")
36 if (data.n_cols != label.n_cols)
38 std::ostringstream oss;
39 oss << callerDescription <<
": number of points (" << data.n_cols <<
") " 40 <<
"does not match number of " << addInfo <<
" (" << label.n_cols
42 throw std::invalid_argument(oss.str());
50 template<
typename DataType>
53 const std::string& callerDescription,
54 const std::string& addInfo =
"labels")
56 if (data.n_cols != size)
58 std::ostringstream oss;
59 oss << callerDescription <<
": number of points (" << data.n_cols <<
") " 60 <<
"does not match number of " << addInfo <<
" (" << size <<
")!" 62 throw std::invalid_argument(oss.str());
77 template<
typename DataType,
typename DimType>
79 const DimType& dimension,
80 const std::string& callerDescription,
81 const std::string& addInfo =
"dataset")
83 if (data.n_rows != dimension.n_rows)
85 std::ostringstream oss;
86 oss << callerDescription <<
": dimensionality of " << addInfo <<
" (" 87 << data.n_rows <<
") is not equal to the dimensionality of the model" 88 " (" << dimension.n_rows <<
")!";
90 throw std::invalid_argument(oss.str());
98 template<
typename DataType>
100 const size_t& dimension,
101 const std::string& callerDescription,
102 const std::string& addInfo =
"dataset")
104 if (data.n_rows != dimension)
106 std::ostringstream oss;
107 oss << callerDescription <<
": dimensionality of " << addInfo <<
" (" 108 << data.n_rows <<
") is not equal to the dimensionality of the model" 109 " (" << dimension <<
")!";
110 throw std::invalid_argument(oss.str());
Linear algebra utility functions, generally performed on matrices or vectors.
void CheckSameSizes(const DataType &data, const LabelsType &label, const std::string &callerDescription, const std::string &addInfo="labels")
Check for if the given data points & labels have same size.
void CheckSameDimensionality(const DataType &data, const DimType &dimension, const std::string &callerDescription, const std::string &addInfo="dataset")
Check for if the given dataset dimension matches with the model's.