]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_trans.cpp
#ifndef around namespace GiNaC { }
[ginac.git] / ginac / inifcns_trans.cpp
index fae653182f4f7c9076526c5cd1dba36ac2e4abef..01711a7fa3c9aae70cc9afc536ab651a157d2d34 100644 (file)
@@ -1,8 +1,9 @@
 /** @file inifcns_trans.cpp
  *
  *  Implementation of transcendental (and trigonometric and hyperbolic)
- *  functions.
- *
+ *  functions. */
+
+/*
  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
 #include "numeric.h"
 #include "power.h"
 
+#ifndef NO_GINAC_NAMESPACE
+namespace GiNaC {
+#endif // ndef NO_GINAC_NAMESPACE
+
 //////////
 // exponential function
 //////////
 
-ex exp_evalf(ex const & x)
+static ex exp_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
         TYPECHECK(x,numeric)
@@ -42,7 +47,7 @@ ex exp_evalf(ex const & x)
     return exp(ex_to_numeric(x)); // -> numeric exp(numeric)
 }
 
-ex exp_eval(ex const & x)
+static ex exp_eval(ex const & x)
 {
     // exp(0) -> 1
     if (x.is_zero()) {
@@ -72,9 +77,9 @@ ex exp_eval(ex const & x)
     return exp(x).hold();
 }    
 
-ex exp_diff(ex const & x, unsigned diff_param)
+static ex exp_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
 
     return exp(x);
 }
@@ -85,7 +90,7 @@ REGISTER_FUNCTION(exp, exp_eval, exp_evalf, exp_diff, NULL);
 // natural logarithm
 //////////
 
-ex log_evalf(ex const & x)
+static ex log_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
         TYPECHECK(x,numeric)
@@ -94,7 +99,7 @@ ex log_evalf(ex const & x)
     return log(ex_to_numeric(x)); // -> numeric log(numeric)
 }
 
-ex log_eval(ex const & x)
+static ex log_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // log(1) -> 0
@@ -120,9 +125,9 @@ ex log_eval(ex const & x)
     return log(x).hold();
 }    
 
-ex log_diff(ex const & x, unsigned diff_param)
+static ex log_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
 
     return power(x, -1);
 }
@@ -133,7 +138,7 @@ REGISTER_FUNCTION(log, log_eval, log_evalf, log_diff, NULL);
 // sine (trigonometric function)
 //////////
 
-ex sin_evalf(ex const & x)
+static ex sin_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -142,7 +147,7 @@ ex sin_evalf(ex const & x)
     return sin(ex_to_numeric(x)); // -> numeric sin(numeric)
 }
 
-ex sin_eval(ex const & x)
+static ex sin_eval(ex const & x)
 {
     // sin(n*Pi) -> 0
     ex xOverPi=x/Pi;
@@ -176,9 +181,9 @@ ex sin_eval(ex const & x)
     return sin(x).hold();
 }
 
-ex sin_diff(ex const & x, unsigned diff_param)
+static ex sin_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return cos(x);
 }
@@ -189,7 +194,7 @@ REGISTER_FUNCTION(sin, sin_eval, sin_evalf, sin_diff, NULL);
 // cosine (trigonometric function)
 //////////
 
-ex cos_evalf(ex const & x)
+static ex cos_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
         TYPECHECK(x,numeric)
@@ -198,7 +203,7 @@ ex cos_evalf(ex const & x)
     return cos(ex_to_numeric(x)); // -> numeric cos(numeric)
 }
 
-ex cos_eval(ex const & x)
+static ex cos_eval(ex const & x)
 {
     // cos(n*Pi) -> {+|-}1
     ex xOverPi=x/Pi;
@@ -232,9 +237,9 @@ ex cos_eval(ex const & x)
     return cos(x).hold();
 }
 
-ex cos_diff(ex const & x, unsigned diff_param)
+static ex cos_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
 
     return numMINUSONE()*sin(x);
 }
@@ -245,7 +250,7 @@ REGISTER_FUNCTION(cos, cos_eval, cos_evalf, cos_diff, NULL);
 // tangent (trigonometric function)
 //////////
 
-ex tan_evalf(ex const & x)
+static ex tan_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -254,7 +259,7 @@ ex tan_evalf(ex const & x)
     return tan(ex_to_numeric(x));
 }
 
-ex tan_eval(ex const & x)
+static ex tan_eval(ex const & x)
 {
     // tan(n*Pi/3) -> {0|3^(1/2)|-(3^(1/2))}
     ex ThreeExOverPi=numTHREE()*x/Pi;
@@ -294,9 +299,9 @@ ex tan_eval(ex const & x)
     return tan(x).hold();
 }
 
-ex tan_diff(ex const & x, unsigned diff_param)
+static ex tan_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return (1+power(tan(x),exTWO()));
 }
@@ -307,7 +312,7 @@ REGISTER_FUNCTION(tan, tan_eval, tan_evalf, tan_diff, NULL);
 // inverse sine (arc sine)
 //////////
 
-ex asin_evalf(ex const & x)
+static ex asin_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -316,7 +321,7 @@ ex asin_evalf(ex const & x)
     return asin(ex_to_numeric(x)); // -> numeric asin(numeric)
 }
 
-ex asin_eval(ex const & x)
+static ex asin_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // asin(0) -> 0
@@ -342,9 +347,9 @@ ex asin_eval(ex const & x)
     return asin(x).hold();
 }
 
-ex asin_diff(ex const & x, unsigned diff_param)
+static ex asin_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return power(1-power(x,exTWO()),exMINUSHALF());
 }
@@ -355,7 +360,7 @@ REGISTER_FUNCTION(asin, asin_eval, asin_evalf, asin_diff, NULL);
 // inverse cosine (arc cosine)
 //////////
 
-ex acos_evalf(ex const & x)
+static ex acos_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -364,7 +369,7 @@ ex acos_evalf(ex const & x)
     return acos(ex_to_numeric(x)); // -> numeric acos(numeric)
 }
 
-ex acos_eval(ex const & x)
+static ex acos_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // acos(1) -> 0
@@ -390,9 +395,9 @@ ex acos_eval(ex const & x)
     return acos(x).hold();
 }
 
-ex acos_diff(ex const & x, unsigned diff_param)
+static ex acos_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return numMINUSONE()*power(1-power(x,exTWO()),exMINUSHALF());
 }
@@ -403,7 +408,7 @@ REGISTER_FUNCTION(acos, acos_eval, acos_evalf, acos_diff, NULL);
 // inverse tangent (arc tangent)
 //////////
 
-ex atan_evalf(ex const & x)
+static ex atan_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
         TYPECHECK(x,numeric)
@@ -412,7 +417,7 @@ ex atan_evalf(ex const & x)
     return atan(ex_to_numeric(x)); // -> numeric atan(numeric)
 }
 
-ex atan_eval(ex const & x)
+static ex atan_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // atan(0) -> 0
@@ -426,9 +431,9 @@ ex atan_eval(ex const & x)
     return atan(x).hold();
 }    
 
-ex atan_diff(ex const & x, unsigned diff_param)
+static ex atan_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
 
     return power(1+x*x, -1);
 }
@@ -439,7 +444,7 @@ REGISTER_FUNCTION(atan, atan_eval, atan_evalf, atan_diff, NULL);
 // inverse tangent (atan2(y,x))
 //////////
 
-ex atan2_evalf(ex const & y, ex const & x)
+static ex atan2_evalf(ex const & y, ex const & x)
 {
     BEGIN_TYPECHECK
         TYPECHECK(y,numeric)
@@ -449,7 +454,7 @@ ex atan2_evalf(ex const & y, ex const & x)
     return atan(ex_to_numeric(y),ex_to_numeric(x)); // -> numeric atan(numeric)
 }
 
-ex atan2_eval(ex const & y, ex const & x)
+static ex atan2_eval(ex const & y, ex const & x)
 {
     if (y.info(info_flags::numeric) && !y.info(info_flags::rational) &&
         x.info(info_flags::numeric) && !x.info(info_flags::rational)) {
@@ -459,16 +464,16 @@ ex atan2_eval(ex const & y, ex const & x)
     return atan2(y,x).hold();
 }    
 
-ex atan2_diff(ex const & y, ex const & x, unsigned diff_param)
+static ex atan2_diff(ex const & y, ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param<2);
-
+    GINAC_ASSERT(diff_param<2);
+    
     if (diff_param==0) {
         // d/dy atan(y,x)
-        return power(x*(1+y*y/(x*x)),-1);
+        return x*pow(pow(x,2)+pow(y,2),-1);
     }
     // d/dx atan(y,x)
-    return -y*power(x*x+y*y,-1);
+    return -y*pow(pow(x,2)+pow(y,2),-1);
 }
 
 REGISTER_FUNCTION(atan2, atan2_eval, atan2_evalf, atan2_diff, NULL);
@@ -477,7 +482,7 @@ REGISTER_FUNCTION(atan2, atan2_eval, atan2_evalf, atan2_diff, NULL);
 // hyperbolic sine (trigonometric function)
 //////////
 
-ex sinh_evalf(ex const & x)
+static ex sinh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -486,7 +491,7 @@ ex sinh_evalf(ex const & x)
     return sinh(ex_to_numeric(x)); // -> numeric sinh(numeric)
 }
 
-ex sinh_eval(ex const & x)
+static ex sinh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // sinh(0) -> 0
@@ -513,9 +518,9 @@ ex sinh_eval(ex const & x)
     return sinh(x).hold();
 }
 
-ex sinh_diff(ex const & x, unsigned diff_param)
+static ex sinh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return cosh(x);
 }
@@ -526,7 +531,7 @@ REGISTER_FUNCTION(sinh, sinh_eval, sinh_evalf, sinh_diff, NULL);
 // hyperbolic cosine (trigonometric function)
 //////////
 
-ex cosh_evalf(ex const & x)
+static ex cosh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -535,7 +540,7 @@ ex cosh_evalf(ex const & x)
     return cosh(ex_to_numeric(x)); // -> numeric cosh(numeric)
 }
 
-ex cosh_eval(ex const & x)
+static ex cosh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // cosh(0) -> 1
@@ -562,9 +567,9 @@ ex cosh_eval(ex const & x)
     return cosh(x).hold();
 }
 
-ex cosh_diff(ex const & x, unsigned diff_param)
+static ex cosh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return sinh(x);
 }
@@ -575,7 +580,7 @@ REGISTER_FUNCTION(cosh, cosh_eval, cosh_evalf, cosh_diff, NULL);
 // hyperbolic tangent (trigonometric function)
 //////////
 
-ex tanh_evalf(ex const & x)
+static ex tanh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -584,7 +589,7 @@ ex tanh_evalf(ex const & x)
     return tanh(ex_to_numeric(x)); // -> numeric tanh(numeric)
 }
 
-ex tanh_eval(ex const & x)
+static ex tanh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // tanh(0) -> 0
@@ -611,9 +616,9 @@ ex tanh_eval(ex const & x)
     return tanh(x).hold();
 }
 
-ex tanh_diff(ex const & x, unsigned diff_param)
+static ex tanh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return exONE()-power(tanh(x),exTWO());
 }
@@ -624,7 +629,7 @@ REGISTER_FUNCTION(tanh, tanh_eval, tanh_evalf, tanh_diff, NULL);
 // inverse hyperbolic sine (trigonometric function)
 //////////
 
-ex asinh_evalf(ex const & x)
+static ex asinh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -633,7 +638,7 @@ ex asinh_evalf(ex const & x)
     return asinh(ex_to_numeric(x)); // -> numeric asinh(numeric)
 }
 
-ex asinh_eval(ex const & x)
+static ex asinh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // asinh(0) -> 0
@@ -647,9 +652,9 @@ ex asinh_eval(ex const & x)
     return asinh(x).hold();
 }
 
-ex asinh_diff(ex const & x, unsigned diff_param)
+static ex asinh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return power(1+power(x,exTWO()),exMINUSHALF());
 }
@@ -660,7 +665,7 @@ REGISTER_FUNCTION(asinh, asinh_eval, asinh_evalf, asinh_diff, NULL);
 // inverse hyperbolic cosine (trigonometric function)
 //////////
 
-ex acosh_evalf(ex const & x)
+static ex acosh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -669,7 +674,7 @@ ex acosh_evalf(ex const & x)
     return acosh(ex_to_numeric(x)); // -> numeric acosh(numeric)
 }
 
-ex acosh_eval(ex const & x)
+static ex acosh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // acosh(0) -> Pi*I/2
@@ -689,9 +694,9 @@ ex acosh_eval(ex const & x)
     return acosh(x).hold();
 }
 
-ex acosh_diff(ex const & x, unsigned diff_param)
+static ex acosh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return power(x-1,exMINUSHALF())*power(x+1,exMINUSHALF());
 }
@@ -702,7 +707,7 @@ REGISTER_FUNCTION(acosh, acosh_eval, acosh_evalf, acosh_diff, NULL);
 // inverse hyperbolic tangent (trigonometric function)
 //////////
 
-ex atanh_evalf(ex const & x)
+static ex atanh_evalf(ex const & x)
 {
     BEGIN_TYPECHECK
        TYPECHECK(x,numeric)
@@ -711,7 +716,7 @@ ex atanh_evalf(ex const & x)
     return atanh(ex_to_numeric(x)); // -> numeric atanh(numeric)
 }
 
-ex atanh_eval(ex const & x)
+static ex atanh_eval(ex const & x)
 {
     if (x.info(info_flags::numeric)) {
         // atanh(0) -> 0
@@ -728,11 +733,15 @@ ex atanh_eval(ex const & x)
     return atanh(x).hold();
 }
 
-ex atanh_diff(ex const & x, unsigned diff_param)
+static ex atanh_diff(ex const & x, unsigned diff_param)
 {
-    ASSERT(diff_param==0);
+    GINAC_ASSERT(diff_param==0);
     
     return power(exONE()-power(x,exTWO()),exMINUSONE());
 }
 
 REGISTER_FUNCTION(atanh, atanh_eval, atanh_evalf, atanh_diff, NULL);
+
+#ifndef NO_GINAC_NAMESPACE
+} // namespace GiNaC
+#endif // ndef NO_GINAC_NAMESPACE