Commit a8fc4c92 authored by jcarpent's avatar jcarpent Committed by Joseph Mirabel
Browse files

[Print] eigen_format algo must be located in the header

This static method can be called according to various templated object through prettyPrint<Object>::run
parent 868a0b3a
......@@ -46,6 +46,24 @@ namespace hpp {
template <bool OneLine, bool PythonStyle, bool Vector>
struct HPP_PINOCCHIO_DLLAPI eigen_format { static const Eigen::IOFormat run(); };
// Default implementation
template <bool OneLine, bool PythonStyle, bool Vector> const Eigen::IOFormat
eigen_format<OneLine, PythonStyle, Vector>::run() {
static const Eigen::IOFormat fmt(
(PythonStyle ? Eigen::FullPrecision : Eigen::StreamPrecision),
0,
", ", // Coeff separator
(PythonStyle // Row separator
? (OneLine ? ", ": ",\n" )
: (OneLine ? "; ": "\n" )),
(PythonStyle ? "(" : ""), // row prefix
(PythonStyle ? ",)" : ""), // row suffix
(PythonStyle && !Vector ? "( " : ""), // mat prefix
(PythonStyle && !Vector ? ", )" : "") // mat suffix
);
return fmt;
}
template <typename T, int Option> struct PrettyPrint {
const T& value;
......
......@@ -29,23 +29,6 @@ namespace hpp {
std::ostream& setpyformat (std::ostream& o) { getpythonformat(o) = 1; return o; }
std::ostream& unsetpyformat (std::ostream& o) { getpythonformat(o) = 0; return o; }
template <bool OneLine, bool PythonStyle, bool Vector> const Eigen::IOFormat&
eigen_format<OneLine, PythonStyle, Vector>::run() {
static const Eigen::IOFormat fmt(
(PythonStyle ? Eigen::FullPrecision : Eigen::StreamPrecision),
0,
", ", // Coeff separator
(PythonStyle // Row separator
? (OneLine ? ", ": ",\n" )
: (OneLine ? "; ": "\n" )),
(PythonStyle ? "(" : ""), // row prefix
(PythonStyle ? ",)" : ""), // row suffix
(PythonStyle && !Vector ? "( " : ""), // mat prefix
(PythonStyle && !Vector ? ", )" : "") // mat suffix
);
return fmt;
}
// se3::SE3
template <int Option> struct HPP_PINOCCHIO_DLLAPI prettyPrint <se3::SE3, Option> {
static std::ostream& run (std::ostream& os, const se3::SE3& M)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment