33 BOOST_FOREACH(
double value, vec)
35 str += boost::lexical_cast<std::string>(value) + std::string(
" ");
45 str.erase(str.find_last_not_of(
" \n\r\t") + 1);
48 std::vector<std::string> valuesAsSubstrings;
49 boost::split(valuesAsSubstrings, str, boost::is_any_of(
" "));
52 for(
unsigned int i = 0; i < valuesAsSubstrings.size(); i++)
54 vec.push_back(boost::lexical_cast<double>(valuesAsSubstrings[i]));
64 for(
int i = 0; i < vec->size(); i++)
65 str += boost::lexical_cast<std::string>((*vec)(i)) + std::string(
" ");
71 str.erase(str.find_last_not_of(
" \n\r\t") + 1);
74 std::vector<std::string> valuesAsSubstrings;
75 boost::split(valuesAsSubstrings, str, boost::is_any_of(
" "));
78 if(valuesAsSubstrings.size() != size)
79 throw std::invalid_argument(
"Error in serialization helper. Bad number of substrings.");
82 vec.reset(
new Eigen::VectorXd(size));
85 for(
unsigned int i = 0; i < size; i++)
86 (*vec)(i) = boost::lexical_cast<double>(valuesAsSubstrings[i]);
95 for(
int y = 0;
y < mat->rows();
y++)
96 for(
int x = 0;
x < mat->cols();
x++)
97 str += boost::lexical_cast<std::string>((*mat)(
y,
x)) + std::string(
" ");
103 str.erase(str.find_last_not_of(
" \n\r\t") + 1);
106 std::vector<std::string> valuesAsSubstrings;
107 boost::split(valuesAsSubstrings, str, boost::is_any_of(
" "));
110 if(valuesAsSubstrings.size() != pow(size, 2))
111 throw std::invalid_argument(
"Error in serialization helper. Bad number of substrings.");
114 mat.reset(
new Eigen::MatrixXd(size, size));
117 for(
unsigned int y = 0;
y < size;
y++)
118 for(
unsigned int x = 0;
x < size;
x++)
119 (*mat)(
y,
x) = boost::lexical_cast<double>(valuesAsSubstrings[
y * size +
x]);
static void convertMatrixToString(boost::shared_ptr< Eigen::MatrixXd > &mat, std::string &str)
static void convertStringToVector(std::string &str, std::vector< double > &vec)
static void convertVectorToString(std::vector< double > &vec, std::string &str)
TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE const tfScalar & x() const
static void convertStringToMatrix(unsigned int size, std::string &str, boost::shared_ptr< Eigen::MatrixXd > &mat)