From c1f464625be16fabb9f7e37ed83e71bedfdbeec0 Mon Sep 17 00:00:00 2001 From: dellaert Date: Fri, 12 Dec 2014 12:39:32 +0100 Subject: [PATCH] Provided (some) printing functionality --- gtsam/nonlinear/Expression-inl.h | 8 ++++++++ gtsam/nonlinear/Expression.h | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/gtsam/nonlinear/Expression-inl.h b/gtsam/nonlinear/Expression-inl.h index 8c3f8b24c..c5a4aaeaa 100644 --- a/gtsam/nonlinear/Expression-inl.h +++ b/gtsam/nonlinear/Expression-inl.h @@ -34,6 +34,7 @@ #include namespace MPL = boost::mpl::placeholders; +#include // operator typeid #include class ExpressionFactorBinaryTest; @@ -247,6 +248,13 @@ public: virtual ~ExpressionNode() { } + /// Streaming + GTSAM_EXPORT friend std::ostream &operator<<(std::ostream &os, + const ExpressionNode& node) { + os << "Expression of type " << typeid(int).name() << std::endl; + if (node.traceSize_>0) os << node.traceSize_ << std::endl; + } + /// Return keys that play in this expression as a set virtual std::set keys() const { std::set keys; diff --git a/gtsam/nonlinear/Expression.h b/gtsam/nonlinear/Expression.h index fe07de039..0bd07b97d 100644 --- a/gtsam/nonlinear/Expression.h +++ b/gtsam/nonlinear/Expression.h @@ -52,6 +52,11 @@ private: public: + /// Print + void print(const std::string& s) const { + std::cout << s << root_ << std::endl; + } + // Construct a constant expression Expression(const T& value) : root_(new ConstantExpression(value)) {