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;
|
||||
}
|
||||
|
||||
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
|
||||
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<const Matrix> ConstSubMatrix;
|
||||
|
||||
// Matrix formatting arguments when printing. Akin to Matlab style.
|
||||
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
|
||||
);
|
||||
// Matrix formatting arguments when printing.
|
||||
// Akin to Matlab style.
|
||||
const Eigen::IOFormat& matlabFormat();
|
||||
|
||||
/**
|
||||
* equals with a tolerance
|
||||
|
|
|
@ -223,7 +223,7 @@ pair<Matrix3, Vector3> RQ(const Matrix3& A) {
|
|||
|
||||
/* ************************************************************************* */
|
||||
ostream &operator<<(ostream &os, const Rot3& R) {
|
||||
os << R.matrix().format(matlab);
|
||||
os << R.matrix().format(matlabFormat());
|
||||
return os;
|
||||
}
|
||||
|
||||
|
|
|
@ -421,21 +421,11 @@ JacobianFactor::JacobianFactor(const GaussianFactorGraph& graph,
|
|||
/* ************************************************************************* */
|
||||
void JacobianFactor::print(const string& s,
|
||||
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())
|
||||
cout << s << "\n";
|
||||
for (const_iterator key = begin(); key != end(); ++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";
|
||||
if (model_)
|
||||
|
|
Loading…
Reference in New Issue