[squeakdev] The Trunk: Kernelnice.1460.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun Apr 24 14:41:03 UTC 2022
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernelnice.1460.mcz
==================== Summary ====================
Name: Kernelnice.1460
Author: nice
Time: 24 April 2022, 4:40:46.56674 pm
UUID: c06981bc7eba4a8ea388658d43b49ec8
Ancestors: Kernelnice.1459
Oups fixup (2 i sqrt), not enough tests...
Sorry for the noise.
=============== Diff against Kernelnice.1459 ===============
Item was changed:
 Method: Complex>>sqrt (in category 'mathematical functions') 
sqrt
+ "Return the square root of the receiver with a positive real part.
+ This is the same as (Complex abs: self abs sqrt arg: self arg / 2).
 "Return the square root of the receiver with a positive imaginary part.
Implementation notes:
the formulation used ensure a protection against floating point overflow/underflow.
it also result in a reasonable precision (around 3 ulp).
It is inspired by following reference, except that it uses prescaling rather than eception handling:
Implementing Complex Elementary Function Using Exception Handling
ACM Transactions on Mathematical Software  October 1994
Ping Tang and 3 other authors"
 x y r s t scale 
real isZero
ifTrue:
+ [t := imaginary abs sqrt / 2 sqrt.
 [t := imaginary abs sqrt.
^self class real: t imaginary: (imaginary copySignTo: t)].
scale := real abs max: imaginary abs.
x := real / scale.
y := imaginary / scale.
r := (x squared + y squared) sqrt.
s := scale sqrt.
t := (r + x abs * 2) sqrt.
^real > 0
ifTrue: [self class real: t * s / 2 imaginary: y * s / t]
ifFalse: [self class real: y abs * s / t imaginary: (y copySignTo: t * s / 2)]!
More information about the Squeakdev
mailing list
