Skip to content

Commit 40811e8

Browse files
authored
Merge branch 'PolyMathOrg:master' into least-squares
2 parents b925816 + 7c07cd5 commit 40811e8

File tree

68 files changed

+1780
-1439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1780
-1439
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
*This file is currently not complete but will be improve step by step.*
44

5-
You need to download Pharo 8.0 first.
5+
You need to download Pharo 9.0 or 10 first.
66

77
## Setup Iceberg
88
You need an ssh key in order to commit on github. Open Iceberg tool, and then click on the settings. Check the box : "Use custom SSH keys".
@@ -14,7 +14,7 @@ All changes you'll do will be versionned in your own fork of the [PolyMath repos
1414
Go to PolyMath github's repository and click on the fork button on the top right. Yes, this means that you'll need a github account to contribute to PolyMath.
1515

1616
## Load last dev version of PolyMath
17-
In a fresh Pharo 8.0 image, load last development version of Polymath :
17+
In a fresh Pharo 9.0 or 10 image, load last development version of Polymath :
1818

1919
```Smalltalk
2020
Metacello new

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
<img width="1675" alt="Screenshot 2019-04-24 at 11 12 57" src="https://user-images.githubusercontent.com/327334/56652094-66eb7780-6682-11e9-9753-101be18df67c.png">
2222

2323

24-
You can load PolyMath 1.0.3 into a fresh Pharo 9.0 or 10 image with:
24+
You can load PolyMath 1.0.4 into a fresh Pharo 9.0 or 10 image with:
2525

2626
```Smalltalk
2727
Metacello new
28-
repository: 'github://PolyMathOrg/PolyMath:v1.0.3';
28+
repository: 'github://PolyMathOrg/PolyMath:v1.0.4';
2929
baseline: 'PolyMath';
3030
load
3131
```
@@ -39,7 +39,7 @@ Metacello new
3939
load
4040
```
4141

