moved matlab-style matrix format definition back to cpp, updated all formatters
parent
d3ac33ac18
commit
d7522ab970
|
@ -136,10 +136,24 @@ Vector operator^(const Matrix& A, const Vector & v) {
|
||||||
return A.transpose() * v;
|
return A.transpose() * v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Eigen::IOFormat& matlabFormat() {
|
||||||
|
static const Eigen::IOFormat matlab(
|
||||||
|
Eigen::StreamPrecision, // precision
|
||||||
|
Eigen::DontAlignCols, // flags set such that rowSpacers are not added
|
||||||
|
", ", // coeffSeparator
|
||||||
|
";\n", // rowSeparator
|
||||||
|
"\t", // rowPrefix
|
||||||
|
"", // rowSuffix
|
||||||
|
"[\n", // matPrefix
|
||||||
|
"\n]" // matSuffix
|
||||||
|
);
|
||||||
|
return matlab;
|
||||||
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
//3 argument call
|
//3 argument call
|
||||||
void print(const Matrix& A, const string &s, ostream& stream) {
|
void print(const Matrix& A, const string &s, ostream& stream) {
|
||||||
cout << s << A.format(matlab) << endl;
|
cout << s << A.format(matlabFormat()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
|
@ -76,17 +76,9 @@ GTSAM_MAKE_MATRIX_DEFS(9);
|
||||||
typedef Eigen::Block<Matrix> SubMatrix;
|
typedef Eigen::Block<Matrix> SubMatrix;
|
||||||
typedef Eigen::Block<const Matrix> ConstSubMatrix;
|
typedef Eigen::Block<const Matrix> ConstSubMatrix;
|
||||||
|
|
||||||
// Matrix formatting arguments when printing. Akin to Matlab style.
|
// Matrix formatting arguments when printing.
|
||||||
const Eigen::IOFormat matlab(
|
// Akin to Matlab style.
|
||||||
Eigen::StreamPrecision, // precision
|
const Eigen::IOFormat& matlabFormat();
|
||||||
Eigen::DontAlignCols, // flags set such that rowSpacers are not added
|
|
||||||
", ", // coeffSeparator
|
|
||||||
";\n", // rowSeparator
|
|
||||||
"\t", // rowPrefix
|
|
||||||
"", // rowSuffix
|
|
||||||
"[\n", // matPrefix
|
|
||||||
"\n]" // matSuffix
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* equals with a tolerance
|
* equals with a tolerance
|
||||||
|
|
|
@ -223,7 +223,7 @@ pair<Matrix3, Vector3> RQ(const Matrix3& A) {
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
ostream &operator<<(ostream &os, const Rot3& R) {
|
ostream &operator<<(ostream &os, const Rot3& R) {
|
||||||
os << R.matrix().format(matlab);
|
os << R.matrix().format(matlabFormat());
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,21 +421,11 @@ JacobianFactor::JacobianFactor(const GaussianFactorGraph& graph,
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
void JacobianFactor::print(const string& s,
|
void JacobianFactor::print(const string& s,
|
||||||
const KeyFormatter& formatter) const {
|
const KeyFormatter& formatter) const {
|
||||||
static const Eigen::IOFormat matlab(
|
|
||||||
Eigen::StreamPrecision, // precision
|
|
||||||
0, // flags
|
|
||||||
" ", // coeffSeparator
|
|
||||||
";\n", // rowSeparator
|
|
||||||
"\t", // rowPrefix
|
|
||||||
"", // rowSuffix
|
|
||||||
"[\n", // matPrefix
|
|
||||||
"\n ]" // matSuffix
|
|
||||||
);
|
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
cout << s << "\n";
|
cout << s << "\n";
|
||||||
for (const_iterator key = begin(); key != end(); ++key) {
|
for (const_iterator key = begin(); key != end(); ++key) {
|
||||||
cout << boost::format(" A[%1%] = ") % formatter(*key);
|
cout << boost::format(" A[%1%] = ") % formatter(*key);
|
||||||
cout << getA(key).format(matlab) << endl;
|
cout << getA(key).format(matlabFormat()) << endl;
|
||||||
}
|
}
|
||||||
cout << formatMatrixIndented(" b = ", getb(), true) << "\n";
|
cout << formatMatrixIndented(" b = ", getb(), true) << "\n";
|
||||||
if (model_)
|
if (model_)
|
||||||
|
|
Loading…
Reference in New Issue