31#ifndef HPP_PINOCCHIO_UTIL_HH 
   32#define HPP_PINOCCHIO_UTIL_HH 
   36#include <hpp/util/indent.hh> 
   77template <
typename T, 
int Option>
 
   79  static std::ostream& 
run(std::ostream& os, 
const T& pp);
 
 
   94template <
bool OneLine, 
bool PythonStyle, 
bool Vector>
 
   96  static const Eigen::IOFormat run();
 
  100template <
bool OneLine, 
bool PythonStyle, 
bool Vector>
 
  101const Eigen::IOFormat eigen_format<OneLine, PythonStyle, Vector>::run() {
 
  102  static const Eigen::IOFormat fmt(
 
  103      (PythonStyle ? Eigen::FullPrecision : Eigen::StreamPrecision), 0,
 
  106           ? (OneLine ? 
", " : 
",\n")
 
  107           : (OneLine ? 
"; " : 
"\n")),
 
  108      (PythonStyle ? 
"(" : 
""),              
 
  109      (PythonStyle ? 
",)" : 
""),             
 
  110      (PythonStyle && !Vector ? 
"( " : 
""),  
 
  111      (PythonStyle && !Vector ? 
", )" : 
"")  
 
  116template <
typename T, 
int Option>
 
  119  inline explicit PrettyPrint(
const T& t) : value(t) {}
 
  122template <
typename T, 
int Option>
 
  123std::ostream& 
operator<<(std::ostream& os, 
const PrettyPrint<T, Option> pp) {
 
  128template <
typename Derived, 
int Option>
 
  130    static inline std::ostream &
 
  131    run(std::ostream & os, 
const Derived& M){
 
  134static const Eigen::IOFormat mfmt_py =
 
  135    eigen_format<Condensed, true, false>::run();
 
  136static const Eigen::IOFormat vfmt_py =
 
  137    eigen_format<Condensed, true, true>::run();
 
  138static const Eigen::IOFormat mfmt_raw =
 
  139    eigen_format<Condensed, false, false>::run();
 
  140static const Eigen::IOFormat vfmt_raw =
 
  141    eigen_format<Condensed, false, true>::run();
 
  142bool use_py_fmt = (getpythonformat(os) != 0);
 
  143const Eigen::IOFormat& fmt =
 
  144    (Derived::IsVectorAtCompileTime ? (use_py_fmt ? vfmt_py : vfmt_raw)
 
  145                                    : (use_py_fmt ? mfmt_py : mfmt_raw));
 
  146bool transpose = (Derived::ColsAtCompileTime == 1);
 
  149  return os << M.transpose().format(fmt);
 
  151  return os << M.format(fmt);
 
  158template <
typename _Scalar, 
int _Rows, 
int _Cols, 
int _Options, 
int _MaxRows,
 
  159          int _MaxCols, 
int Option>
 
  161    Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>, Option>
 
  163          Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>,
 
  167template <
typename OtherDerived, 
int Size, 
int Option>
 
  169    prettyPrint<Eigen::VectorBlock<OtherDerived, Size>, Option>
 
  170    : prettyPrintEigen<Eigen::VectorBlock<OtherDerived, Size>, Option> {};
 
  173template <
typename XprType, 
int BlockRows, 
int BlockCols, 
bool InnerPanel,
 
  176    prettyPrint<Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>, Option>
 
  177    : prettyPrintEigen<Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>,
 
  181template <
typename _PlainObjectType, 
int _Options, 
typename _StrideType,
 
  184    prettyPrint<Eigen::Ref<_PlainObjectType, _Options, _StrideType>, Option>
 
  185    : prettyPrintEigen<Eigen::Ref<_PlainObjectType, _Options, _StrideType>,
 
  189template <
typename _PlainObjectType, 
int Option>
 
  191    prettyPrint<Eigen::Transpose<_PlainObjectType>, Option>
 
  192    : prettyPrintEigen<Eigen::Transpose<_PlainObjectType>, Option> {};
 
  195template <
typename _Scalar, 
int _Options, 
int Option>
 
  197    prettyPrint<Eigen::Quaternion<_Scalar, _Options>, Option> {
 
  198  typedef Eigen::Quaternion<_Scalar, _Options> Derived;
 
  199  typedef typename Eigen::internal::traits<Derived>::Coefficients Coefficients;
 
  200  static inline std::ostream& run(std::ostream& os, 
const Derived& M) {
 
  201    return prettyPrint<Coefficients, Option>::run(os, M.coeffs());
 
  215  return PrettyPrint<T, PrettyOutput>(t);
 
 
  219inline PrettyPrint<T, CondensedOutput> 
condensed(
const T& t) {
 
  220  return PrettyPrint<T, CondensedOutput>(t);
 
 
  224inline PrettyPrint<T, OneLineOutput> 
one_line(
const T& t) {
 
  225  return PrettyPrint<T, OneLineOutput>(t);
 
 
#define HPP_PINOCCHIO_DLLAPI
Definition config.hh:88
PrettyPrint< T, OneLineOutput > one_line(const T &t)
Print on one line.
Definition util.hh:224
HPP_PINOCCHIO_DLLAPI std::ostream & setpyformat(std::ostream &o)
PrettyPrint< T, CondensedOutput > condensed(const T &t)
Condensed printing.
Definition util.hh:219
PrettyPrint< T, PrettyOutput > pretty_print(const T &t)
Pretty printing.
Definition util.hh:214
HPP_PINOCCHIO_DLLAPI std::ostream & unsetpyformat(std::ostream &o)
@ PrettyOutput
Definition util.hh:88
@ CondensedOutput
Definition util.hh:87
@ OutputFormatBits
Definition util.hh:84
@ OneLineOutput
Definition util.hh:86
std::ostream & operator<<(std::ostream &os, const hpp::pinocchio::Device &device)
Definition device.hh:366
Utility functions.
Definition body.hh:39
This function must be specialized for the type you want to print.
Definition util.hh:78
static std::ostream & run(std::ostream &os, const T &pp)