- exprseq and lst are commutative (they shouldn't appear in products anyway,
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 19 Feb 2003 21:11:00 +0000 (21:11 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 19 Feb 2003 21:11:00 +0000 (21:11 +0000)
  but this simplifies the use of lists as function arguments)
- function_options::set_return_type() now actually works

ginac/container.pl
ginac/function.pl

index 39c7538..9b02154 100755 (executable)
@@ -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
 //////////
index bc46d71..7602527 100755 (executable)
@@ -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();
+       }
 }
 
 //////////