diff -Nru ginac-1.5.8.orig/ginac/symbol.cpp ginac-1.5.8.patch/ginac/symbol.cpp
--- ginac-1.5.8.orig/ginac/symbol.cpp	2010-03-05 21:39:00.000000000 +0100
+++ ginac-1.5.8.patch/ginac/symbol.cpp	2011-02-15 15:43:14.218196002 +0100
@@ -46,7 +46,7 @@
 
 // symbol
 
-symbol::symbol() : serial(next_serial++), name(""), TeX_name("")
+symbol::symbol() : serial(next_serial++), name(""), TeX_name(""), rtype(return_types::commutative)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
@@ -68,13 +68,19 @@
 // symbol
 
 symbol::symbol(const std::string & initname) : serial(next_serial++),
-	name(initname), TeX_name("")
+	name(initname), TeX_name(""), rtype(return_types::commutative)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
 
 symbol::symbol(const std::string & initname, const std::string & texname) :
-	serial(next_serial++), name(initname), TeX_name(texname)
+	serial(next_serial++), name(initname), TeX_name(texname), rtype(return_types::commutative)
+{
+	setflag(status_flags::evaluated | status_flags::expanded);
+}
+
+symbol::symbol(const std::string & initname, const std::string & texname, const unsigned return_type) :
+	serial(next_serial++), name(initname), TeX_name(texname), rtype(return_type)
 {
 	setflag(status_flags::evaluated | status_flags::expanded);
 }
@@ -86,6 +92,9 @@
 realsymbol::realsymbol(const std::string & initname, const std::string & texname)
 	: symbol(initname, texname) { }
 
+realsymbol::realsymbol(const std::string & initname, const std::string & texname, const unsigned return_type)
+	: symbol(initname, texname, return_type) { }
+
 // possymbol
 	
 possymbol::possymbol(const std::string & initname) : realsymbol(initname) { }
@@ -93,6 +102,9 @@
 possymbol::possymbol(const std::string & initname, const std::string & texname) 
 	: realsymbol(initname, texname) { }
 
+possymbol::possymbol(const std::string & initname, const std::string & texname, const unsigned return_type) 
+	: realsymbol(initname, texname, return_type) { }
+
 //////////
 // archiving
 //////////
@@ -115,6 +127,8 @@
 	name = tmp_name;
 	if (!n.find_string("TeXname", TeX_name))
 		TeX_name = std::string("");
+        if (!n.find_unsigned("rtype", rtype))
+		rtype = return_types::commutative;
 	setflag(status_flags::evaluated | status_flags::expanded);
 
 	setflag(status_flags::dynallocated);
@@ -130,6 +144,7 @@
 		n.add_string("name", name);
 	if (!TeX_name.empty())
 		n.add_string("TeX_name", TeX_name);
+        n.add_unsigned("rtype", rtype);
 }
 
 //////////
@@ -164,8 +179,13 @@
 	c.s << std::string(level, ' ') << name << " (" << class_name() << ")" << " @" << this
 	    << ", serial=" << serial
 	    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
-	    << ", domain=" << get_domain()
-	    << std::endl;
+	    << ", domain=" << get_domain();
+        switch (rtype) {
+	  case return_types::commutative: c.s << ", commutative";
+          case return_types::noncommutative: c.s << ", non-commutative";
+	  case return_types::noncommutative_composite: c.s << ", non-commutative composite";
+        }
+	c.s << std::endl;
 }
 
 void symbol::do_print_python_repr(const print_python_repr & c, unsigned level) const
diff -Nru ginac-1.5.8.orig/ginac/symbol.h ginac-1.5.8.patch/ginac/symbol.h
--- ginac-1.5.8.orig/ginac/symbol.h	2010-03-05 21:39:00.000000000 +0100
+++ ginac-1.5.8.patch/ginac/symbol.h	2011-02-15 15:28:07.710196001 +0100
@@ -42,6 +42,7 @@
 public:
 	explicit symbol(const std::string & initname);
 	symbol(const std::string & initname, const std::string & texname);
+        symbol(const std::string & initname, const std::string & texname, const unsigned return_type);
 	
 	// functions overriding virtual functions from base classes
 public:
@@ -72,6 +73,7 @@
 	std::string get_name() const { return name; }
 	virtual unsigned get_domain() const { return domain::complex; }
 protected:
+	unsigned return_type() const { return rtype; }
 	void do_print(const print_context & c, unsigned level) const;
 	void do_print_latex(const print_latex & c, unsigned level) const;
 	void do_print_tree(const print_tree & c, unsigned level) const;
@@ -83,6 +85,7 @@
 	unsigned serial;                 ///< unique serial number for comparison
 	std::string name;                ///< printname of this symbol
 	std::string TeX_name;            ///< LaTeX name of this symbol
+        unsigned rtype;			 ///< return type (commutativity) of this symbol
 private:
 	static unsigned next_serial;
 };
@@ -96,6 +99,7 @@
 	realsymbol();
 	explicit realsymbol(const std::string & initname);
 	realsymbol(const std::string & initname, const std::string & texname);
+	realsymbol(const std::string & initname, const std::string & texname, const unsigned return_type);
 
 	unsigned get_domain() const { return domain::real; }
 
@@ -115,6 +119,7 @@
 	possymbol();
 	explicit possymbol(const std::string & initname);
 	possymbol(const std::string & initname, const std::string & texname);
+	possymbol(const std::string & initname, const std::string & texname, const unsigned return_type);
 
 	unsigned get_domain() const { return domain::positive; }
 
