27 #include <Eigen/Geometry>
29 #include <SimoxUtility/algorithm/string/string_tools.h>
46 this->
data.resize(rows * cols);
51 this->rows = m.rows();
52 this->cols = m.cols();
54 data = std::vector<float>(rows * cols);
56 for (
int col = 0; col < cols; col++)
58 for (
int row = 0; row < rows; row++)
60 data[i] = m(row, col);
84 Eigen::MatrixXf m(rows, cols);
86 for (
int col = 0; col < cols; col++)
88 for (
int row = 0; row < rows; row++)
90 m(row, col) =
data[i];
107 return data.at(row + col * rows);
113 std::stringstream stream;
116 for (
int row = 0; row < rows; row++)
118 stream << (row > 0 ?
", [" :
"[");
120 for (
int col = 0; col < cols; col++)
122 stream << (col > 0 ?
", " :
"");
123 stream << (*this)(row, col);
137 obj->setInt(
"rows", rows);
138 obj->setInt(
"cols", cols);
139 Ice::StringSeq rowContent;
142 for (
int row = 0; row < rows; row++)
144 std::stringstream ss;
146 for (
int col = 0; col < cols; col++)
148 ss << m(row, col) << (col < cols - 1 ?
"," :
"");
151 rowContent.push_back(ss.str());
154 obj->setStringArray(
"rowContent", rowContent);
161 rows = obj->getInt(
"rows");
162 cols = obj->getInt(
"cols");
163 Ice::StringSeq rowContent;
164 obj->getStringArray(
"rowContent", rowContent);
166 if ((
int)rowContent.size() != rows)
168 throw LocalException(
"unexcepted row count: ")
169 << rowContent.size() <<
", but expected " << rows;
172 data.resize(rows * cols);
174 for (
size_t row = 0; row < rowContent.size(); row++)
179 if ((
int)
values.size() != cols)
181 throw LocalException(
"unexcepted column count: ")
182 <<
values.size() <<
", but expected " << cols;
187 data.at(col * rows + row) = atof(
v.c_str());
203 this->
data.resize(rows * cols);
208 this->rows = m.rows();
209 this->cols = m.cols();
211 data = std::vector<double>(rows * cols);
213 for (
int col = 0; col < cols; col++)
215 for (
int row = 0; row < rows; row++)
217 data[i] = m(row, col);
227 this->
data = entries;
241 Eigen::MatrixXd m(rows, cols);
243 for (
int col = 0; col < cols; col++)
245 for (
int row = 0; row < rows; row++)
247 m(row, col) =
data[i];
258 return data.at(row + col * rows);
264 std::stringstream stream;
267 for (
int row = 0; row < rows; row++)
269 stream << (row > 0 ?
", [" :
"[");
271 for (
int col = 0; col < cols; col++)
273 stream << (col > 0 ?
", " :
"");
274 stream << (*this)(row, col);
288 obj->setInt(
"rows", rows);
289 obj->setInt(
"cols", cols);
290 Ice::StringSeq rowContent;
293 for (
int row = 0; row < rows; row++)
295 std::stringstream ss;
297 for (
int col = 0; col < cols; col++)
299 ss << m(row, col) << (col < cols - 1 ?
"," :
"");
302 rowContent.push_back(ss.str());
305 obj->setStringArray(
"rowContent", rowContent);
312 rows = obj->getInt(
"rows");
313 cols = obj->getInt(
"cols");
314 Ice::StringSeq rowContent;
315 obj->getStringArray(
"rowContent", rowContent);
317 if ((
int)rowContent.size() != rows)
319 throw LocalException(
"unexcepted row count: ")
320 << rowContent.size() <<
", but expected " << rows;
323 data.resize(rows * cols);
325 for (
size_t row = 0; row < rowContent.size(); row++)
330 if ((
int)
values.size() != cols)
332 throw LocalException(
"unexcepted column count: ")
333 <<
values.size() <<
", but expected " << cols;
338 data.at(col * rows + row) = atof(
v.c_str());