]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_zeta.cpp
- ex_to<foo>(obj) is a good candidate for asserting is_a<foo>(obj).
[ginac.git] / ginac / inifcns_zeta.cpp
index 14015b79e9c8a578da3ec08e6320e197f720515b..53eba05bb23107e1119b11568638da5ff954b15f 100644 (file)
@@ -38,21 +38,23 @@ namespace GiNaC {
 
 static ex zeta1_evalf(const ex & x)
 {
-       BEGIN_TYPECHECK
-               TYPECHECK(x,numeric)
-       END_TYPECHECK(zeta(x))
-               
-       return zeta(ex_to_numeric(x));
+       if (is_exactly_a<numeric>(x)) {
+               try {
+                       return zeta(ex_to<numeric>(x));
+               } catch (const dunno &e) { }
+       }
+       
+       return zeta(x).hold();
 }
 
 static ex zeta1_eval(const ex & x)
 {
        if (x.info(info_flags::numeric)) {
-               numeric y = ex_to_numeric(x);
+               numeric y = ex_to<numeric>(x);
                // trap integer arguments:
                if (y.is_integer()) {
                        if (y.is_zero())
-                               return -_ex1_2();
+                               return _ex_1_2();
                        if (x.is_equal(_ex1()))
                                throw(std::domain_error("zeta(1): infinity"));
                        if (x.info(info_flags::posint)) {
@@ -67,6 +69,9 @@ static ex zeta1_eval(const ex & x)
                                        return _num0();
                        }
                }
+               // zeta(float)
+               if (x.info(info_flags::numeric) && !x.info(info_flags::crational))
+                       return zeta1_evalf(x);
        }
        return zeta(x).hold();
 }