42-
We have **872** green tests ! At the moment, all the development happens in the master branch (we are using [trunk-based development](https://trunkbaseddevelopment.com/)).
42+
We have **900** green tests ! At the moment, all the development happens in the master branch (we are using [trunk-based development](https://trunkbaseddevelopment.com/)).
4343

4444
PolyMath is a Pharo project, similar to existing scientific libraries like NumPy, SciPy for Python or SciRuby for Ruby. PolyMath already provides the following basic functionalities:
4545
- complex and quaternions extensions,

src/Math-AutomaticDifferenciation/PMDualNumber.class.st

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,19 @@ PMDualNumber >> asInteger [
133133
^ value asInteger
134134
]
135135

136+
{ #category : #comparing }
137+
PMDualNumber >> closeTo: aDualNumber [
138+
139+
^ (value closeTo: aDualNumber value) and: [
140+
eps closeTo: aDualNumber eps ]
141+
]
142+
136143
{ #category : #'mathematical functions' }
137144
PMDualNumber >> conjugated [
145+
138146
^ self class
139-
value: self value conjugated
140-
eps: self eps asComplex complexConjugate
147+
value: self value complexConjugate
148+
eps: self eps asComplex complexConjugate
141149
]
142150

143151
{ #category : #'mathematical functions' }
@@ -157,7 +165,12 @@ PMDualNumber >> eps: aNumber [
157165

158166
{ #category : #comparing }
159167
PMDualNumber >> equalsTo: aDualNumber [
160-
^ (value equalsTo: aDualNumber value) and: [ eps equalsTo: aDualNumber eps ]
168+
169+
self
170+
deprecated: 'Use closeTo: instead'
171+
transformWith: '`@rec equalsTo: `@arg' -> '`@rec closeTo: `@arg'.
172+
173+
^ self closeTo: aDualNumber
161174
]
162175

163176
{ #category : #testing }

src/Math-AutomaticDifferenciation/PMHyperDualNumber.class.st

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ PMHyperDualNumber >> arcTan [
9696
yourself
9797
]
9898

99+
{ #category : #comparing }
100+
PMHyperDualNumber >> closeTo: aHyperDualNumber [
101+
102+
^ (super closeTo: aHyperDualNumber) and: [
103+
(eps2 closeTo: aHyperDualNumber eps2) and: [
104+
eps1eps2 closeTo: aHyperDualNumber eps1eps2 ] ]
105+
]
106+
99107
{ #category : #'mathematical functions' }
100108
PMHyperDualNumber >> cos [
101109
^ super cos
@@ -126,9 +134,12 @@ PMHyperDualNumber >> eps2: anEps2 [
126134

127135
{ #category : #comparing }
128136
PMHyperDualNumber >> equalsTo: aHyperDualNumber [
129-
^ (super equalsTo: aHyperDualNumber)
130-
and: [ (eps2 equalsTo: aHyperDualNumber eps2)
131-
and: [ eps1eps2 equalsTo: aHyperDualNumber eps1eps2 ] ]
137+
138+
self
139+
deprecated: 'Use closeTo: instead'
140+
transformWith: '`@rec equalsTo: `@arg' -> '`@rec closeTo: `@arg'.
141+
142+
^ self closeTo: aHyperDualNumber
132143
]
133144

134145
{ #category : #'mathematical functions' }

src/Math-Chromosome/PMChromosomeManager.class.st

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Class {
55
'population',
66
'populationSize',
77
'rateOfMutation',
8-
'rateOfCrossover'
8+
'rateOfCrossover',
9+
'randomNumberGenerator'
910
],
10-
#category : 'Math-Chromosome'
11+
#category : #'Math-Chromosome'
1112
}
1213

1314
{ #category : #creation }
@@ -28,6 +29,12 @@ PMChromosomeManager >> crossover: aChromosome1 and: aChromosome2 [
2829
^self subclassResponsibility
2930
]
3031

32+
{ #category : #initialization }
33+
PMChromosomeManager >> initialize [
34+
super initialize.
35+
randomNumberGenerator := Random new.
36+
]
37+
3138
{ #category : #information }
3239
PMChromosomeManager >> isFullyPopulated [
3340

@@ -56,7 +63,7 @@ PMChromosomeManager >> populationSize: anInteger [
5663
PMChromosomeManager >> process: aChromosome1 and: aChromosome2 [
5764

5865
| roll |
59-
roll := Number random.
66+
roll := randomNumberGenerator next.
6067
roll < rateOfCrossover
6168
ifTrue: [population addAll: (self crossover: aChromosome1 and: aChromosome2)]
6269
ifFalse:

src/Math-Chromosome/PMVectorChromosomeManager.class.st

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@ Class {
55
'origin',
66
'range'
77
],
8-
#category : 'Math-Chromosome'
8+
#category : #'Math-Chromosome'
99
}
1010

1111
{ #category : #operation }
1212
PMVectorChromosomeManager >> crossover: aChromosome1 and: aChromosome2 [
1313

14-
| index new1 new2|
15-
index := ( aChromosome1 size - 1) random + 2.
14+
| index new1 new2 |
15+
16+
index := randomNumberGenerator nextIntegerBetween: 2 and: aChromosome1 size.
17+
1618
new1 := self clone: aChromosome1.
1719
new1 replaceFrom: index to: new1 size with: aChromosome2 startingAt: index.
20+
1821
new2 := self clone: aChromosome2.
1922
new2 replaceFrom: index to: new2 size with: aChromosome1 startingAt: index.
20-
^Array with: new1 with: new2
23+
24+
^ Array with: new1 with: new2
2125
]
2226

2327
{ #category : #operation }
2428
PMVectorChromosomeManager >> mutate: aVector [
2529

2630
| index |
27-
index := aVector size random + 1.
31+
index := randomNumberGenerator nextIntegerBetween: 1 and: aVector size.
32+
2833
^( aVector copy)
29-
at: index put: ( self randomComponent: index);
34+
at: index put: (self randomComponent: index);
3035
yourself
3136
]
3237

@@ -39,13 +44,13 @@ PMVectorChromosomeManager >> origin: aVector [
3944
{ #category : #creation }
4045
PMVectorChromosomeManager >> randomChromosome [
4146

42-
^( ( 1 to: origin size) collect: [ :n | self randomComponent: n]) asPMVector
47+
^ ((1 to: origin size) collect: [ :n | self randomComponent: n ]) asPMVector
4348
]
4449

4550
{ #category : #information }
4651
PMVectorChromosomeManager >> randomComponent: anInteger [
4752

48-
^( range at: anInteger) asFloat random + ( origin at: anInteger)
53+
^ (randomNumberGenerator nextBetween: 0 and: (range at: anInteger)) + (origin at: anInteger)
4954
]
5055

5156
{ #category : #initialization }

src/Math-Complex/Number.extension.st

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Number >> adaptToComplex: rcvr andSend: selector [
1010
Number >> asComplex [
1111
"Answer a Complex number that represents value of the receiver."
1212

13-
^ PMComplex real: self imaginary: 0
13+
^ PMComplexNumber real: self imaginary: 0
1414
]
1515

1616
{ #category : #'*Math-Complex' }
@@ -25,7 +25,7 @@ Number >> complexConjugate [
2525

2626
{ #category : #'*Math-Complex' }
2727
Number >> i [
28-
^ PMComplex real: 0 imaginary: self
28+
^ PMComplexNumber real: 0 imaginary: self
2929
]
3030

3131
{ #category : #'*Math-Complex' }
@@ -36,7 +36,7 @@ Number >> i: aNumber [
3636
this is the same as (self + aNumber i) but a little bit more efficient."
3737

3838
aNumber isNumber ifFalse: [self error: 'Badly formed complex number'].
39-
^PMComplex real: self imaginary: aNumber
39+
^PMComplexNumber real: self imaginary: aNumber
4040
]
4141

4242
{ #category : #'*Math-Complex' }

0 commit comments

Comments
 (0)