Hi, something must be wrong with my subclass, but I don't understand it. I subclassed symbol to get a non-commutative version: ---------- HEADER -------------- #include <ginac/symbol.h> namespace GiNaC { class ncsymbol: public symbol { public: ncsymbol(const symbol& s); explicit ncsymbol(const std::string & initname); ncsymbol(const std::string & initname, const std::string & texname); unsigned return_type() const { return return_types::noncommutative_composite; } }; GINAC_DECLARE_UNARCHIVER(ncsymbol); } ---------- IMPLEMENTATION ------------- #include <ginac/ginac.h> namespace GiNaC { // non-commutative symbol ncsymbol::ncsymbol() : symbol() { } ncsymbol::ncsymbol(const symbol& s) : symbol(s) { } ncsymbol::ncsymbol(const std::string & initname) : symbol(initname) { } ncsymbol::ncsymbol(const std::string & initname, const std::string & texname) : symbol(initname, texname) { } GINAC_BIND_UNARCHIVER(ncsymbol); -------------------------------------- But when I execute the following code the program crashes when printing x: symbol x("x"); x = ncsymbol("y"); std::cout << x << std::endl; It does not crash if I print ncsymbol("y") directly (without assigning it to x first). Can anybody explain why? Did I forget to implement an essential method? Thanks! Jan
On Wed, 11 May 2016 21:10:29 +0200, Jan Rheinländer <jrheinlaender@gmx.de> said:
JR> Hi, something must be wrong with my subclass, but I don't JR> understand it. Did you look into section "6.5.1 Hierarchy of algebraic classes" of the tutorial? I think you need to use several macros described there. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
Hi, the code is practically the same as in GiNaC symbol.h and symbol.cpp (for symbol subclasses realsymbol / possymbol). I did try using GINAC_DECLARE_REGISTERED_CLASS(ncsymbol, symbol) etc. as well but it makes no difference. And I just tried: If I use GiNaC::realsymbol class instead of my own ncsymbol class the code also crashes. So maybe its a GinaC bug? Am 11.05.2016 um 21:45 schrieb Vladimir V. Kisil:
On Wed, 11 May 2016 21:10:29 +0200, Jan Rheinländer <jrheinlaender@gmx.de> said: JR> Hi, something must be wrong with my subclass, but I don't JR> understand it.
Did you look into section "6.5.1 Hierarchy of algebraic classes" of the tutorial? I think you need to use several macros described there.
On Wed, 11 May 2016 21:56:50 +0200, Jan Rheinländer <jrheinlaender@gmx.de> said:
JR> Hi, the code is practically the same as in GiNaC symbol.h and JR> symbol.cpp (for symbol subclasses realsymbol / possymbol). I JR> did try using GINAC_DECLARE_REGISTERED_CLASS(ncsymbol, symbol) JR> etc. as well but it makes no difference. I think you have to send the full example written in accordance to GiNaC tutorial which crashes, then other people may look into it. -- Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/ Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu Software: Geometry of cycles http://moebinv.sourceforge.net/
participants (2)
-
Jan Rheinländer
-
Vladimir V. Kisil