From: Christian Bauer Date: Wed, 19 Feb 2003 21:11:00 +0000 (+0000) Subject: - exprseq and lst are commutative (they shouldn't appear in products anyway, X-Git-Tag: release_1-0-14~8 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=82fd1a4ad2f5d58a502a2ccc71be45093b282fea;p=ginac.git - exprseq and lst are commutative (they shouldn't appear in products anyway, but this simplifies the use of lists as function arguments) - function_options::set_return_type() now actually works --- diff --git a/ginac/container.pl b/ginac/container.pl index 39c75385..9b021540 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -244,7 +244,6 @@ public: ex subs(const lst & ls, const lst & lr, bool no_pattern = false) const; protected: bool is_equal_same_type(const basic & other) const; - unsigned return_type(void) const; // new virtual functions which can be overridden by derived classes public: @@ -522,11 +521,6 @@ bool ${CONTAINER}::is_equal_same_type(const basic & other) const return true; } -unsigned ${CONTAINER}::return_type(void) const -{ - return return_types::noncommutative_composite; -} - ////////// // new virtual functions which can be overridden by derived classes ////////// diff --git a/ginac/function.pl b/ginac/function.pl index bc46d710..76025274 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -504,7 +504,6 @@ function_options& function_options::series_func(series_funcp_exvector s) return *this; } - function_options & function_options::set_return_type(unsigned rt, unsigned rtt) { use_return_type = true; @@ -913,18 +912,36 @@ bool function::match_same_type(const basic & other) const unsigned function::return_type(void) const { - if (seq.empty()) - return return_types::commutative; - else - return seq.begin()->return_type(); + const function_options &opt = registered_functions()[serial]; + + if (opt.use_return_type) { + // Return type was explicitly specified + return opt.return_type; + } else { + // Default behavior is to use the return type of the first + // argument. Thus, exp() of a matrix behaves like a matrix, etc. + if (seq.empty()) + return return_types::commutative; + else + return seq.begin()->return_type(); + } } unsigned function::return_type_tinfo(void) const { - if (seq.empty()) - return tinfo_key; - else - return seq.begin()->return_type_tinfo(); + const function_options &opt = registered_functions()[serial]; + + if (opt.use_return_type) { + // Return type was explicitly specified + return opt.return_type_tinfo; + } else { + // Default behavior is to use the return type of the first + // argument. Thus, exp() of a matrix behaves like a matrix, etc. + if (seq.empty()) + return tinfo_key; + else + return seq.begin()->return_type_tinfo(); + } } //////////