[pure-lang-svn] SF.net SVN: pure-lang:[575] pure/trunk
Status: Beta
Brought to you by:
agraef
|
From: <ag...@us...> - 2008-08-22 20:24:39
|
Revision: 575
http://pure-lang.svn.sourceforge.net/pure-lang/?rev=575&view=rev
Author: agraef
Date: 2008-08-22 20:24:48 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
Remove all special case rules for the real -> complex cases, so that real functions always return real results now.
Modified Paths:
--------------
pure/trunk/lib/math.pure
pure/trunk/lib/primitives.pure
pure/trunk/test/test020.log
Modified: pure/trunk/lib/math.pure
===================================================================
--- pure/trunk/lib/math.pure 2008-08-22 16:34:32 UTC (rev 574)
+++ pure/trunk/lib/math.pure 2008-08-22 20:24:48 UTC (rev 575)
@@ -26,17 +26,16 @@
/* The sqrt function. */
-extern double sqrt(double) = c_sqrt;
+extern double sqrt(double);
-sqrt x::double = c_sqrt x if x>=0 || nanp x;
sqrt x::int | sqrt x::bigint = sqrt (double x);
/* Exponential function and logarithms. */
extern double exp(double), double log(double) = c_log;
-ln x::double = c_log x if x>=0.0 || nanp x;
-log x::double = c_log x/c_log 10.0 if x>=0.0 || nanp x;
+ln x::double = c_log x;
+log x::double = c_log x/c_log 10.0;
exp x::int | exp x::bigint = exp (double x);
ln x::int | ln x::bigint = ln (double x);
@@ -75,8 +74,8 @@
extern double __asinh(double), double __acosh(double), double __atanh(double);
asinh x::double = __asinh x;
-acosh x::double = __acosh x if x>=1.0 || nanp x;
-atanh x::double = __atanh x if abs x<=1.0 || nanp x;
+acosh x::double = __acosh x;
+atanh x::double = __atanh x;
sinh x::int | sinh x::bigint = sinh (double x);
cosh x::int | cosh x::bigint = cosh (double x);
@@ -188,9 +187,6 @@
when r = sqrt (x*x+y*y) end;
sqrt (r<:t) = sqrt r <: t/2;
-// Complex square roots of negative reals.
-sqrt x::double = 0.0 +: sqrt (-x) if x<0;
-
/* Complex exponential and logarithms. */
exp (x+:y) = exp x * (cos y +: sin y);
@@ -202,10 +198,6 @@
log z@(x+:y) |
log z@(r<:t) = ln z / ln 10;
-// Complex logarithms of negative reals.
-ln x::double = ln (abs x) +: arg x if x<0;
-log x::double = ln x / ln 10 if x<0;
-
/* Complex trig functions. */
sin (x+:y) = sin x*cosh y +: cos x*sinh y;
@@ -246,10 +238,6 @@
= -inf +: 0.0 if z==-1;
= ln ((1+z)/(1-z))/2;
-// These inverse hyperbolic trigs have complex results for some reals.
-acosh x::double = acosh (x+:0);
-atanh x::double = atanh (x+:0);
-
/* Complex arithmetic. */
-(x+:y) = -x +: -y;
@@ -319,9 +307,6 @@
(r1<:t1)^x2 = r1^x2 <: t1*x2;
x1^z2@(r2<:t2) = (x1<:0) ^ z2;
-// Complex powers of negative reals.
-x1::double^x2::double = exp (ln x1*x2) if x1<0;
-
/* Equality. */
(x1+:y1) == (x2+:y2) = x1==x2 && y1==y2;
Modified: pure/trunk/lib/primitives.pure
===================================================================
--- pure/trunk/lib/primitives.pure 2008-08-22 16:34:32 UTC (rev 574)
+++ pure/trunk/lib/primitives.pure 2008-08-22 20:24:48 UTC (rev 575)
@@ -350,13 +350,11 @@
pow x::bigint y::int = bigint_pow x y if y>=0;
/* The ^ operator. Computes inexact powers for any combination of int, bigint
- and double operands. The result is always a double. Note that x may be
- negative only if y is integer, but see math.pure which deals with the
- general case x<0 using complex numbers. */
+ and double operands. The result is always a double. */
extern double pow(double, double) = c_pow;
-x::double^y::double = c_pow x y if x>=0 || frac y==0.0 || nanp x || nanp y;
+x::double^y::double = c_pow x y;
x::int^y::int |
x::bigint^y::bigint |
x::int^y::bigint |
@@ -364,8 +362,7 @@
x::double^y::int |
x::double^y::bigint = c_pow x (double y);
x::int^y::double |
-x::bigint^y::double = c_pow (double x) y if x>=0 || frac y==0.0 || nanp y;
- = double x^y otherwise;
+x::bigint^y::double = c_pow (double x) y;
/* Pointer arithmetic. We do this using bigints, so that the code is portable
to 64 bit systems. */
Modified: pure/trunk/test/test020.log
===================================================================
--- pure/trunk/test/test020.log 2008-08-22 16:34:32 UTC (rev 574)
+++ pure/trunk/test/test020.log 2008-08-22 20:24:48 UTC (rev 575)
@@ -184,13 +184,13 @@
}
*** UNARY ***
sqrt,1,1.00
-sqrt,-1,0.00+:1.00
+sqrt,-1,nan
sqrt,0,0.00
sqrt,0.00,0.00
sqrt,1.20,1.10
-sqrt,-1.20,0.00+:1.10
+sqrt,-1.20,nan
sqrt,1L%3L,0.577
-sqrt,(-1L)%4L,0.00+:0.500
+sqrt,(-1L)%4L,nan
sqrt,1+:2,1.27+:0.786
sqrt,-1+:2,0.786+:1.27
sqrt,1+:-2,1.27+:0.786
@@ -204,7 +204,7 @@
sqrt,3.10<:2.50,1.76<:1.25
sqrt,2L%3L<:2,0.816<:1.00
sqrt,1L%2L<:3L%4L,0.707<:0.375
-sqrt,-inf,0.00+:inf
+sqrt,-inf,nan
sqrt,nan,nan
sin,1,0.841
sin,-1,-0.841
@@ -276,13 +276,13 @@
tan,-inf,nan
tan,nan,nan
ln,1,0.00
-ln,-1,0.00+:3.14
+ln,-1,nan
ln,0,-inf
ln,0.00,-inf
ln,1.20,0.182
-ln,-1.20,0.182+:3.14
+ln,-1.20,nan
ln,1L%3L,-1.10
-ln,(-1L)%4L,-1.39+:3.14
+ln,(-1L)%4L,nan
ln,1+:2,0.805+:1.11
ln,-1+:2,0.805+:2.03
ln,1+:-2,0.805+:-1.11
@@ -296,16 +296,16 @@
ln,3.10<:2.50,2.74<:1.15
ln,2L%3L<:2,2.04<:1.77
ln,1L%2L<:3L%4L,1.02<:2.32
-ln,-inf,inf+:3.14
+ln,-inf,nan
ln,nan,nan
log,1,0.00
-log,-1,0.00+:1.36
+log,-1,nan
log,0,-inf
log,0.00,-inf
log,1.20,0.0792
-log,-1.20,0.0792+:1.36
+log,-1.20,nan
log,1L%3L,-0.477
-log,(-1L)%4L,-0.602+:1.36
+log,(-1L)%4L,nan
log,1+:2,0.349+:0.481
log,-1+:2,0.349+:0.884
log,1+:-2,0.349+:-0.481
@@ -319,7 +319,7 @@
log,3.10<:2.50,1.19<:1.15
log,2L%3L<:2,0.886<:1.77
log,1L%2L<:3L%4L,0.444<:2.32
-log,-inf,inf+:1.36
+log,-inf,nan
log,nan,nan
exp,1,2.72
exp,-1,0.368
@@ -506,13 +506,13 @@
asinh,-inf,-inf
asinh,nan,nan
acosh,1,0.00
-acosh,-1,0.00+:3.14
-acosh,0,0.00+:1.57
-acosh,0.00,0.00+:1.57
+acosh,-1,nan
+acosh,0,nan
+acosh,0.00,nan
acosh,1.20,0.622
-acosh,-1.20,-0.622+:3.14
-acosh,1L%3L,0.00+:1.23
-acosh,(-1L)%4L,0.00+:1.82
+acosh,-1.20,nan
+acosh,1L%3L,nan
+acosh,(-1L)%4L,nan
acosh,1+:2,1.53+:1.14
acosh,-1+:2,1.43+:1.59
acosh,1+:-2,0.653+:0.103
@@ -526,14 +526,14 @@
acosh,3.10<:2.50,1.34+:1.60
acosh,2L%3L<:2,0.563+:1.65
acosh,1L%2L<:3L%4L,0.355+:1.22
-acosh,-inf,nan+:nan
+acosh,-inf,nan
acosh,nan,nan
atanh,1,inf
atanh,-1,-inf
atanh,0,0.00
atanh,0.00,0.00
-atanh,1.20,1.20+:-1.57
-atanh,-1.20,-1.20+:1.57
+atanh,1.20,nan
+atanh,-1.20,nan
atanh,1L%3L,0.347
atanh,(-1L)%4L,-0.255
atanh,1+:2,0.173+:1.18
@@ -549,7 +549,7 @@
atanh,3.10<:2.50,-0.254+:1.37
atanh,2L%3L<:2,-0.202+:0.571
atanh,1L%2L<:3L%4L,0.335+:0.369
-atanh,-inf,nan+:nan
+atanh,-inf,nan
atanh,nan,nan
abs,1,1
abs,-1,1
@@ -3155,10 +3155,10 @@
(^),-1,-1,-1.00
(^),-1,0,1.00
(^),-1,0.00,1.00
-(^),-1,1.20,-0.809+:-0.588
-(^),-1,-1.20,-0.809+:0.588
-(^),-1,1L%3L,0.500+:0.866
-(^),-1,(-1L)%4L,0.707+:-0.707
+(^),-1,1.20,nan
+(^),-1,-1.20,nan
+(^),-1,1L%3L,nan
+(^),-1,(-1L)%4L,nan
(^),-1,1+:2,-0.00187+:2.29e-19
(^),-1,-1+:2,-0.00187+:-2.29e-19
(^),-1,1+:-2,-535.+:6.56e-14
@@ -3172,7 +3172,7 @@
(^),-1,3.10<:2.50,0.000152+:-0.00294
(^),-1,2L%3L<:2,0.0958+:-0.114
(^),-1,1L%2L<:3L%4L,0.140+:0.313
-(^),-1,-inf,nan+:nan
+(^),-1,-inf,1.00
(^),-1,nan,nan
(^),0,1,0.00
(^),0,-1,inf
@@ -3247,10 +3247,10 @@
(^),-1.20,-1,-0.833
(^),-1.20,0,1.00
(^),-1.20,0.00,1.00
-(^),-1.20,1.20,-1.01+:-0.732
-(^),-1.20,-1.20,-0.650+:0.472
-(^),-1.20,1L%3L,0.531+:0.920
-(^),-1.20,(-1L)%4L,0.676+:-0.676
+(^),-1.20,1.20,nan
+(^),-1.20,-1.20,nan
+(^),-1.20,1L%3L,nan
+(^),-1.20,(-1L)%4L,nan
(^),-1.20,1+:2,-0.00209+:-0.000799
(^),-1.20,-1+:2,-0.00145+:-0.000555
(^),-1.20,1+:-2,-600.+:229.
@@ -3264,7 +3264,7 @@
(^),-1.20,3.10<:2.50,0.000711+:-0.00173
(^),-1.20,2L%3L<:2,0.103+:-0.0976
(^),-1.20,1L%2L<:3L%4L,0.129+:0.343
-(^),-1.20,-inf,nan+:nan
+(^),-1.20,-inf,0.00
(^),-1.20,nan,nan
(^),1L%3L,1,0.333
(^),1L%3L,-1,3.00
@@ -3293,10 +3293,10 @@
(^),(-1L)%4L,-1,-4.00
(^),(-1L)%4L,0,1.00
(^),(-1L)%4L,0.00,1.00
-(^),(-1L)%4L,1.20,-0.153+:-0.111
-(^),(-1L)%4L,-1.20,-4.27+:3.10
-(^),(-1L)%4L,1L%3L,0.315+:0.546
-(^),(-1L)%4L,(-1L)%4L,1.00+:-1.00
+(^),(-1L)%4L,1.20,nan
+(^),(-1L)%4L,-1.20,nan
+(^),(-1L)%4L,1L%3L,nan
+(^),(-1L)%4L,(-1L)%4L,nan
(^),(-1L)%4L,1+:2,0.000435+:0.000168
(^),(-1L)%4L,-1+:2,0.00697+:0.00269
(^),(-1L)%4L,1+:-2,125.+:-48.3
@@ -3310,7 +3310,7 @@
(^),(-1L)%4L,3.10<:2.50,-0.0536+:0.0748
(^),(-1L)%4L,2L%3L<:2,-0.0308+:-0.217
(^),(-1L)%4L,1L%2L<:3L%4L,0.161+:0.129
-(^),(-1L)%4L,-inf,nan+:nan
+(^),(-1L)%4L,-inf,inf
(^),(-1L)%4L,nan,nan
(^),1+:2,1,1.00+:2.00
(^),1+:2,-1,0.200+:-0.400
@@ -3615,10 +3615,10 @@
(^),-inf,-1,-0.00
(^),-inf,0,1.00
(^),-inf,0.00,1.00
-(^),-inf,1.20,-inf+:-inf
-(^),-inf,-1.20,-0.00+:0.00
-(^),-inf,1L%3L,inf+:inf
-(^),-inf,(-1L)%4L,0.00+:-0.00
+(^),-inf,1.20,inf
+(^),-inf,-1.20,0.00
+(^),-inf,1L%3L,inf
+(^),-inf,(-1L)%4L,0.00
(^),-inf,1+:2,nan+:nan
(^),-inf,-1+:2,nan+:nan
(^),-inf,1+:-2,nan+:nan
@@ -3632,7 +3632,7 @@
(^),-inf,3.10<:2.50,nan+:nan
(^),-inf,2L%3L<:2,nan+:nan
(^),-inf,1L%2L<:3L%4L,nan+:nan
-(^),-inf,-inf,nan+:nan
+(^),-inf,-inf,0.00
(^),-inf,nan,nan
(^),nan,1,nan
(^),nan,-1,nan
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|