Skip to content
Snippets Groups Projects
Commit 70501397 authored by Rohan Budhiraja's avatar Rohan Budhiraja
Browse files

[wip/dynamic-graph3][PATCH] fix bug in matrix istream input operator

parent 6d0c4067
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
PKG_NAME= dynamic-graph
VERSION= 3.0.0
DISTNAME= ${PKG_NAME}-${VERSION}
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= wip
MASTER_SITES= ${MASTER_SITE_OPENROBOTS:=dynamic-graph/}
......
......@@ -3,3 +3,4 @@ RMD160 (dynamic-graph-3.0.0.tar.gz) = e2f50ba8e06003d264fd9e61afef9248c7df4dea
Size (dynamic-graph-3.0.0.tar.gz) = 429940 bytes
SHA1 (patch-aa) = d8d3aa22eea6c004d8bce7fbbe3c54c376463303
SHA1 (patch-ab) = f162e6527d43a57adb10700242997838c0446cc9
SHA1 (patch-ac) = 302875035b9e3ed3b82593bc4903c46b831b4bb8
[c++] fix bug in matrix istream input operator
diff --git include/dynamic-graph/eigen-io.h include/dynamic-graph/eigen-io.h
index 89d8f33..6352cb5 100644
--- include/dynamic-graph/eigen-io.h
+++ include/dynamic-graph/eigen-io.h
@@ -39,6 +39,7 @@ using dynamicgraph::ExceptionSignal;
*/
namespace Eigen {
typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE eigen_index;
+
inline std::istringstream& operator >> (std::istringstream &iss,
dynamicgraph::Vector &inst) {
unsigned int _size;
@@ -88,7 +89,8 @@ namespace Eigen {
unsigned int _rowsize;
double _dbl_val;
char _ch;
- boost::format fmt ("Failed to enter %s as vector. Reenter as [N](val1,val2,val3,...,valN)");
+ boost::format fmt ("Failed to enter %s as matrix. Reenter as ((val11,val12,val13,...,val1N),...,(valM1,valM2,...,valMN))");
+ MatrixXd _tmp_matrix;
fmt %iss.str();
if(iss>> _ch && _ch != '['){
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
@@ -101,7 +103,7 @@ namespace Eigen {
if (iss.fail())
throw ExceptionSignal(ExceptionSignal::GENERIC,fmt.str());
else {
- inst.resize(_rowsize,_colsize);
+ _tmp_matrix.resize(_rowsize,_colsize);
if(iss >> _ch && _ch != ']')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
else {
@@ -115,7 +117,7 @@ namespace Eigen {
iss >> _dbl_val;
if (iss.peek() == ',' || iss.peek() == ' ')
iss.ignore();
- inst(j,i) = _dbl_val;
+ _tmp_matrix(j,i) = _dbl_val;
}
if(iss >> _ch && _ch != ')')
throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str());
@@ -128,13 +130,14 @@ namespace Eigen {
}
}
}
+ inst = _tmp_matrix;
return iss;
}
inline std::istringstream& operator >> (std::istringstream &iss,
Transform<double,3,Affine> &inst) {
- Matrix4d M; iss >> M; inst = M; return iss; }
+ MatrixXd M; iss >> M; inst.matrix() = M; return iss; }
@@ -157,12 +160,12 @@ namespace Eigen {
inline std::ostream& operator << (std::ostream &os,
AngleAxisd quat) {
- Vector4d v; v(0) = quat.angle(); v.tail<3>() = quat.axis();
+ VectorXd v(4); v(0) = quat.angle(); v.tail<3>() = quat.axis();
os << v; return os; }
inline std::istringstream& operator >> (std::istringstream &iss,
AngleAxisd &inst) {
- Vector4d v; iss >>v;
+ VectorXd v(4); iss >>v;
inst.angle() = v(0); inst.axis() = v.tail<3>();
return iss; }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment