10 #include <boost/property_tree/ptree.hpp> 11 #include <boost/property_tree/info_parser.hpp> 30 template <
typename SCALAR>
31 void loadScalar(
const std::string& filename,
const std::string& scalarName,
SCALAR& scalar,
const std::string& ns =
"")
33 boost::property_tree::ptree pt;
34 boost::property_tree::read_info(filename, pt);
36 scalar = pt.get<
SCALAR>(ns + scalarName);
50 template <
typename SCALAR>
52 const std::string& scalarName,
54 const SCALAR& defaultValue,
55 const std::string& ns =
"")
57 boost::property_tree::ptree pt;
58 boost::property_tree::read_info(filename, pt);
60 scalar = pt.get<
SCALAR>(ns + scalarName, defaultValue);
110 template <
typename SCALAR,
int ROW,
int COL>
112 const std::string& matrixName,
113 Eigen::Matrix<SCALAR, ROW, COL>& matrix,
114 const std::string& ns =
"")
116 size_t rows = matrix.rows();
117 size_t cols = matrix.cols();
119 boost::property_tree::ptree pt;
120 boost::property_tree::read_info(filename, pt);
122 double scaling = pt.get<
double>(ns + matrixName +
".scaling", 1);
124 for (
size_t i = 0;
i < rows;
i++)
126 for (
size_t j = 0; j < cols; j++)
130 pt.get<
double>(ns + matrixName +
"." +
"(" + std::to_string(
i) +
"," + std::to_string(j) +
")", 0.0);
void loadMatrix(const std::string &filename, const std::string &matrixName, Eigen::Matrix< SCALAR, ROW, COL > &matrix, const std::string &ns="")
Loads a matrix/vector file from an .info file.
Definition: InfoFileParser.h:111
void loadScalar(const std::string &filename, const std::string &scalarName, SCALAR &scalar, const std::string &ns="")
Loads a scalar file from an .info file.
Definition: InfoFileParser.h:31
CppAD::AD< CppAD::cg::CG< double > > SCALAR
void loadScalarOptional(const std::string &filename, const std::string &scalarName, SCALAR &scalar, const SCALAR &defaultValue, const std::string &ns="")
Tries to load a scalar from an .info file. Falls back to default value if not found.
Definition: InfoFileParser.h:51