Changes to Trunk (http://source.squeak.org/trunk.html) in the last 24 hours:
http://lists.squeakfoundation.org/pipermail/packages/2011-November/005056.h…
Name: Kernel-nice.647
Ancestors: Kernel-nice.646
Optimize #ln and #log as in Pharo.
1) SmallInteger just inherits from super (^self asFloat log)
2) LargePositiveInteger can avoid self > à guard
3) LargeNegativeInteger can goto Error (no raise, just kidding)
4) Fraction can avoid arithmetic because (a/b) log = (a log - b log) and because a log or b log are unlikely to overflow - (10 raisedTo: (10 raisedTo: 308)) is likely to exhaust your memory before any overflow occurs ;).
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-November/005057.h…
Name: KernelTests-nice.209
Ancestors: KernelTests-nice.208
Restore the intention of testNaN2 which is to test both = and == (there can be several instances of NaN)
Complete the ScaledDecimalTest (from Pharo) and correct intention (test absolute value of difference).
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-November/005058.h…
Name: Kernel-eem.648
Ancestors: Kernel-nice.647
First part of changes to restore protection against infinite
recursion on printing circular array literals.
=============================================
http://lists.squeakfoundation.org/pipermail/packages/2011-November/005059.h…
Name: Collections-eem.464
Ancestors: Collections-ul.463
Second part of changes to restore protection against infinite
recursion on printing circular array literals. Add a visited set
to Array>shouldBePrintedAsLiteral => shouldBePrintedAsLiteralVisiting:.
=============================================
Eliot Miranda uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-eem.464.mcz
==================== Summary ====================
Name: Collections-eem.464
Author: eem
Time: 2 November 2011, 1:08:39.649 pm
UUID: 0984ea11-ef0f-40e0-9de1-aea54055ef85
Ancestors: Collections-ul.463
Second part of changes to restore protection against infinite
recursion on printing circular array literals. Add a visited set
to Array>shouldBePrintedAsLiteral => shouldBePrintedAsLiteralVisiting:.
=============== Diff against Collections-ul.463 ===============
Item was changed:
----- Method: Array>>shouldBePrintedAsLiteral (in category 'testing') -----
shouldBePrintedAsLiteral
+ ^self class == Array
+ and: [self shouldBePrintedAsLiteralVisiting: (IdentitySet new: 8)]!
- ^self class == Array and: [ self allSatisfy: [ :each | each shouldBePrintedAsLiteral ] ]!
Item was added:
+ ----- Method: Array>>shouldBePrintedAsLiteralVisiting: (in category 'testing') -----
+ shouldBePrintedAsLiteralVisiting: aSet
+ self class == Array ifFalse:
+ [^false].
+ (aSet includes: self) ifTrue:
+ [^false].
+ aSet add: self.
+ ^self allSatisfy: [:each | each shouldBePrintedAsLiteralVisiting: aSet]!
Item was added:
+ ----- Method: Character>>shouldBePrintedAsLiteralVisiting: (in category 'testing') -----
+ shouldBePrintedAsLiteralVisiting: aSet
+
+ ^self shouldBePrintedAsLiteral!
Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.648.mcz
==================== Summary ====================
Name: Kernel-eem.648
Author: eem
Time: 2 November 2011, 12:58:59.757 pm
UUID: c3ee000c-6816-4eff-9f24-4ddc497c4171
Ancestors: Kernel-nice.647
First part of changes to restore protection against infinite
recursion on printing circular array literals.
=============== Diff against Kernel-nice.647 ===============
Item was added:
+ ----- Method: Object>>shouldBePrintedAsLiteralVisiting: (in category 'testing') -----
+ shouldBePrintedAsLiteralVisiting: aSet
+
+ ^self isLiteral!
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.209.mcz
==================== Summary ====================
Name: KernelTests-nice.209
Author: nice
Time: 2 November 2011, 8:12:16.968 pm
UUID: 91e9e8ee-ff2b-4cce-8df3-ff2d1ade58ea
Ancestors: KernelTests-nice.208
Restore the intention of testNaN2 which is to test both = and == (there can be several instances of NaN)
Complete the ScaledDecimalTest (from Pharo) and correct intention (test absolute value of difference).
=============== Diff against KernelTests-nice.208 ===============
Item was changed:
----- Method: FloatTest>>testNaN2 (in category 'NaN behavior') -----
testNaN2
"Two NaN values are always considered to be different.
On an little-endian machine (32 bit Intel), Float nan is 16rFFF80000 16r00000000.
On a big-endian machine (PowerPC), Float nan is 16r7FF80000 16r00000000. Changing
the bit pattern of the first word of a NaN produces another value that is still
considered equal to NaN. This test should work on both little endian and big
endian machines. However, it is not guaranteed to work on future 64 bit versions
of Squeak, for which Float may have different internal representations."
"FloatTest new testNaN2"
| nan1 nan2 |
nan1 := Float nan copy.
nan2 := Float nan copy.
"test two instances of NaN with the same bit pattern"
self deny: nan1 = nan2.
+ self deny: nan1 == nan2.
- self deny: nan1 = nan2.
self deny: nan1 = nan1.
self assert: nan1 == nan1.
"change the bit pattern of nan1"
self assert: nan1 size = 2.
self assert: (nan1 at: 2) = 0.
nan1 at: 1 put: (nan1 at: 1) + 999.
self assert: nan1 isNaN.
self assert: nan2 isNaN.
self deny: (nan1 at: 1) = (nan2 at: 1).
"test two instances of NaN with different bit patterns"
self deny: nan1 = nan2.
+ self deny: nan1 == nan2.
- self deny: nan1 = nan2.
self deny: nan1 = nan1.
self assert: nan1 == nan1
!
Item was changed:
----- Method: ScaledDecimalTest>>testConvertFromFloat (in category 'tests') -----
testConvertFromFloat
| aFloat sd f2 diff |
aFloat := 11/13 asFloat.
sd := aFloat asScaledDecimal: 2.
self assert: 2 = sd scale.
self assert: '0.84s2' = sd printString.
+ self assert: '-0.84s2' = sd negated printString.
f2 := sd asFloat.
diff := f2 - aFloat.
+ self assert: diff abs < 1.0e-9. "actually, f = f2, but this is not a requirement"
- self assert: diff < 1.0e-9. "actually, f = f2, but this is not a requirement"
!
Item was changed:
----- Method: ScaledDecimalTest>>testConvertFromFractionWithScale (in category 'tests') -----
testConvertFromFractionWithScale
| sd |
sd := (13 / 11) asScaledDecimal: 6.
self assert: ScaledDecimal == sd class.
self assert: ('1.181818s6' = sd printString).
+ self assert: 6 = sd scale.
+ sd := (-13 / 11) asScaledDecimal: 6.
+ self assert: ScaledDecimal == sd class.
+ self assert: ('-1.181818s6' = sd printString).
self assert: 6 = sd scale
!
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.647.mcz
==================== Summary ====================
Name: Kernel-nice.647
Author: nice
Time: 2 November 2011, 7:50:14.247 pm
UUID: 68374059-00c3-4605-bfb3-615f3793071a
Ancestors: Kernel-nice.646
Optimize #ln and #log as in Pharo.
1) SmallInteger just inherits from super (^self asFloat log)
2) LargePositiveInteger can avoid self > à guard
3) LargeNegativeInteger can goto Error (no raise, just kidding)
4) Fraction can avoid arithmetic because (a/b) log = (a log - b log) and because a log or b log are unlikely to overflow - (10 raisedTo: (10 raisedTo: 308)) is likely to exhaust your memory before any overflow occurs ;).
=============== Diff against Kernel-nice.646 ===============
Item was changed:
----- Method: Fraction>>ln (in category 'mathematical functions') -----
ln
+ "This function is defined because super ln might overflow."
+ | res |
- "This function is defined because super ln might overflow.
- Note that < 1 is tested before converting to float in order to avoid precision loss due to gradual underflow."
- | res int |
self <= 0 ifTrue: [DomainError signal: 'ln is only defined for x > 0'].
+ "Test self < 1 before converting to float in order to avoid precision loss due to gradual underflow."
+ numerator < denominator ifTrue: [^self reciprocal ln negated].
- self < 1 ifTrue: [^self reciprocal ln negated].
res := super ln.
res isFinite ifTrue: [^res].
+ ^numerator ln - denominator ln!
- int := self integerPart.
- ^int ln + (self / int) ln!
Item was changed:
----- Method: Fraction>>log (in category 'mathematical functions') -----
log
+ "This function is defined because super log might overflow."
+ | res |
- "This function is defined because super log might overflow.
- Note that < 1 is tested before converting to float in order to avoid precision loss due to gradual underflow."
- | res int |
self <= 0 ifTrue: [DomainError signal: 'log is only defined for x > 0'].
+ "Test self < 1 before converting to float in order to avoid precision loss due to gradual underflow."
+ numerator < denominator ifTrue: [^self reciprocal log negated].
- self < 1 ifTrue: [^self reciprocal log negated].
res := super log.
res isFinite ifTrue: [^res].
+ ^numerator log - denominator log!
- int := self integerPart.
- ^int log + (self / int) log!
Item was removed:
- ----- Method: Integer>>ln (in category 'mathematical functions') -----
- ln
- "This function is defined because super ln might overflow."
- | res h |
- self <= 0 ifTrue: [DomainError signal: 'ln is only defined for x > 0'].
- res := super ln.
- res isFinite ifTrue: [^res].
- h := self highBit.
- ^2 ln * h + (self / (1 << h)) asFloat ln!
Item was removed:
- ----- Method: Integer>>log (in category 'mathematical functions') -----
- log
- "This function is defined because super log might overflow."
- | res h |
- self <= 0 ifTrue: [DomainError signal: 'log is only defined for x > 0'].
- res := super log.
- res isFinite ifTrue: [^res].
- h := self highBit.
- ^2 log * h + (self / (1 << h)) asFloat log!
Item was added:
+ ----- Method: LargeNegativeInteger>>ln (in category 'mathematical functions') -----
+ ln
+ ^DomainError signal: 'ln is only defined for x > 0' from: 0!
Item was added:
+ ----- Method: LargeNegativeInteger>>log (in category 'mathematical functions') -----
+ log
+ ^DomainError signal: 'log is only defined for x > 0' from: 0!
Item was added:
+ ----- Method: LargePositiveInteger>>ln (in category 'mathematical functions') -----
+ ln
+ "This function is defined because super ln might overflow."
+ | res h |
+ res := super ln.
+ res isFinite ifTrue: [^res].
+ h := self highBit.
+ ^2 ln * h + (self / (1 << h)) asFloat ln!
Item was added:
+ ----- Method: LargePositiveInteger>>log (in category 'mathematical functions') -----
+ log
+ "This function is defined because super log might overflow."
+ | res h |
+ res := super log.
+ res isFinite ifTrue: [^res].
+ h := self highBit.
+ ^2 log * h + (self / (1 << h)) asFloat log!