]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns.cpp
- normal() respects the "level" parameter to limit the recursion depth
[ginac.git] / ginac / inifcns.cpp
index c03f4a15a6e29b39d4dea7d5269711fc5ce5f3a4..85a7365fa980ece03a596b9b9cff70724c8da529 100644 (file)
@@ -84,7 +84,7 @@ static ex csgn_eval(const ex & x)
     if (is_ex_exactly_of_type(x, numeric))
         return csgn(ex_to_numeric(x));
     
-    if (is_ex_exactly_of_type(x, mul)) {
+    else if (is_ex_exactly_of_type(x, mul)) {
         numeric oc = ex_to_numeric(x.op(x.nops()-1));
         if (oc.is_real()) {
             if (oc > 0)
@@ -102,13 +102,29 @@ static ex csgn_eval(const ex & x)
                 // csgn(-42*I*x) -> -csgn(I*x)
                 return -csgn(I*x/oc).hold();
         }
-    }
-    
+       }
+   
     return csgn(x).hold();
 }
 
+static ex csgn_series(const ex & x, const relational & rel, int order)
+{
+    const ex x_pt = x.subs(rel);
+    if (x_pt.info(info_flags::numeric)) {
+        if (ex_to_numeric(x_pt).real().is_zero())
+            throw (std::domain_error("csgn_series(): on imaginary axis"));
+        epvector seq;
+        seq.push_back(expair(csgn(x_pt), _ex0()));
+        return pseries(rel,seq);
+    }
+    epvector seq;
+    seq.push_back(expair(csgn(x_pt), _ex0()));
+    return pseries(rel,seq);
+}
+
 REGISTER_FUNCTION(csgn, eval_func(csgn_eval).
-                        evalf_func(csgn_evalf));
+                        evalf_func(csgn_evalf).
+                        series_func(csgn_series));
 
 //////////
 // dilogarithm