Skip to content

Commit 129703a

Browse files
committed
Better dependencies in Distributions
1 parent 39a3c1d commit 129703a

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

src/BaselineOfPolyMath/BaselineOfPolyMath.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BaselineOfPolyMath >> baseline: spec [
4545
package: 'Math-Complex'
4646
with: [ spec requires: #('Math-Numerical' 'Math-Polynomials') ];
4747
package: 'Math-Helpers';
48-
package: 'Math-Distributions' with: [ spec requires: #('PolyMathDataStructures' 'Math-Quantile') ];
48+
package: 'Math-Distributions' with: [ spec requires: #('PolyMathDataStructures' 'Math-Quantile' 'Math-Core-Process') ];
4949
package: 'Math-Core-Process' with: [ spec requires: #('Math-Helpers') ];
5050
package: 'Math-Numerical' with: [ spec requires: #('PolyMathDataStructures' 'Math-Helpers' 'Math-Core-Process' 'Math-Distributions' 'Math-StatisticalMoments' 'Math-Series') ];
5151
package: 'Math-Polynomials' with: [ spec requires: #('PolyMathDataStructures' 'Math-Helpers' 'Math-Core-Process' 'Math-Distributions' 'Math-StatisticalMoments' 'Math-Series') ];

src/Math-Distributions/PMTrapezeIntegrator.class.st

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ A PMTrapezeIntegrator is the base class for integration methods. You should not
55
"
66
Class {
77
#name : #PMTrapezeIntegrator,
8-
#superclass : #PMFunctionalIterator,
8+
#superclass : #PMIterativeProcess,
99
#instVars : [
10+
'functionBlock',
1011
'from',
1112
'to',
1213
'sum',
@@ -28,9 +29,10 @@ PMTrapezeIntegrator class >> function: aBlock from: aNumber1 to: aNumber2 [
2829

2930
{ #category : #operation }
3031
PMTrapezeIntegrator >> computeInitialValues [
31-
"Private"
32+
"Private"
33+
3234
step := to - from.
33-
sum := ( ( functionBlock value: from) + ( functionBlock value: to)) * step /2.
35+
sum := (functionBlock value: from) + (functionBlock value: to) * step / 2.
3436
result := sum
3537
]
3638

@@ -69,3 +71,24 @@ PMTrapezeIntegrator >> initialize: aBlock from: aNumber1 to: aNumber2 [
6971
functionBlock := aBlock.
7072
self from: aNumber1 to: aNumber2
7173
]
74+
75+
{ #category : #initialization }
76+
PMTrapezeIntegrator >> initializeIterations [
77+
"If no initial value has been defined, take 0 as the starting point (for lack of anything better)."
78+
79+
super initializeIterations.
80+
functionBlock ifNil: [ self error: 'No function supplied' ].
81+
self computeInitialValues
82+
]
83+
84+
{ #category : #information }
85+
PMTrapezeIntegrator >> relativePrecision: aNumber [
86+
87+
^ self precisionOf: aNumber relativeTo: result abs
88+
]
89+
90+
{ #category : #initialization }
91+
PMTrapezeIntegrator >> setFunction: aBlock [
92+
93+
functionBlock := aBlock
94+
]

src/Math-Numerical/PMFunctionalIterator.class.st

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ PMFunctionalIterator >> computeInitialValues [
3636
{ #category : #operation }
3737
PMFunctionalIterator >> initializeIterations [
3838
"If no initial value has been defined, take 0 as the starting point (for lack of anything better)."
39-
40-
functionBlock isNil ifTrue: [self error: 'No function supplied'].
39+
super initializeIterations.
40+
functionBlock ifNil: [self error: 'No function supplied'].
4141
self computeInitialValues
4242
]
4343

4444
{ #category : #information }
4545
PMFunctionalIterator >> relativePrecision: aNumber [
46-
^self precisionOf: aNumber relativeTo: result abs
46+
47+
^ self precisionOf: aNumber relativeTo: result abs
4748
]
4849

4950
{ #category : #initialization }
5051
PMFunctionalIterator >> setFunction: aBlock [
51-
( aBlock respondsTo: #value:)
52-
ifFalse:[ self error: 'Function block must implement the method value:'].
52+
5353
functionBlock := aBlock
5454
]

0 commit comments

Comments
 (0)