[pure-lang-svn] SF.net SVN: pure-lang:[532] pure/trunk/lib/math.pure
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-08-18 17:30:50
|
Revision: 532 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=532&view=rev Author: agraef Date: 2008-08-18 17:30:58 +0000 (Mon, 18 Aug 2008) Log Message: ----------- Fix glitch in complex sqrt, reported by Eddie Rucker. Modified Paths: -------------- pure/trunk/lib/math.pure Modified: pure/trunk/lib/math.pure =================================================================== --- pure/trunk/lib/math.pure 2008-08-18 11:47:30 UTC (rev 531) +++ pure/trunk/lib/math.pure 2008-08-18 17:30:58 UTC (rev 532) @@ -32,7 +32,7 @@ extern double sqrt(double) = c_sqrt; -sqrt x::double = c_sqrt x if x>=0; +sqrt x::double = c_sqrt x if x>=0; sqrt x::int | sqrt x::bigint = sqrt (double x); /* Exponential function and logarithms. */ @@ -185,7 +185,8 @@ /* Complex sqrt. */ -sqrt (x+:y) = sqrt (x*x+y*y) * (cos (t/2) +: sin (t/2)); +sqrt (x+:y) = sqrt r * (cos t +: sin t) + when r = sqrt (x*x+y*y); t = atan2 y x/2 end; sqrt (r<:t) = sqrt r <: t/2; // Complex square roots of negative reals. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |