From e102a4458307077ff5b05f5de6df5a5d2c517724 Mon Sep 17 00:00:00 2001 From: torset Date: Thu, 5 Feb 2009 13:25:16 +0000 Subject: Add complex pow exception : z=0 --- src/elementaryFunctions/pow/cpows.c | 11 ++++++++++- src/elementaryFunctions/pow/zpows.c | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/elementaryFunctions/pow/cpows.c b/src/elementaryFunctions/pow/cpows.c index 87392706..5848c4b5 100644 --- a/src/elementaryFunctions/pow/cpows.c +++ b/src/elementaryFunctions/pow/cpows.c @@ -15,5 +15,14 @@ #include "log.h" floatComplex cpows(floatComplex z, floatComplex power) { - return cexps(cmuls(clogs(z), power)); + /*Cas z=0 */ + if ( (creals(z)==0) && (cimags(z)==0) ){ + /* Cas 0^0 */ + if ( (creals(power)==0) && (cimags(power)==0) ) return FloatComplex(1,0); + /* Cas 0^x, x!=0 */ + return FloatComplex(0,0); + } + + /* Cas z!=0 */ + return cexps(cmuls(clogs(z), power)); } diff --git a/src/elementaryFunctions/pow/zpows.c b/src/elementaryFunctions/pow/zpows.c index cc532090..1a7059b2 100644 --- a/src/elementaryFunctions/pow/zpows.c +++ b/src/elementaryFunctions/pow/zpows.c @@ -15,5 +15,14 @@ #include "exp.h" doubleComplex zpows(doubleComplex z, doubleComplex power) { + /*Cas z=0 */ + if ( (zreals(z)==0) && (zimags(z)==0) ){ + /* Cas 0^0 */ + if ( (zreals(power)==0) && (zimags(power)==0) ) return DoubleComplex(1,0); + /* Cas 0^x, x!=0 */ + return DoubleComplex(0,0); + } + + /* Cas z!=0 */ return zexps(zmuls(zlogs(z), power)); } -- cgit