30 #include <SimoxUtility/algorithm/string/string_tools.h>
32 #include <Eigen/Geometry>
47 this->
data.resize(rows * cols);
52 this->rows = m.rows();
53 this->cols = m.cols();
55 data = std::vector<float>(rows * cols);
57 for (
int col = 0; col < cols; col++)
59 for (
int row = 0; row < rows; row++)
61 data[i] = m(row, col);
85 Eigen::MatrixXf m(rows, cols);
87 for (
int col = 0; col < cols; col++)
89 for (
int row = 0; row < rows; row++)
91 m(row, col) =
data[i];
106 return data.at(row + col * rows);
111 std::stringstream stream;
114 for (
int row = 0; row < rows; row++)
116 stream << (row > 0 ?
", [" :
"[");
118 for (
int col = 0; col < cols; col++)
120 stream << (col > 0 ?
", " :
"");
121 stream << (*this)(row, col);
135 obj->setInt(
"rows", rows);
136 obj->setInt(
"cols", cols);
137 Ice::StringSeq rowContent;
140 for (
int row = 0; row < rows; row++)
142 std::stringstream ss;
144 for (
int col = 0; col < cols; col++)
146 ss << m(row, col) << (col < cols - 1 ?
"," :
"");
149 rowContent.push_back(ss.str());
152 obj->setStringArray(
"rowContent", rowContent);
158 rows = obj->getInt(
"rows");
159 cols = obj->getInt(
"cols");
160 Ice::StringSeq rowContent;
161 obj->getStringArray(
"rowContent", rowContent);
163 if ((
int)rowContent.size() != rows)
165 throw LocalException(
"unexcepted row count: ") << rowContent.size() <<
", but expected " << rows;
168 data.resize(rows * cols);
170 for (
size_t row = 0; row < rowContent.size(); row++)
175 if ((
int)
values.size() != cols)
177 throw LocalException(
"unexcepted column count: ") <<
values.size() <<
", but expected " << cols;
182 data.at(col * rows + row) = atof(
v.c_str());
202 this->
data.resize(rows * cols);
207 this->rows = m.rows();
208 this->cols = m.cols();
210 data = std::vector<double>(rows * cols);
212 for (
int col = 0; col < cols; col++)
214 for (
int row = 0; row < rows; row++)
216 data[i] = m(row, col);
227 this->
data = entries;
240 Eigen::MatrixXd m(rows, cols);
242 for (
int col = 0; col < cols; col++)
244 for (
int row = 0; row < rows; row++)
246 m(row, col) =
data[i];
256 return data.at(row + col * rows);
261 std::stringstream stream;
264 for (
int row = 0; row < rows; row++)
266 stream << (row > 0 ?
", [" :
"[");
268 for (
int col = 0; col < cols; col++)
270 stream << (col > 0 ?
", " :
"");
271 stream << (*this)(row, col);
285 obj->setInt(
"rows", rows);
286 obj->setInt(
"cols", cols);
287 Ice::StringSeq rowContent;
290 for (
int row = 0; row < rows; row++)
292 std::stringstream ss;
294 for (
int col = 0; col < cols; col++)
296 ss << m(row, col) << (col < cols - 1 ?
"," :
"");
299 rowContent.push_back(ss.str());
302 obj->setStringArray(
"rowContent", rowContent);
308 rows = obj->getInt(
"rows");
309 cols = obj->getInt(
"cols");
310 Ice::StringSeq rowContent;
311 obj->getStringArray(
"rowContent", rowContent);
313 if ((
int)rowContent.size() != rows)
315 throw LocalException(
"unexcepted row count: ") << rowContent.size() <<
", but expected " << rows;
318 data.resize(rows * cols);
320 for (
size_t row = 0; row < rowContent.size(); row++)
325 if ((
int)
values.size() != cols)
327 throw LocalException(
"unexcepted column count: ") <<
values.size() <<
", but expected " << cols;
332 data.at(col * rows + row) = atof(
v.c_str());