]> www.ginac.de Git - ginac.git/commitdiff
- 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 39c75385197ddbe0a93b684c039a90212a943e88..9b02154097836fb0f4718eb3b3f275018e8148bd 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;
        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:
 
        // 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;
 }
 
        return true;
 }
 
-unsigned ${CONTAINER}::return_type(void) const
-{
-       return return_types::noncommutative_composite;
-}
-
 //////////
 // new virtual functions which can be overridden by derived classes
 //////////
 //////////
 // new virtual functions which can be overridden by derived classes
 //////////
index bc46d710ad3355dd4f4e4ee64e72d8ad6900513a..760252748775130c3db0331776c131e1a0cef96c 100755 (executable)
@@ -504,7 +504,6 @@ function_options& function_options::series_func(series_funcp_exvector s)
        return *this;
 }
 
        return *this;
 }
 
-
 function_options & function_options::set_return_type(unsigned rt, unsigned rtt)
 {
        use_return_type = true;
 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
 {
 
 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
 {
 }
 
 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();
+       }
 }
 
 //////////
 }
 
 //////////