diff --git a/.smalltalk.ston b/.smalltalk.ston
index 7f19c7a1b..32951b60a 100644
--- a/.smalltalk.ston
+++ b/.smalltalk.ston
@@ -7,8 +7,23 @@ SmalltalkCISpec {
}
],
#testing : {
- #categories : [ 'Math-*' ]
+ #coverage : {
+ #packages : [
+ 'Math-Accuracy-ODE',
+ 'Math-ArbitraryPrecisionFloat',
+ 'Math-AutomaticDifferenciation',
+ 'Math-B*',
+ 'Math-C*',
+ 'Math-D*',
+ 'Math-FunctionFit',
+ 'Math-K*',
+ 'Math-M*',
+ 'Math-N*',
+ 'Math-ODE',
+ 'Math-P*',
+ 'Math-Q*',
+ 'Math-R*',
+ 'Math-TNSE' ]
+ }
}
}
-
-
diff --git a/.travis.yml b/.travis.yml
index 70991a2ec..896d023f5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,12 +7,8 @@ os:
smalltalk:
- Pharo-6.1
- - Pharo64-6.1
- - Pharo-7.0
+ - Pharo32-7.0
- Pharo64-7.0
matrix:
fast_finish: true
- allow_failures:
- - smalltalk: Pharo-7.0
- - smalltalk: Pharo64-7.0
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 75457fa84..7c4de85e0 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -15,9 +15,9 @@ In a fresh Pharo 7.0 image, load last development version of Polymath :
```Smalltalk
Metacello new
- githubUser: 'XXX' project: 'PolyMath' commitish: 'development' path: 'src';
- baseline: 'PolyMath';
- load
+ githubUser: 'XXX' project: 'PolyMath' commitish: 'master' path: 'src';
+ baseline: 'PolyMath';
+ load.
```
where you replace XXX with your github user name.
@@ -33,6 +33,8 @@ Ounce your pull request is integrated, some cleanups are required:
- remove your branch from your fork
- close the issue (tips: you can automatically close the issue n, by inserting the sentence: **close #n** when you merge your pull request).
+You will need from time to time to sync your fork with the original repo. You can do it on the command line with: https://help.github.com/articles/syncing-a-fork/ or in the browser like : https://github.com/KirstieJane/STEMMRoleModels/wiki/Syncing-your-fork-to-the-original-repository-via-the-browser You can also kill and redo a fork very easily.
+
# Release management
This project use semantic versionning to define the releases, meaning that each stable release of the project will be assigned a version number of the form `vX.Y.Z`.
@@ -49,11 +51,11 @@ Thus, it should be safe to depend on a fixed major version and moving minor vers
# Branch management
-This project uses gitflow management.
+PolyMath is developed using trunk-based development: https://trunkbaseddevelopment.com/
This project contains two main branches:
-- **master** : This branch is a stable branch. Each version on this branch should be a stable release of PolyMath, and ideally each commit modifying the source code of the project should be tagged with a version number.
-- **development** : This branch contains the current development of this project.
+- **master** : In short, the development branch is the master branch and it always contains the latest version of the projects.
+- **release** : This branch contains the releases of this project.
## Hot fix
diff --git a/README.md b/README.md
index efb045863..e3507e799 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,25 @@
-# PolyMath
+
+
+ Scientific Computing with Pharo
+
+ Explore the docs »
+
+
+ Report a defect
+ |
+ Request feature
+
+
[](http://www.repostatus.org/#active)
[](https://travis-ci.org/PolyMathOrg/PolyMath)
[](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea)
+[](https://coveralls.io/github/PolyMathOrg/PolyMath?branch=development)
[](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE)
-You can load the code in a fresh Pharo 6.1 image with:
+
+
+You can load the code in a fresh Pharo 7.0 image with:
```Smalltalk
Metacello new
@@ -14,19 +28,17 @@ Metacello new
load
```
-We have **767** green tests !
-
-PolyMath is a Smalltalk project, similar to existing scientific libraries like NumPy, SciPy for Python or SciRuby for Ruby. PolyMath already provide the following basic functionalities:
+We have **806** green tests ! At the moment, all the development happens in the development branch.
+
+PolyMath is a Pharo project, similar to existing scientific libraries like NumPy, SciPy for Python or SciRuby for Ruby. PolyMath already provide the following basic functionalities:
- complex and quaternions extensions,
- random number generators,
- fuzzy algorithms,
- KDE-trees,
-- Didier Besset's numerical methods,
+- Numerical methods,
- Ordinary Differential Equation (ODE) solvers.
-[](https://twitter.com/SergeStinckwich/status/457039376111788032)
-
-A book about PolyMath called "Numerical Methods" is available online: https://github.com/SquareBracketAssociates/NumericalMethods/releases/tag/snapshot-2016-01-17
+A book about PolyMath called "PolyMath book" is available online: https://github.com/SquareBracketAssociates/PolyMath-book
Some documentation (to be cleaned and reorganized) about PolyMath is available on the Wiki here:
https://github.com/PolyMathOrg/PolyMath/wiki
@@ -35,7 +47,7 @@ Natalia wrote some explanation about benchmarking PolyMath in the Pharo For Ente
## Install PolyMath
-To install PolyMath on your Pharo image you can just execute the following script:
+To install PolyMath in your Pharo image you can just execute the following script:
```Smalltalk
Metacello new
@@ -52,8 +64,6 @@ To add PolyMath to your baseline just add this:
with: [ spec repository: 'github://PolyMathOrg/PolyMath:master/src' ]
```
-Note that you can replace the #master by another branch as #development or a tag as #v1.0.0, #v1.? or #v1.2.? .
-
## How to contribute to PolyMath
diff --git a/appveyor.yml b/appveyor.yml
index 400219bd2..bce180177 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -6,9 +6,8 @@ environment:
CYG_MIRROR: http://cygwin.mirror.constant.com
SCI_RUN: /cygdrive/c/smalltalkCI-master/run.sh
matrix:
- - SMALLTALK: Pharo-6.1
- SMALLTALK: Pharo-7.0
-
+
platform:
- x86
diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st
index 2e762cc74..57a688763 100644
--- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st
+++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st
@@ -29,67 +29,142 @@ BaselineOfPolyMath >> baseline: spec [
spec
package: 'ExtendedNumberParser';
package: 'Math-Accuracy-Core';
- package: 'Math-Accuracy-ODE' with: [ spec requires: #('Math-ODE' 'XMLWriter') ];
- package: 'Math-ArbitraryPrecisionFloat' with: [ spec requires: #('ExtendedNumberParser') ];
- package: 'Math-AutomaticDifferenciation' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Matrix') ];
- package: 'Math-Benchmarks-KDTree' with: [ spec requires: #('Math-KDTree' 'SMark') ];
- package: 'Math-Benchmarks-ODE' with: [ spec requires: #('Math-ODE' 'SMark' 'XMLWriter') ];
- package: 'Math-Chromosome' with: [ spec requires: #('Math-Core') ];
- package: 'Math-Clustering' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Core-Process' 'Math-Matrix') ];
- package: 'Math-Complex' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Polynomials') ];
+ package: 'Math-Accuracy-ODE'
+ with: [ spec requires: #('Math-ODE' 'XMLWriter') ];
+ package: 'Math-ArbitraryPrecisionFloat'
+ with: [ spec requires: #('ExtendedNumberParser') ];
+ package: 'Math-AutomaticDifferenciation'
+ with: [ spec requires: #('Math-Numerical' 'Math-Matrix') ];
+ package: 'Math-Benchmarks-KDTree'
+ with: [ spec requires: #('Math-KDTree' 'SMark') ];
+ package: 'Math-Benchmarks-ODE'
+ with: [ spec requires: #('Math-ODE' 'SMark' 'XMLWriter') ];
+ package: 'Math-Chromosome'
+ with: [ spec requires: #('Math-Core') ];
+ package: 'Math-Clustering'
+ with:
+ [ spec requires: #('Math-Numerical' 'Math-Core-Process' 'Math-Matrix') ];
+ package: 'Math-Complex'
+ with: [ spec requires: #('Math-Numerical' 'Math-Polynomials') ];
package: 'Math-Core';
- package: 'Math-Core-Distribution' with: [ spec requires: #('Math-Core') ];
+ package: 'Math-Core-Distribution'
+ with: [ spec requires: #('Math-Core') ];
package: 'Math-Core-Process';
- package: 'Math-DHB-Numerical' with: [ spec requires: #('Math-Core' 'Math-Core-Process' 'Math-Core-Distribution' 'Math-DistributionGamma' 'Math-DistributionBeta' 'Math-DistributionForHistogram' 'Math-StatisticalMoments' 'Math-Series') ];
- package: 'Math-Polynomials' with: [ spec requires: #('Math-Core' 'Math-Core-Process' 'Math-Core-Distribution' 'Math-DistributionGamma' 'Math-DistributionBeta' 'Math-DistributionForHistogram' 'Math-StatisticalMoments' 'Math-Series') ];
- package: 'Math-DistributionBeta' with: [ spec requires: #('Math-DistributionGamma') ];
- package: 'Math-DistributionForHistogram' with: [ spec requires: #('Math-Core-Distribution') ];
- package: 'Math-DistributionGamma' with: [ spec requires: #('Math-Core-Distribution') ];
- package: 'Math-FastFourierTransform' with: [ spec requires: #('Math-Complex') ];
- package: 'Math-FunctionFit' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core' 'Math-Core' 'Math-Matrix' 'Math-Polynomials') ];
+ package: 'Math-Numerical'
+ with: [ spec
+ requires:
+ #('Math-Core' 'Math-Core-Process' 'Math-Core-Distribution' 'Math-DistributionGamma' 'Math-DistributionBeta' 'Math-DistributionForHistogram' 'Math-StatisticalMoments' 'Math-Series') ];
+ package: 'Math-Polynomials'
+ with: [ spec
+ requires:
+ #('Math-Core' 'Math-Core-Process' 'Math-Core-Distribution' 'Math-DistributionGamma' 'Math-DistributionBeta' 'Math-DistributionForHistogram' 'Math-StatisticalMoments' 'Math-Series') ];
+ package: 'Math-DistributionBeta'
+ with: [ spec requires: #('Math-DistributionGamma') ];
+ package: 'Math-DistributionForHistogram'
+ with: [ spec requires: #('Math-Core-Distribution') ];
+ package: 'Math-DistributionGamma'
+ with: [ spec requires: #('Math-Core-Distribution') ];
+ package: 'Math-FastFourierTransform'
+ with: [ spec requires: #('Math-Complex') ];
+ package: 'Math-FunctionFit'
+ with: [ spec
+ requires:
+ #('Math-Numerical' 'Math-Chromosome' 'Math-Accuracy-Core' 'Math-Core' 'Math-Matrix' 'Math-Polynomials') ];
package: 'Math-KDTree';
- package: 'Math-KernelSmoothing' with: [ spec requires: #('Math-Quantile' 'Math-DHB-Numerical' 'Math-Polynomials') ];
- package: 'Math-KolmogorovSmirnov' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Polynomials') ];
+ package: 'Math-KernelSmoothing'
+ with: [ spec
+ requires: #('Math-Quantile' 'Math-Numerical' 'Math-Polynomials') ];
+ package: 'Math-KolmogorovSmirnov'
+ with: [ spec requires: #('Math-Numerical' 'Math-Polynomials') ];
package: 'Math-Matrix';
package: 'Math-Number-Extensions';
- package: 'Math-ODE' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Matrix' 'Math-Polynomials') ];
- package: 'Math-Permutation' with:[ spec requires: #('Math-Core' 'Math-Matrix' 'Math-Core-Process') ];
+ package: 'Math-ODE'
+ with:
+ [ spec requires: #('Math-Numerical' 'Math-Matrix' 'Math-Polynomials') ];
+ package: 'Math-Permutation'
+ with: [ spec requires: #('Math-Core' 'Math-Matrix' 'Math-Core-Process') ];
package: 'Math-Physics-Constants';
- package: 'Math-PrincipalComponentAnalysis' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Matrix' 'Math-Polynomials') ];
+ package: 'Math-PrincipalComponentAnalysis'
+ with:
+ [ spec requires: #('Math-Numerical' 'Math-Matrix' 'Math-Polynomials') ];
package: 'Math-Quantile';
- package: 'Math-Quaternion' with: [ spec requires: #('Math-Complex' 'Math-DHB-Numerical' 'Math-Polynomials') ];
+ package: 'Math-Quaternion'
+ with:
+ [ spec requires: #('Math-Complex' 'Math-Numerical' 'Math-Polynomials') ];
package: 'Math-Random';
- package: 'Math-RandomDistributionBased' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Polynomials') ];
package: 'Math-Series';
- package: 'Math-StatisticalMoments' with: [ spec requires: #('Math-Core' 'Math-DistributionForHistogram') ];
+ package: 'Math-StatisticalMoments'
+ with: [ spec requires: #('Math-Core' 'Math-DistributionForHistogram') ];
package: 'Math-TSNE';
- package: 'Math-Tests-Accuracy' with: [ spec requires: #('Math-Accuracy-Core') ];
- package: 'Math-Tests-ArbitraryPrecisionFloat' with: [ spec requires: #('Math-ArbitraryPrecisionFloat') ];
- package: 'Math-Tests-AutomaticDifferenciation' with: [ spec requires: #('Math-AutomaticDifferenciation' 'Math-Matrix') ];
- package: 'Math-Tests-Clustering' with: [ spec requires: #('Math-Clustering' 'Math-Core' 'Math-Core-Distribution' 'Math-UtilsDataServer') ];
- package: 'Math-Tests-Complex' with: [ spec requires: #('Math-Complex') ];
- package: 'Math-Tests-DHB-Numerical' with: [ spec requires: #('Math-DHB-Numerical' 'Math-UtilsDataServer') ];
- package: 'Math-Tests-DHB-wk';
- package: 'Math-Tests-FastFourierTransform' with: [ spec requires: #('Math-FastFourierTransform' 'Math-DHB-Numerical' 'Math-Polynomials') ];
+ package: 'Math-Tests-Accuracy'
+ with: [ spec requires: #('Math-Accuracy-Core') ];
+ package: 'Math-Tests-ArbitraryPrecisionFloat'
+ with: [ spec requires: #('Math-ArbitraryPrecisionFloat') ];
+ package: 'Math-Tests-AutomaticDifferenciation'
+ with: [ spec requires: #('Math-AutomaticDifferenciation' 'Math-Matrix') ];
+ package: 'Math-Tests-Clustering'
+ with: [ spec
+ requires:
+ #('Math-Clustering' 'Math-Core' 'Math-Core-Distribution' 'Math-UtilsDataServer') ];
+ package: 'Math-Tests-Complex'
+ with: [ spec requires: #('Math-Complex') ];
+ package: 'Math-Tests-Core'
+ with: [ spec requires: #('Math-Core') ];
+ package: 'Math-Tests-Core-Process'
+ with: [ spec requires: #('Math-Core-Process') ];
+ package: 'Math-Tests-Numerical'
+ with: [ spec requires: #('Math-Numerical' 'Math-UtilsDataServer') ];
+ package: 'Math-Tests-FastFourierTransform'
+ with: [ spec
+ requires: #('Math-FastFourierTransform' 'Math-Numerical' 'Math-Polynomials') ];
package: 'Math-Tests-FunctionFit';
- package: 'Math-Tests-KDTree' with: [ spec requires: #('Math-KDTree') ];
- package: 'Math-Tests-KolmogorovSmirnov' with: [ spec requires: #('Math-DHB-Numerical' 'Math-KolmogorovSmirnov' 'Math-Polynomials') ];
- package: 'Math-Tests-Matrix' with: [ spec requires: #('Math-Core' 'Math-DHB-Numerical' 'Math-StatisticalMoments' 'Math-Matrix' 'Math-Polynomials') ];
+ package: 'Math-Tests-KDTree'
+ with: [ spec requires: #('Math-KDTree') ];
+ package: 'Math-Tests-KernelSmoothing'
+ with: [ spec requires: #('Math-KernelSmoothing') ];
+ package: 'Math-Tests-KolmogorovSmirnov'
+ with: [ spec
+ requires: #('Math-Numerical' 'Math-KolmogorovSmirnov' 'Math-Polynomials') ];
+ package: 'Math-Tests-Matrix'
+ with: [ spec
+ requires:
+ #('Math-Core' 'Math-Numerical' 'Math-StatisticalMoments' 'Math-Matrix' 'Math-Polynomials') ];
+ package: 'Math-Tests-Number-Extensions'
+ with: [ spec requires: #('Math-Number-Extensions') ];
package: 'Math-Tests-ODE' with: [ spec requires: #('Math-ODE') ];
- package: 'Math-Tests-Quantile' with: [ spec requires: #('Math-Quantile') ];
- package: 'Math-Tests-Polynomials' with: [ spec requires: #('Math-Polynomials') ];
- package: 'Math-Tests-Quaternion' with: [ spec requires: #('Math-Quaternion') ];
- package: 'Math-Tests-Random' with: [ spec requires: #('Math-Random') ];
+ package: 'Math-Tests-Permutation'
+ with: [ spec requires: #('Math-Permutation') ];
+ package: 'Math-Tests-PrincipalComponentAnalysis'
+ with: [ spec requires: #('Math-PrincipalComponentAnalysis') ];
+ package: 'Math-Tests-Quantile'
+ with: [ spec requires: #('Math-Quantile') ];
+ package: 'Math-Tests-Polynomials'
+ with: [ spec requires: #('Math-Polynomials') ];
+ package: 'Math-Tests-Quaternion'
+ with: [ spec requires: #('Math-Quaternion') ];
+ package: 'Math-Tests-Random'
+ with: [ spec requires: #('Math-Random') ];
+ package: 'Math-Tests-TSNE'
+ with: [ spec requires: #('Math-TSNE') ];
package: 'Math-UtilsDataServer'.
"Groups"
spec
- group: 'Accuracy' with: #('Math-Accuracy-ODE' 'Math-Accuracy-Core');
- group: 'Benchmarks' with: #('Math-Benchmarks-ODE' 'Math-Benchmarks-KDTree');
- group: 'Core' with: #('Math-Complex' 'Math-Quaternion' 'Math-DHB-Numerical' 'Math-Random' 'Math-KDTree' 'Math-ODE' 'Math-ArbitraryPrecisionFloat' 'Math-FastFourierTransform' 'ExtendedNumberParser' 'Math-Quantile' 'Math-Physics-Constants' 'Math-Polynomials' 'Math-TSNE');
- group: 'Extensions' with: #('Math-Clustering' 'Math-Number-Extensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' 'Math-KernelSmoothing' 'Math-Permutation' 'Math-RandomDistributionBased' 'Math-KolmogorovSmirnov');
- group: 'Tests' with: #('Math-Tests-Matrix' 'Math-Tests-Clustering' 'Math-Tests-DHB-Numerical' 'Math-Tests-Complex' 'Math-Tests-Quaternion' 'Math-Tests-Random' 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-DHB-wk' 'Math-Tests-FunctionFit' 'Math-Tests-AutomaticDifferenciation' 'Math-Tests-FastFourierTransform' 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' 'Math-Tests-KolmogorovSmirnov' 'Math-Tests-Quantile' 'Math-Tests-Polynomials');
- group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ]
+ group: 'Accuracy'
+ with: #('Math-Accuracy-ODE' 'Math-Accuracy-Core');
+ group: 'Benchmarks'
+ with: #('Math-Benchmarks-ODE' 'Math-Benchmarks-KDTree');
+ group: 'Core'
+ with:
+ #('Math-Complex' 'Math-Quaternion' 'Math-Numerical' 'Math-Random' 'Math-KDTree' 'Math-ODE' 'Math-ArbitraryPrecisionFloat' 'Math-FastFourierTransform' 'ExtendedNumberParser' 'Math-Quantile' 'Math-Physics-Constants' 'Math-Polynomials' 'Math-TSNE' 'Math-Core-Process' 'Math-Core' 'Math-Core-Distribution');
+ group: 'Extensions'
+ with:
+ #('Math-Clustering' 'Math-Number-Extensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' 'Math-KernelSmoothing' 'Math-Permutation' 'Math-KolmogorovSmirnov');
+ group: 'Tests'
+ with:
+ #('Math-Tests-Matrix' 'Math-Tests-Clustering' 'Math-Tests-Numerical' 'Math-Tests-Complex' 'Math-Tests-Quaternion' 'Math-Tests-Random' 'Math-Tests-ODE' 'Math-Tests-KDTree' 'Math-Tests-FunctionFit' 'Math-Tests-AutomaticDifferenciation' 'Math-Tests-FastFourierTransform' 'Math-Tests-Accuracy' 'Math-Tests-ArbitraryPrecisionFloat' 'Math-Tests-KolmogorovSmirnov' 'Math-Tests-Quantile' 'Math-Tests-Polynomials' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-KernelSmoothing' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' 'Math-Tests-TSNE' 'Math-Tests-Core-Process' 'Math-Tests-Core');
+ group: 'default'
+ with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ]
]
{ #category : #accessing }
@@ -105,7 +180,7 @@ BaselineOfPolyMath >> sMark: spec [
project: 'SMark'
with: [ spec
className: #ConfigurationOfSMark;
- versionString: '1.0.2';
+ versionString: '1.0.3';
repository: 'http://smalltalkhub.com/mc/StefanMarr/SMark/main' ]
]
diff --git a/src/Math-Accuracy-Core/PMAccuracy.class.st b/src/Math-Accuracy-Core/PMAccuracy.class.st
index 01ca179a0..1e74de0a5 100644
--- a/src/Math-Accuracy-Core/PMAccuracy.class.st
+++ b/src/Math-Accuracy-Core/PMAccuracy.class.st
@@ -209,14 +209,15 @@ PMAccuracy >> extremeCollection: acol max:aBoolean [
{ #category : #private }
PMAccuracy >> findKey [
- | s m |
+ | s selector matchingMessage |
s := thisContext sender.
- m := s sender method selector .
- ^(names detect: [:n| m asString endsWith: n] ifNone: [nil])
- ifNil: [ m='initialize'
- ifTrue: ['AllTheRest']
- ifFalse: [ m := s method selector asString.
- self error: m,' called in wrong context'] ]
+ selector := s sender method selector.
+ selector = 'initialize'
+ ifTrue: [ ^ 'AllTheRest' ].
+ matchingMessage := names
+ detect: [ :name | selector endsWith: name ]
+ ifNone: [ '' ].
+ ^ matchingMessage
]
{ #category : #printing }
@@ -252,31 +253,33 @@ PMAccuracy >> ifSeveralterations: aBlock [
]
{ #category : #'initialize-release' }
-PMAccuracy >> initNames [
- names := (self class allSelectorsBelow: Object)
- select: [ :s | s beginsWith: #check ]
- thenCollect: [ :s | s copyFrom: 6 to: s size ].
- names := names asArray sort
+PMAccuracy >> initRest: aName [
+ | initializationMessage |
+ initializationMessage := ('initialize' , aName) asSymbol.
+ (self respondsTo: initializationMessage)
+ ifFalse: [ ^ self ].
+ self perform: initializationMessage
]
{ #category : #'initialize-release' }
-PMAccuracy >> initRest: aName [
- | i |
- i := ('initialize' , aName) asSymbol.
- (self respondsTo: i)
- ifTrue: [ self perform: i ]
+PMAccuracy >> initSubclassSelectorNames [
+ names := (self class allSelectorsBelow: Object)
+ select: [ :selectorName | selectorName beginsWith: #check ]
+ thenCollect: [ :selectorName | selectorName copyFrom: 6 to: selectorName size ].
+ names := names asArray sort
]
{ #category : #'initialize-release' }
PMAccuracy >> initialize [
- self initNames.
parameters := Dictionary new.
arguments := Dictionary new.
results := Dictionary new.
+ self initSubclassSelectorNames.
+ names do: [ :name | self initRest: name ].
aStream := WriteStream with: ''.
iterations := 1.
- dataTree := KeyedTree new .
- names do: [ :n | self initRest: n ]
+ dataTree := KeyedTree new.
+
]
{ #category : #accessing }
@@ -303,6 +306,11 @@ PMAccuracy >> numberOfDifferentResultsAt: aname [
^ no first isCollection ifTrue: [ no size ] ifFalse: [ 1 ]
]
+{ #category : #accessing }
+PMAccuracy >> occurrencesOf: key In: aResults UpTo: anInteger [
+ ^ (aResults copyFrom: 1 to: anInteger) occurrencesOf: key
+]
+
{ #category : #accessing }
PMAccuracy >> parameter [
| r |
@@ -394,15 +402,9 @@ PMAccuracy >> resultsKeyFor: aName AtPosition: anInteger [
key := aResults at: anInteger.
key isArray
ifFalse: [ ^ aResults ].
- repetitions := 0.
- aResults
- from: 1
- to: anInteger - 1
- do: [ :i |
- i = key
- ifTrue: [ repetitions := repetitions + 1 ] ].
+ repetitions := self occurrencesOf: key In: aResults UpTo: anInteger - 1.
result := (Array new: key size + repetitions)
- replaceFrom: 1
+ replaceFrom: 1
to: key size
with: key
startingAt: 1.
diff --git a/src/Math-Accuracy-ODE/PMODEAccuracy.class.st b/src/Math-Accuracy-ODE/PMODEAccuracy.class.st
index fef5131fc..29c1dfadc 100644
--- a/src/Math-Accuracy-ODE/PMODEAccuracy.class.st
+++ b/src/Math-Accuracy-ODE/PMODEAccuracy.class.st
@@ -38,28 +38,28 @@ PMODEAccuracy class >> runToXML [
{ #category : #checks }
PMODEAccuracy >> checkAB2 [
- ^ self checkSolverClass: AB2Solver systemClass: ExplicitSystem stepperClass: AB2Stepper
+ ^ self checkSolverClass: PMAB2Solver systemClass: PMExplicitSystem stepperClass: PMAB2Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkAB3 [
- ^ self checkSolverClass: AB3Solver systemClass: ExplicitSystem stepperClass: AB3Stepper
+ ^ self checkSolverClass: PMAB3Solver systemClass: PMExplicitSystem stepperClass: PMAB3Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkAB4 [
- ^ self checkSolverClass: AB4Solver systemClass: ExplicitSystem stepperClass: AB4Stepper
+ ^ self checkSolverClass: PMAB4Solver systemClass: PMExplicitSystem stepperClass: PMAB4Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkAM3 [
^ self
- checkSolverClass: AM3Solver
- systemClass: ImplicitSystem
- stepperClass: AM3Stepper
+ checkSolverClass: PMAM3Solver
+ systemClass: PMImplicitSystem
+ stepperClass: PMAM3Stepper
]
@@ -67,81 +67,81 @@ PMODEAccuracy >> checkAM3 [
{ #category : #checks }
PMODEAccuracy >> checkAM4 [
^ self
- checkSolverClass: AM4Solver
- systemClass: ImplicitSystem
- stepperClass: AM4Stepper
+ checkSolverClass: PMAM4Solver
+ systemClass: PMImplicitSystem
+ stepperClass: PMAM4Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkBDF2 [
^ self
- checkSolverClass: BDF2Solver
- systemClass: ImplicitSystem
- stepperClass: BDF2Stepper
+ checkSolverClass: PMBDF2Solver
+ systemClass: PMImplicitSystem
+ stepperClass: PMBDF2Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkBDF3 [
^ self
- checkSolverClass: BDF3Solver
- systemClass: ImplicitSystem
- stepperClass: BDF3Stepper
+ checkSolverClass: PMBDF3Solver
+ systemClass: PMImplicitSystem
+ stepperClass: PMBDF3Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkBDF4 [
^ self
- checkSolverClass: BDF4Solver
- systemClass: ImplicitSystem
- stepperClass: BDF4Stepper
+ checkSolverClass: PMBDF4Solver
+ systemClass: PMImplicitSystem
+ stepperClass: PMBDF4Stepper
]
{ #category : #checks }
PMODEAccuracy >> checkBeckwardEuler [
^ self
- checkSolverClass: ImplicitSolver
- systemClass: ImplicitSystem
- stepperClass: ImplicitStepper
+ checkSolverClass: PMImplicitSolver
+ systemClass: PMImplicitSystem
+ stepperClass: PMImplicitStepper
]
{ #category : #checks }
PMODEAccuracy >> checkEuler [
^ self
- checkSolverClass: ExplicitSolver
- systemClass: ExplicitSystem
- stepperClass: ExplicitStepper
+ checkSolverClass: PMExplicitSolver
+ systemClass: PMExplicitSystem
+ stepperClass: PMExplicitStepper
]
{ #category : #checks }
PMODEAccuracy >> checkHeun [
^ self
- checkSolverClass: ExplicitSolver
- systemClass: ExplicitSystem
- stepperClass: HeunStepper
+ checkSolverClass: PMExplicitSolver
+ systemClass: PMExplicitSystem
+ stepperClass: PMHeunStepper
]
{ #category : #checks }
PMODEAccuracy >> checkImplicitMidpoint [
^ self
- checkSolverClass: ImplicitMidpointSolver
- systemClass: ImplicitSystem
- stepperClass: ImplicitMidpointStepper
+ checkSolverClass: PMImplicitMidpointSolver
+ systemClass: PMImplicitSystem
+ stepperClass: PMImplicitMidpointStepper
]
{ #category : #checks }
PMODEAccuracy >> checkMidpoint [
^ self
- checkSolverClass: ExplicitSolver
- systemClass: ExplicitSystem
- stepperClass: MidpointStepper
+ checkSolverClass: PMExplicitSolver
+ systemClass: PMExplicitSystem
+ stepperClass: PMMidpointStepper
]
{ #category : #checks }
PMODEAccuracy >> checkRungeKutta [
^ self
- checkSolverClass: ExplicitSolver
- systemClass: ExplicitSystem
- stepperClass: RungeKuttaStepper
+ checkSolverClass: PMExplicitSolver
+ systemClass: PMExplicitSystem
+ stepperClass: PMRungeKuttaStepper
]
{ #category : #utils }
@@ -156,9 +156,9 @@ PMODEAccuracy >> checkSolverClass: solverClass systemClass: systemClass stepperC
{ #category : #checks }
PMODEAccuracy >> checkTrapezoidAM2 [
^ self
- checkSolverClass: ImplicitSolver
- systemClass: ImplicitSystem
- stepperClass: TrapezoidStepper
+ checkSolverClass: PMImplicitSolver
+ systemClass: PMImplicitSystem
+ stepperClass: PMTrapezoidStepper
]
{ #category : #initialization }
diff --git a/src/Math-AutomaticDifferenciation/Number.extension.st b/src/Math-AutomaticDifferenciation/Number.extension.st
new file mode 100644
index 000000000..572b4e11d
--- /dev/null
+++ b/src/Math-AutomaticDifferenciation/Number.extension.st
@@ -0,0 +1,15 @@
+Extension { #name : #Number }
+
+{ #category : #'*Math-AutomaticDifferenciation' }
+Number >> addDualNumber: aDualNumber [
+ ^ aDualNumber class
+ value: self + aDualNumber value
+ eps: aDualNumber eps
+]
+
+{ #category : #'*Math-AutomaticDifferenciation' }
+Number >> multiplyDualNumber: aDualNumber [
+ ^ aDualNumber class
+ value: aDualNumber value * self
+ eps: aDualNumber eps * self
+]
diff --git a/src/Math-AutomaticDifferenciation/PMDualNumber.class.st b/src/Math-AutomaticDifferenciation/PMDualNumber.class.st
index a75512f63..058af1fbf 100644
--- a/src/Math-AutomaticDifferenciation/PMDualNumber.class.st
+++ b/src/Math-AutomaticDifferenciation/PMDualNumber.class.st
@@ -1,4 +1,7 @@
"
+In linear algebra, dual numbers extend the real numbers by adjoining one new element ε with the property ε^2 = 0 (ε is nilpotent).
+See here: https://en.wikipedia.org/wiki/Dual_number^
+
PMDualNumbers can be used to calculate the first derivative if one creates them this way:
PMDualNumber value: aNumber eps: derivativeOfaNumber (1 if the derivative with respect to aNumber is calculated, 0 otherwise)
@@ -6,7 +9,7 @@ PMDualNumbers can be mixed with Numbers.
"
Class {
#name : #PMDualNumber,
- #superclass : #Magnitude,
+ #superclass : #Number,
#instVars : [
'value',
'eps'
@@ -14,13 +17,12 @@ Class {
#classVars : [
'ZeroApproximation'
],
- #category : 'Math-AutomaticDifferenciation'
+ #category : #'Math-AutomaticDifferenciation'
}
{ #category : #'instance creation' }
-PMDualNumber class >> value:aValue [
-"for entering a constant"
-^(self new value: aValue) eps: 0
+PMDualNumber class >> value: aValue [
+ ^ (self new value: aValue) eps: 0
]
{ #category : #'instance creation' }
@@ -41,31 +43,24 @@ PMDualNumber class >> zeroApproximation: aSmallNumber [
]
{ #category : #arithmetic }
-PMDualNumber >> * aDualNumber [
-^aDualNumber isDualNumber
- ifFalse:[self class value: value * aDualNumber eps: eps *aDualNumber]
- ifTrue:[self class value: value * aDualNumber value eps: eps * aDualNumber value + (aDualNumber eps *value)]
+PMDualNumber >> * aNumber [
+ ^ aNumber multiplyDualNumber: self
]
{ #category : #arithmetic }
-PMDualNumber >> + aDualNumber [
-^aDualNumber isDualNumber
- ifFalse:[self class value: value + aDualNumber eps: eps]
- ifTrue:[self class value: value + aDualNumber value eps: eps + aDualNumber eps]
+PMDualNumber >> + aNumber [
+ ^ aNumber addDualNumber: self
]
{ #category : #arithmetic }
-PMDualNumber >> - aDualNumber [
-^aDualNumber isDualNumber
- ifFalse:[self class value: value - aDualNumber eps: eps]
- ifTrue:[self class value: value - aDualNumber value eps: eps - aDualNumber eps]
+PMDualNumber >> - aNumber [
+ ^ aNumber negated addDualNumber: self
]
{ #category : #arithmetic }
-PMDualNumber >> / aDualNumber [
-^aDualNumber isDualNumber
- ifFalse:[self class value: value / aDualNumber eps: eps /aDualNumber]
- ifTrue:[self class value: value / aDualNumber value eps:( eps * aDualNumber value - (aDualNumber eps *value))/aDualNumber value squared]
+PMDualNumber >> / aNumber [
+
+ ^ aNumber reciprocal multiplyDualNumber: self
]
{ #category : #testing }
@@ -84,9 +79,26 @@ PMDualNumber >> abs [
]
+{ #category : #arithmetic }
+PMDualNumber >> absSquared [
+ ^ (self conjugated * self) real
+]
+
{ #category : #converting }
-PMDualNumber >> adaptToNumber: rcvr andSend: selector [
- ^ (self class value:rcvr) perform: selector with: self
+PMDualNumber >> adaptToFraction: rcvr andSend: selector [
+ ^ (self class value: rcvr) perform: selector with: self
+]
+
+{ #category : #converting }
+PMDualNumber >> adaptToInteger: rcvr andSend: selector [
+ ^ (self class value: rcvr) perform: selector with: self
+]
+
+{ #category : #arithmetic }
+PMDualNumber >> addDualNumber: aDualNumber [
+ ^ self class
+ value: value + aDualNumber value
+ eps: eps + aDualNumber eps
]
{ #category : #'mathematical functions' }
@@ -105,9 +117,7 @@ PMDualNumber >> arcSin [
{ #category : #'mathematical functions' }
PMDualNumber >> arcTan [
- ^ self class
- value: value arcTan
- eps: eps / (1 + value squared)
+ ^ self class value: value arcTan eps: eps / (1 + value squared)
]
{ #category : #converting }
@@ -120,11 +130,16 @@ PMDualNumber >> asInteger [
^ value asInteger
]
+{ #category : #'mathematical functions' }
+PMDualNumber >> conjugated [
+ ^ self class
+ value: self value conjugated
+ eps: self eps asComplex conjugated
+]
+
{ #category : #'mathematical functions' }
PMDualNumber >> cos [
- ^ self class
- value: value cos
- eps: eps * value sin negated
+ ^ self class value: value cos eps: eps * value sin negated
]
{ #category : #accessing }
@@ -133,8 +148,8 @@ PMDualNumber >> eps [
]
{ #category : #accessing }
-PMDualNumber >> eps: anObject [
-eps := anObject
+PMDualNumber >> eps: aNumber [
+ eps := aNumber
]
{ #category : #comparing }
@@ -154,7 +169,7 @@ PMDualNumber >> exp [
^ self class value: e eps: eps * e
]
-{ #category : #hash }
+{ #category : #comparing }
PMDualNumber >> hash [
^ value hash
]
@@ -193,6 +208,13 @@ PMDualNumber >> ln [
^ self class value: value ln eps: eps / v
]
+{ #category : #arithmetic }
+PMDualNumber >> multiplyDualNumber: aDualNumber [
+ ^self class
+ value: value * aDualNumber value
+ eps: eps * aDualNumber value + (aDualNumber eps * value)
+]
+
{ #category : #arithmetic }
PMDualNumber >> negated [
^self class value: value negated eps: eps negated
@@ -226,15 +248,22 @@ PMDualNumber >> printOn: aStream [
nextPutAll: ')'
]
+{ #category : #printing }
+PMDualNumber >> printOn: aStream base: base [
+ self printOn: aStream
+]
+
{ #category : #'mathematical functions' }
PMDualNumber >> raisedTo: aDualNumber [
| v |
value = 0
- ifTrue: [ ^ PMDualNumber value: 0 ].
+ ifTrue: [ ^ self class value: 0 ].
v := value raisedTo: aDualNumber value.
aDualNumber isDualNumber
ifFalse: [ ^ self class value: v eps: v / value * eps * aDualNumber ].
- ^ self class value: v eps: v * (eps * aDualNumber value / value + (aDualNumber eps * value ln))
+ ^ self class
+ value: v
+ eps: v * (eps * aDualNumber value / value + (aDualNumber eps * value ln))
]
{ #category : #'mathematical functions' }
@@ -244,9 +273,14 @@ PMDualNumber >> raisedToInteger: anInteger [
ifFalse: [ self class value: (value raisedToInteger: anInteger) eps: anInteger * eps * (value raisedToInteger: anInteger - 1) ]
]
+{ #category : #converting }
+PMDualNumber >> real [
+ ^ self class value: self value real eps: self eps asComplex real
+]
+
{ #category : #arithmetic }
PMDualNumber >> reciprocal [
-^self class value: 1/value eps: eps /value squared negated
+ ^ self class value: 1 / value eps: eps / value squared negated
]
{ #category : #'mathematical functions' }
diff --git a/src/Math-AutomaticDifferenciation/PMGradient.class.st b/src/Math-AutomaticDifferenciation/PMGradient.class.st
index 793c9e4f4..135ff3051 100644
--- a/src/Math-AutomaticDifferenciation/PMGradient.class.st
+++ b/src/Math-AutomaticDifferenciation/PMGradient.class.st
@@ -1,5 +1,7 @@
"
-Gradient calcs the gradient of a function of a SequentialCollection of Numbers. example: f(x,y)=x^2 * y
+Computes the gradient of a function of a Collection of Numbers.
+
+Example: f(x,y)=x^2 * y
g := PMGradient of:[:x|x first squared * x second].
g value:#(3 2). ""-->#(12 9)""
g value:#(1 1). ""-->#(2 1)""
@@ -11,7 +13,7 @@ Class {
#instVars : [
'function'
],
- #category : 'Math-AutomaticDifferenciation'
+ #category : #'Math-AutomaticDifferenciation'
}
{ #category : #'instance creation' }
diff --git a/src/Math-AutomaticDifferenciation/PMHyperDualNumber.class.st b/src/Math-AutomaticDifferenciation/PMHyperDualNumber.class.st
index 1dd67a7c5..bf61d46d9 100644
--- a/src/Math-AutomaticDifferenciation/PMHyperDualNumber.class.st
+++ b/src/Math-AutomaticDifferenciation/PMHyperDualNumber.class.st
@@ -9,23 +9,23 @@ Class {
'eps2',
'eps1eps2'
],
- #category : 'Math-AutomaticDifferenciation'
+ #category : #'Math-AutomaticDifferenciation'
}
{ #category : #'instance creation' }
-PMHyperDualNumber class >> value:aValue [
-"a constant"
-^(((self new value: aValue) eps: 0) eps2: 0) eps1eps2: 0
+PMHyperDualNumber class >> value: aValue [
+ ^ (((self new value: aValue) eps: 0) eps2: 0) eps1eps2: 0
]
{ #category : #'instance creation' }
-PMHyperDualNumber class >> value:aValue eps: anEps [
-^(((self new value: aValue) eps: anEps) eps2: 0) eps1eps2: 0
+PMHyperDualNumber class >> value: aValue eps: anEps [
+ ^ (((self new value: aValue) eps: anEps) eps2: 0) eps1eps2: 0
]
{ #category : #'instance creation' }
-PMHyperDualNumber class >> value:aValue eps: anEps eps2: anEps2 eps1eps2: anEps1eps2 [
-^(((self new value: aValue) eps: anEps) eps2: anEps2) eps1eps2: anEps1eps2
+PMHyperDualNumber class >> value: aValue eps: anEps eps2: anEps2 eps1eps2: anEps1eps2 [
+ ^ (((self new value: aValue) eps: anEps) eps2: anEps2)
+ eps1eps2: anEps1eps2
]
{ #category : #arithmetic }
@@ -66,160 +66,195 @@ PMHyperDualNumber >> / aHyperDualNumber [
{ #category : #'mathematical functions' }
PMHyperDualNumber >> arcCos [
-|a d|
-a:=1 - value squared.
-d:=a sqrt negated.
-^(super arcCos) eps2: eps2 / d; eps1eps2: eps1eps2 /d + (eps * eps2 * value negated /(a raisedTo: (3/2)));yourself
-
+ | a d |
+ a := 1 - value squared.
+ d := a sqrt negated.
+ ^ super arcCos
+ eps2: eps2 / d;
+ eps1eps2: eps1eps2 / d + (eps * eps2 * value negated / (a raisedTo: 3 / 2));
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> arcSin [
-|a d|
-a:=1 - value squared.
-d:=a sqrt.
-^(super arcSin) eps2: eps2 / d; eps1eps2: eps1eps2 /d + (eps * eps2 * value /(a raisedTo: (3/2)));yourself
-
+ | a d |
+ a := 1 - value squared.
+ d := a sqrt.
+ ^ super arcSin
+ eps2: eps2 / d;
+ eps1eps2: eps1eps2 / d + (eps * eps2 * value / (a raisedTo: 3 / 2));
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> arcTan [
-|a|
-a:=1 + value squared.
-^(super arcTan) eps2: eps2 / a; eps1eps2: eps1eps2 /a + (-2 * eps * eps2 * value /(a squared));yourself
-
+ | a |
+ a := 1 + value squared.
+ ^ super arcTan
+ eps2: eps2 / a;
+ eps1eps2: eps1eps2 / a + (-2 * eps * eps2 * value / a squared);
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> cos [
-^(super cos) eps2: eps2 * value sin negated; eps1eps2: (eps1eps2 * value sin + (eps * eps2 * value cos))negated ;yourself
-
+ ^ super cos
+ eps2: eps2 * value sin negated;
+ eps1eps2: (eps1eps2 * value sin + (eps * eps2 * value cos)) negated;
+ yourself
]
{ #category : #accessing }
PMHyperDualNumber >> eps1eps2 [
- ^eps1eps2
+ ^ eps1eps2
]
{ #category : #accessing }
PMHyperDualNumber >> eps1eps2: anEps [
- eps1eps2 := anEps
+ eps1eps2 := anEps
]
{ #category : #accessing }
PMHyperDualNumber >> eps2 [
- ^eps2
+ ^ eps2
]
{ #category : #accessing }
PMHyperDualNumber >> eps2: anEps2 [
- eps2 := anEps2
+ eps2 := anEps2
]
{ #category : #comparing }
PMHyperDualNumber >> equalsTo: aHyperDualNumber [
- ^(super equalsTo: aHyperDualNumber)
- and: [(eps2 equalsTo: aHyperDualNumber eps2)
- and: [eps1eps2 equalsTo: aHyperDualNumber eps1eps2]]
+ ^ (super equalsTo: aHyperDualNumber)
+ and: [ (eps2 equalsTo: aHyperDualNumber eps2)
+ and: [ eps1eps2 equalsTo: aHyperDualNumber eps1eps2 ] ]
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> exp [
-|e|
-e:=value exp.
-^(super exp)eps2: eps2 * e; eps1eps2: (eps1eps2 +(eps * eps2) * e);yourself
-
+ | e |
+ e := value exp.
+ ^ super exp
+ eps2: eps2 * e;
+ eps1eps2: (eps * eps2 + eps1eps2) * e;
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> ln [
-|v|
-v :=value.
-v=0 ifTrue:[v:=self class zeroApproximation ].
-^(super ln) eps2: eps2/v; eps1eps2: eps1eps2/v -(eps * eps2 / v squared );yourself
-
+ | v |
+ v := value.
+ v = 0
+ ifTrue: [ v := self class zeroApproximation ].
+ ^ super ln
+ eps2: eps2 / v;
+ eps1eps2: eps1eps2 / v - (eps * eps2 / v squared);
+ yourself
]
{ #category : #arithmetic }
PMHyperDualNumber >> negated [
- ^self class
- value: value negated
- eps: eps negated
- eps2: eps2 negated
+ ^ self class
+ value: value negated
+ eps: eps negated
+ eps2: eps2 negated
eps1eps2: eps1eps2 negated
]
{ #category : #printing }
-PMHyperDualNumber >> printOn: aStream [
+PMHyperDualNumber >> printOn: aStream [
"Append a sequence of characters that identify the receiver to aStream."
-aStream
- nextPutAll: self class name;
- nextPutAll: '(value: ' ;
- print: value ;
- nextPutAll:' eps1: ';
- print: eps;
- nextPutAll: ' eps2: ' ;
- print: eps2 ;
- nextPutAll:' eps12: ';
- print: eps1eps2;
- nextPutAll:')'.
+
+ aStream
+ nextPutAll: self class name;
+ nextPutAll: '(value: ';
+ print: value;
+ nextPutAll: ' eps1: ';
+ print: eps;
+ nextPutAll: ' eps2: ';
+ print: eps2;
+ nextPutAll: ' eps12: ';
+ print: eps1eps2;
+ nextPutAll: ')'
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> raisedTo: aHyperDualNumber [
-^ (self ln * aHyperDualNumber)exp
-
+ ^ (self ln * aHyperDualNumber) exp
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> raisedToInteger: anInteger [
-|v|
-anInteger=0 ifTrue:[^self class value:1 eps:0 eps2:0 eps1eps2:0].
-v := value raisedToInteger: anInteger -1.
-^(super raisedToInteger: anInteger) eps2: anInteger * eps2 * v; eps1eps2: eps1eps2 * anInteger * v +(eps * eps2 * anInteger * (anInteger -1) * (value raisedToInteger: anInteger -2));yourself
-
+ | v |
+ anInteger = 0
+ ifTrue: [ ^ self class
+ value: 1
+ eps: 0
+ eps2: 0
+ eps1eps2: 0 ].
+ v := value raisedToInteger: anInteger - 1.
+ ^ (super raisedToInteger: anInteger)
+ eps2: anInteger * eps2 * v;
+ eps1eps2:
+ eps1eps2 * anInteger * v
+ +
+ (eps * eps2 * anInteger * (anInteger - 1)
+ * (value raisedToInteger: anInteger - 2));
+ yourself
]
{ #category : #arithmetic }
-PMHyperDualNumber >> reciprocal [
+PMHyperDualNumber >> reciprocal [
| s |
s := value squared.
- ^ self class
- value: 1/value
- eps: eps /s negated
- eps2: eps2 /s negated
- eps1eps2: (2 * eps2 * eps) /(s * value) - (eps1eps2 / s)
+ ^ self class
+ value: 1 / value
+ eps: eps / s negated
+ eps2: eps2 / s negated
+ eps1eps2: 2 * eps2 * eps / (s * value) - (eps1eps2 / s)
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> sin [
-^(super sin) eps2: eps2 * value cos; eps1eps2: eps1eps2 * value cos - (eps * eps2 * value sin);yourself
-
+ ^ super sin
+ eps2: eps2 * value cos;
+ eps1eps2: eps1eps2 * value cos - (eps * eps2 * value sin);
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> sqrt [
-|d d2|
-d:=2 * value sqrt.
-d2:=4* (value raisedTo: (3/2)).
-d=0 ifTrue:[
- d:=self class zeroApproximation.
- d2:=4* ((self class zeroApproximation) raisedTo: (3/2)) ].
-^(super sqrt) eps2: eps2/d; eps1eps2: eps1eps2/d -(eps * eps2 / d2);yourself
-
+ | d d2 |
+ d := 2 * value sqrt.
+ d2 := 4 * (value raisedTo: 3 / 2).
+ d = 0
+ ifTrue: [ d := self class zeroApproximation.
+ d2 := 4 * (self class zeroApproximation raisedTo: 3 / 2) ].
+ ^ super sqrt
+ eps2: eps2 / d;
+ eps1eps2: eps1eps2 / d - (eps * eps2 / d2);
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> squared [
-|e|
-e:=2 * value.
-^(super squared) eps2: eps2 * e;eps1eps2: eps1eps2 * e +(eps * eps2 * 2);yourself
-
+ | e |
+ e := 2 * value.
+ ^ super squared
+ eps2: eps2 * e;
+ eps1eps2: eps1eps2 * e + (eps * eps2 * 2);
+ yourself
]
{ #category : #'mathematical functions' }
PMHyperDualNumber >> tan [
-|t|
-t:=value cos squared.
-^(super tan) eps2: eps / t; eps1eps2: eps1eps2 / t + (eps * eps2 * 2 * value sin / ((value cos)raisedToInteger: 3)) ;yourself
+ | t |
+ t := value cos squared.
+ ^ super tan
+ eps2: eps / t;
+ eps1eps2:
+ eps1eps2 / t
+ + (eps * eps2 * 2 * value sin / (value cos raisedToInteger: 3));
+ yourself
]
diff --git a/src/Math-Benchmarks-ODE/PMExplicitBenchmark.class.st b/src/Math-Benchmarks-ODE/PMExplicitBenchmark.class.st
index 3fd7e1664..35e31aba9 100644
--- a/src/Math-Benchmarks-ODE/PMExplicitBenchmark.class.st
+++ b/src/Math-Benchmarks-ODE/PMExplicitBenchmark.class.st
@@ -10,8 +10,8 @@ Class {
{ #category : #benchmarking }
PMExplicitBenchmark >> benchEuler [
| solver stepper |
- stepper := ExplicitStepper onSystem: system.
- solver := (ExplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMExplicitStepper onSystem: system.
+ solver := (PMExplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -19,8 +19,8 @@ PMExplicitBenchmark >> benchEuler [
{ #category : #benchmarking }
PMExplicitBenchmark >> benchHeun [
| solver stepper |
- stepper := HeunStepper onSystem: system.
- solver := (ExplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMHeunStepper onSystem: system.
+ solver := (PMExplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -28,8 +28,8 @@ PMExplicitBenchmark >> benchHeun [
{ #category : #benchmarking }
PMExplicitBenchmark >> benchMidpoint [
| solver stepper |
- stepper := MidpointStepper onSystem: system.
- solver := (ExplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMMidpointStepper onSystem: system.
+ solver := (PMExplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -37,8 +37,8 @@ PMExplicitBenchmark >> benchMidpoint [
{ #category : #benchmarking }
PMExplicitBenchmark >> benchRungeKutta [
| solver stepper |
- stepper := RungeKuttaStepper onSystem: system.
- solver := (ExplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := (PMExplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -46,6 +46,6 @@ PMExplicitBenchmark >> benchRungeKutta [
{ #category : #running }
PMExplicitBenchmark >> setUp [
super setUp.
- system := ExplicitSystem block: function.
+ system := PMExplicitSystem block: function.
]
diff --git a/src/Math-Benchmarks-ODE/PMExplicitMultiBenchmark.class.st b/src/Math-Benchmarks-ODE/PMExplicitMultiBenchmark.class.st
index e4b84e1d6..fbe88cfe7 100644
--- a/src/Math-Benchmarks-ODE/PMExplicitMultiBenchmark.class.st
+++ b/src/Math-Benchmarks-ODE/PMExplicitMultiBenchmark.class.st
@@ -10,8 +10,8 @@ Class {
{ #category : #benchmarking }
PMExplicitMultiBenchmark >> benchAB2 [
| solver stepper |
- stepper := AB2Stepper onSystem: system.
- solver := (AB2Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMAB2Stepper onSystem: system.
+ solver := (PMAB2Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -19,8 +19,8 @@ PMExplicitMultiBenchmark >> benchAB2 [
{ #category : #benchmarking }
PMExplicitMultiBenchmark >> benchAB3 [
| solver stepper |
- stepper := AB3Stepper onSystem: system.
- solver := (AB3Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMAB3Stepper onSystem: system.
+ solver := (PMAB3Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -28,8 +28,8 @@ PMExplicitMultiBenchmark >> benchAB3 [
{ #category : #benchmarking }
PMExplicitMultiBenchmark >> benchAB4 [
| solver stepper |
- stepper := AB4Stepper onSystem: system.
- solver := (AB4Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMAB4Stepper onSystem: system.
+ solver := (PMAB4Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -37,5 +37,5 @@ PMExplicitMultiBenchmark >> benchAB4 [
{ #category : #'as yet unclassified' }
PMExplicitMultiBenchmark >> setUp [
super setUp.
- system := ExplicitSystem block: function
+ system := PMExplicitSystem block: function
]
diff --git a/src/Math-Benchmarks-ODE/PMImplicitBenchmark.class.st b/src/Math-Benchmarks-ODE/PMImplicitBenchmark.class.st
index 618969407..e01560b3b 100644
--- a/src/Math-Benchmarks-ODE/PMImplicitBenchmark.class.st
+++ b/src/Math-Benchmarks-ODE/PMImplicitBenchmark.class.st
@@ -10,8 +10,8 @@ Class {
{ #category : #benchmarking }
PMImplicitBenchmark >> benchBeckwardEuler [
| solver stepper |
- stepper := ImplicitStepper onSystem: system.
- solver := (ImplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMImplicitStepper onSystem: system.
+ solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -19,8 +19,8 @@ PMImplicitBenchmark >> benchBeckwardEuler [
{ #category : #benchmarking }
PMImplicitBenchmark >> benchImplicitMidpoint [
| solver stepper |
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := (ImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := (PMImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -28,5 +28,5 @@ PMImplicitBenchmark >> benchImplicitMidpoint [
{ #category : #'as yet unclassified' }
PMImplicitBenchmark >> setUp [
super setUp.
- system := ImplicitSystem block: function.
+ system := PMImplicitSystem block: function.
]
diff --git a/src/Math-Benchmarks-ODE/PMImplicitMultiBenchmark.class.st b/src/Math-Benchmarks-ODE/PMImplicitMultiBenchmark.class.st
index 0be2ca6f7..9e532a512 100644
--- a/src/Math-Benchmarks-ODE/PMImplicitMultiBenchmark.class.st
+++ b/src/Math-Benchmarks-ODE/PMImplicitMultiBenchmark.class.st
@@ -10,8 +10,8 @@ Class {
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchAM3 [
| solver stepper |
- stepper := AM3Stepper onSystem: system.
- solver := (AM3Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMAM3Stepper onSystem: system.
+ solver := (PMAM3Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -19,8 +19,8 @@ PMImplicitMultiBenchmark >> benchAM3 [
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchAM4 [
| solver stepper |
- stepper := AM4Stepper onSystem: system.
- solver := (AM4Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMAM4Stepper onSystem: system.
+ solver := (PMAM4Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -28,8 +28,8 @@ PMImplicitMultiBenchmark >> benchAM4 [
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchBDF2 [
| solver stepper |
- stepper := BDF2Stepper onSystem: system.
- solver := (BDF2Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := (PMBDF2Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -37,8 +37,8 @@ PMImplicitMultiBenchmark >> benchBDF2 [
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchBDF3 [
| solver stepper |
- stepper := BDF3Stepper onSystem: system.
- solver := (BDF3Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := (PMBDF3Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -46,8 +46,8 @@ PMImplicitMultiBenchmark >> benchBDF3 [
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchBDF4 [
| solver stepper |
- stepper := BDF4Stepper onSystem: system.
- solver := (BDF4Solver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := (PMBDF4Solver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -55,8 +55,8 @@ PMImplicitMultiBenchmark >> benchBDF4 [
{ #category : #benchmarking }
PMImplicitMultiBenchmark >> benchTrapezoidAM2 [
| solver stepper |
- stepper := TrapezoidStepper onSystem: system.
- solver := (ImplicitSolver new) stepper: stepper; system: system; dt: dt.
+ stepper := PMTrapezoidStepper onSystem: system.
+ solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt.
1 to: self problemSize do: [ :i
|solver solve: system startState: startState startTime:startTime endTime: endTime]
]
@@ -64,5 +64,5 @@ PMImplicitMultiBenchmark >> benchTrapezoidAM2 [
{ #category : #'as yet unclassified' }
PMImplicitMultiBenchmark >> setUp [
super setUp.
- system := ImplicitSystem block: function
+ system := PMImplicitSystem block: function
]
diff --git a/src/Math-Clustering/PMMahalanobisCenter.class.st b/src/Math-Clustering/PMMahalanobisCenter.class.st
index f989b2fc7..b3ac47257 100644
--- a/src/Math-Clustering/PMMahalanobisCenter.class.st
+++ b/src/Math-Clustering/PMMahalanobisCenter.class.st
@@ -65,8 +65,6 @@ PMMahalanobisCenter >> initialize: anInteger [
{ #category : #printing }
PMMahalanobisCenter >> printOn: aStream [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/16/00 "
accumulator count printOn: aStream.
aStream nextPutAll: ': '.
center printOn: aStream.
diff --git a/src/Math-Complex/PMComplex.class.st b/src/Math-Complex/PMComplex.class.st
index edd8fc131..5981da17c 100644
--- a/src/Math-Complex/PMComplex.class.st
+++ b/src/Math-Complex/PMComplex.class.st
@@ -80,7 +80,7 @@ Class {
'real',
'imaginary'
],
- #category : 'Math-Complex'
+ #category : #'Math-Complex'
}
{ #category : #'instance creation' }
@@ -210,6 +210,12 @@ PMComplex >> absSecure [
ifFalse: [(self class real: real / scale imaginary: imaginary / scale) squaredNorm sqrt * scale]
]
+{ #category : #arithmetic }
+PMComplex >> absSquared [
+
+ ^ self real * self real + (self imaginary * self imaginary)
+]
+
{ #category : #converting }
PMComplex >> adaptToCollection: rcvr andSend: selector [
"If I am involved in arithmetic with a Collection, return a Collection of
diff --git a/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st b/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st
deleted file mode 100644
index 92dfc92c2..000000000
--- a/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st
+++ /dev/null
@@ -1,13 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathCoreDistribution,
- #superclass : #PackageManifest,
- #category : 'Math-Core-Distribution'
-}
-
-{ #category : #'code-critics' }
-ManifestMathCoreDistribution class >> ruleRBCodeCruftLeftInMethodsRuleV1FalsePositive [
- ^ #(#(#(#RGMethodDefinition #(#'DhbProbabilityDensity class' #fromHistogram: #true)) #'2016-03-02T09:06:24.499812+01:00') )
-]
diff --git a/src/Math-Core-Distribution/PMErfApproximation.class.st b/src/Math-Core-Distribution/PMErfApproximation.class.st
index fb0d04cba..b8838fe1c 100644
--- a/src/Math-Core-Distribution/PMErfApproximation.class.st
+++ b/src/Math-Core-Distribution/PMErfApproximation.class.st
@@ -20,14 +20,12 @@ errorFunction := [:x | x errorFunction].
Instance variables constant and series are part of the approximation formula. norm is a scale factor to make erf(infinity) = 1.
-The error function is the Cumulative Distribution of the standard normal distribution. Thus, erf(x) represents the probability of a random variable with standard normal distribution being less than x. The approximation used is credited to Abramowitz and Stegun's Handbook of Mathematical Functions. The error function is detailed in Chapter 7. The implementation is detailed in Besset's book Section 2.3
+The error function is the Cumulative Distribution of the standard normal distribution. Thus, erf(x) represents the probability of a random variable with standard normal distribution being less than x. The approximation used is credited to Abramowitz and Stegun's Handbook of Mathematical Functions. The error function is detailed in Chapter 7. The implementation is detailed in PM's book Section 2.3
Additional resources available from NIST Digital Library of Mathematics at:
http://dlmf.nist.gov/7
-(c) Copyrights Didier BESSET, 1999.
-
"
Class {
#name : #PMErfApproximation,
@@ -40,7 +38,7 @@ Class {
#classVars : [
'UniqueInstance'
],
- #category : 'Math-Core-Distribution'
+ #category : #'Math-Core-Distribution'
}
{ #category : #creation }
diff --git a/src/Math-Core-Distribution/PMMitchellMooreGenerator.class.st b/src/Math-Core-Distribution/PMMitchellMooreGenerator.class.st
index 1638852d6..9f1190011 100644
--- a/src/Math-Core-Distribution/PMMitchellMooreGenerator.class.st
+++ b/src/Math-Core-Distribution/PMMitchellMooreGenerator.class.st
@@ -35,8 +35,6 @@ PMMitchellMooreGenerator class >> generateSeeds: congruentialGenerator [
{ #category : #creation }
PMMitchellMooreGenerator class >> new [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 1/11/00 "
UniqueInstance isNil
ifTrue: [ UniqueInstance := self default].
^UniqueInstance
diff --git a/src/Math-Core/ManifestMathCore.class.st b/src/Math-Core/ManifestMathCore.class.st
deleted file mode 100644
index 67b9138bb..000000000
--- a/src/Math-Core/ManifestMathCore.class.st
+++ /dev/null
@@ -1,8 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathCore,
- #superclass : #PackageManifest,
- #category : 'Math-Core'
-}
diff --git a/src/Math-Core/PMFloatingPointMachine.class.st b/src/Math-Core/PMFloatingPointMachine.class.st
index c4b3db4e7..26b9a0620 100644
--- a/src/Math-Core/PMFloatingPointMachine.class.st
+++ b/src/Math-Core/PMFloatingPointMachine.class.st
@@ -1,5 +1,5 @@
"
-A DhbFloatingPointMachine represents the numerical precision of this system.
+A PMFloatingPointMachine represents the numerical precision of this system.
Instance Variables
@@ -26,8 +26,6 @@ largestExponentArgument
This class is detailed in Object Oriented Implementation of Numerical Methods, Section 1.4.1 and 1.4.2.
-(c) Copyrights Didier BESSET, 1999.
-
"
Class {
#name : #PMFloatingPointMachine,
@@ -45,20 +43,18 @@ Class {
#classVars : [
'UniqueInstance'
],
- #category : 'Math-Core'
+ #category : #'Math-Core'
}
-{ #category : #creation }
+{ #category : #'instance creation' }
PMFloatingPointMachine class >> new [
-
- UniqueInstance ifNil: [ UniqueInstance := super new].
+ UniqueInstance ifNil: [ UniqueInstance := super new ].
^ UniqueInstance
]
-{ #category : #creation }
+{ #category : #accessing }
PMFloatingPointMachine class >> reset [
-
- UniqueInstance := nil.
+ UniqueInstance := nil
]
{ #category : #information }
@@ -73,7 +69,7 @@ PMFloatingPointMachine >> computeLargestNumber [
fullMantissaNumber isInfinite ifTrue: [^nil].
largestNumber := fullMantissaNumber.
true] whileTrue: [ ].
- ] on: Error do: [ :signal | signal return: nil].
+ ] on: Error do: [ :signal | signal return: nil]
]
{ #category : #information }
@@ -86,7 +82,7 @@ PMFloatingPointMachine >> computeMachinePrecision [
machinePrecision := one.
[ tmp := one + machinePrecision.
tmp - one = zero]
- whileFalse:[ machinePrecision := machinePrecision * inverseRadix].
+ whileFalse:[ machinePrecision := machinePrecision * inverseRadix]
]
{ #category : #information }
@@ -100,7 +96,7 @@ PMFloatingPointMachine >> computeNegativeMachinePrecision [
negativeMachinePrecision := one.
[ tmp := one - negativeMachinePrecision.
tmp - one = zero]
- whileFalse:[ negativeMachinePrecision := negativeMachinePrecision * inverseRadix].
+ whileFalse:[ negativeMachinePrecision := negativeMachinePrecision * inverseRadix]
]
{ #category : #information }
@@ -118,7 +114,7 @@ PMFloatingPointMachine >> computeRadix [
[ b := b + b.
tmp1 := a + b.
radix := ( tmp1 - a) truncated.
- radix = 0 ] whileTrue: [].
+ radix = 0 ] whileTrue: []
]
{ #category : #information }
@@ -189,7 +185,6 @@ PMFloatingPointMachine >> radix [
{ #category : #display }
PMFloatingPointMachine >> showParameters [
- "added 'Transcript flush' to make sure that the transcript window gets updated"
Transcript cr; cr;
nextPutAll: 'Floating-point machine parameters'; cr;
nextPutAll: '---------------------------------';cr;
@@ -203,7 +198,7 @@ PMFloatingPointMachine >> showParameters [
self smallestNumber printOn: Transcript.
Transcript cr; nextPutAll: 'Largest number: '.
self largestNumber printOn: Transcript.
- Transcript flush.
+ Transcript flush
]
{ #category : #information }
diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st
index 8d1652cb3..4820c79d1 100644
--- a/src/Math-Core/PMVector.class.st
+++ b/src/Math-Core/PMVector.class.st
@@ -70,35 +70,21 @@ PMVector >> + aVectorOrNumber [
]
{ #category : #operation }
-PMVector >> - aVector [
- "Answers the difference of the receiver with aVector."
- | answer n |
- answer := self class new: self size.
- n := 0.
- self with: aVector do:
- [ :a :b |
- n := n + 1.
- answer at: n put: ( a - b).
- ].
- ^answer
+PMVector >> - aVectorOrNumber [
+ "Answers the difference of the receiver with a vector or number."
+ ^ -1*aVectorOrNumber addWithVector: self
]
{ #category : #operation }
PMVector >> < aNumber [
- "Apply < operator to every element of a vector"
- 1 to: self size do: [ :n | self at: n put: (self at: n) < aNumber].
-]
-
-{ #category : #comparing }
-PMVector >> == aNumber [
- "Apply == operator to every element of a vector"
- 1 to: self size do: [ :n | self at: n put: (self at: n) == aNumber].
+ "Apply < operator to every element of a vector and returns a new vector"
+ ^ ((1 to: self size) collect: [ :n | (self at: n) < aNumber]) asPMVector.
]
{ #category : #operation }
PMVector >> > aNumber [
- "Apply > function to every element of a vector"
- 1 to: self size do: [ :n | self at: n put: (self at: n) > aNumber].
+ "Apply > function to every element of a vector and return a new vector"
+ ^ ((1 to: self size) collect: [ :n | (self at: n) > aNumber]) asPMVector.
]
{ #category : #transformation }
@@ -113,6 +99,13 @@ PMVector >> accumulateNegated: aVectorOrAnArray [
1 to: self size do: [ :n | self at: n put: ((self at: n) - (aVectorOrAnArray at: n))].
]
+{ #category : #'as yet unclassified' }
+PMVector >> argMax [
+ | a |
+ a := self asArray.
+ ^ a indexOf: a max
+]
+
{ #category : #converting }
PMVector >> asArray [
@@ -129,6 +122,18 @@ PMVector >> asPMVector [
^ self
]
+{ #category : #'as yet unclassified' }
+PMVector >> checkDimensionalCompatibility: dimensionArray [
+ |prod|
+ prod := 1.
+
+ dimensionArray do: [ :each | prod := prod * each ].
+
+ self assert: (self size = prod) description: 'Imcompatible combination of Dimensions provided'.
+
+ ^true
+]
+
{ #category : #comparing }
PMVector >> closeTo: aPMVector [
"Compare two vectors using the default precision from Float >> #closeTo:."
@@ -167,18 +172,18 @@ PMVector >> cumsum [
]
{ #category : #operation }
-PMVector >> dot: aVector [
-"Answers the elementwise product of the receiver with aVector."
+PMVector >> hadamardProduct: aVector [
+ "Answers the elementwise product of the receiver with aVector."
+
| answer n |
answer := self class new: self size.
n := 0.
- self with: aVector do:
- [ :a :b |
- n := n + 1.
- answer at: n put: ( a * b).
- ].
- ^answer
-
+ self
+ with: aVector
+ do: [ :a :b |
+ n := n + 1.
+ answer at: n put: a * b ].
+ ^ answer
]
{ #category : #'as yet unclassified' }
@@ -244,6 +249,17 @@ PMVector >> productWithVector: aVector [
into: [ :sum :each | n := n + 1. (aVector at: n) * each + sum]
]
+{ #category : #'as yet unclassified' }
+PMVector >> reshapeWithDimensions: dimensionArray [
+ | computedRows rowNum colNum |
+ self checkDimensionalCompatibility: dimensionArray.
+ rowNum := dimensionArray at: 1.
+ colNum := dimensionArray at: 2.
+ computedRows := ((1 to: rowNum) collect: [ :i | (1 to: colNum) collect: [ :j | self at: (i-1*colNum)+j ] ]).
+
+ ^PMMatrix rows: computedRows
+]
+
{ #category : #operation }
PMVector >> scalarProduct: aVector [
@@ -292,15 +308,6 @@ PMVector >> sqrt [
1 to: self size do: [ :n | self at: n put: (self at: n) sqrt ]
]
-{ #category : #transformation }
-PMVector >> sum [
- "Compute the sum of a vector."
- |a|
- a := 0.
- 1 to: self size do: [ :n | a := a + self at: n].
- ^a.
-]
-
{ #category : #operation }
PMVector >> tan [
"Apply tan function to every element of a vector"
diff --git a/src/Math-DHB-Numerical/Number.extension.st b/src/Math-DHB-Numerical/Number.extension.st
deleted file mode 100644
index af3da97b7..000000000
--- a/src/Math-DHB-Numerical/Number.extension.st
+++ /dev/null
@@ -1,126 +0,0 @@
-Extension { #name : #Number }
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> addPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99 "
- ^aPolynomial addNumber: self
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> beta: aNumber [
- "Computes the beta function of the receiver and aNumber
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/3/99 "
- ^( self logBeta: aNumber) exp
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> dividingPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99 "
- ^aPolynomial timesNumber: (1 / self)
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> equalsTo: aNumber [
- "compare to Float>>closeTo:"
- ^self relativelyEqualsTo: aNumber upTo: PMFloatingPointMachine new defaultNumericalPrecision
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> errorFunction [
- "Answer the error function for the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
- ^ PMErfApproximation new value: self
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> gamma [
- "Compute the Gamma function for the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
- ^ self > 1
- ifTrue: [ ^ PMLanczosFormula new gamma: self]
- ifFalse:[ self < 0
- ifTrue: [ Float pi / ( ( Float pi * self) sin * ( 1 - self) gamma)]
- ifFalse:[ ( PMLanczosFormula new gamma: ( self + 1)) / self]
- ]
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> logBeta: aNumber [
- "Computes the logarithm of the beta function of the receiver and aNumber
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/3/99 "
- ^self logGamma + aNumber logGamma - ( self + aNumber) logGamma
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> logGamma [
- "Computes the log of the Gamma function (for positive numbers only)
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/3/99 "
- ^self > 1
- ifTrue: [ PMLanczosFormula new logGamma: self]
- ifFalse:[ self > 0
- ifTrue: [ ( PMLanczosFormula new logGamma: ( self + 1) ) - self ln ]
- ifFalse: [ ^self error: 'Argument for the log gamma function must be positive']
- ]
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> productWithMatrix: aMatrix [
-^aMatrix class rows: (aMatrix rowsCollect: [:r| self productWithVector: r])
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> productWithVector: aVector [
- "Answers a new vector product of the receiver with aVector.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
- ^aVector collect: [ :each | each * self]
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> random [
- "Answers a random number distributed between 0 and the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/2/99 "
- ^self class random * self
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number class >> random [
- "Answers a random number between 0 and the receiver
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/2/99 "
- ^ PMMitchellMooreGenerator new floatValue
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> relativelyEqualsTo: aNumber upTo: aSmallNumber [
- "compare to Float>>closeTo:
- generally called from Number>>equalsTo:
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 21/4/99 "
- | norm |
- norm := self abs max: aNumber abs.
- ^norm <= PMFloatingPointMachine new defaultNumericalPrecision
- or: [ (self - aNumber) abs < ( aSmallNumber * norm)]
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> subtractToPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99 "
- ^aPolynomial addNumber: self negated
-]
-
-{ #category : #'*Math-DHB-Numerical' }
-Number >> timesPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99 "
- ^aPolynomial timesNumber: self
-]
diff --git a/src/Math-DHB-Numerical/package.st b/src/Math-DHB-Numerical/package.st
deleted file mode 100644
index b294af993..000000000
--- a/src/Math-DHB-Numerical/package.st
+++ /dev/null
@@ -1 +0,0 @@
-Package { #name : #'Math-DHB-Numerical' }
diff --git a/src/Math-DistributionBeta/PMIncompleteBetaFunction.class.st b/src/Math-DistributionBeta/PMIncompleteBetaFunction.class.st
index 90bd6f094..155d131a3 100644
--- a/src/Math-DistributionBeta/PMIncompleteBetaFunction.class.st
+++ b/src/Math-DistributionBeta/PMIncompleteBetaFunction.class.st
@@ -15,7 +15,7 @@ Class {
PMIncompleteBetaFunction class >> shape: aNumber1 shape: aNumber2 [
"Create an instance of the receiver with given shape parameters."
- ^super new initialize: aNumber1 shape: aNumber2
+ ^self new initialize: aNumber1 shape: aNumber2
]
{ #category : #private }
diff --git a/src/Math-DistributionForHistogram/ManifestMathDistributionForHistogram.class.st b/src/Math-DistributionForHistogram/ManifestMathDistributionForHistogram.class.st
deleted file mode 100644
index e4f34fc0d..000000000
--- a/src/Math-DistributionForHistogram/ManifestMathDistributionForHistogram.class.st
+++ /dev/null
@@ -1,8 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathDistributionForHistogram,
- #superclass : #PackageManifest,
- #category : 'Math-DistributionForHistogram'
-}
diff --git a/src/Math-DistributionGamma/PMGammaDistribution.class.st b/src/Math-DistributionGamma/PMGammaDistribution.class.st
index 1a82392b4..f88c0486a 100644
--- a/src/Math-DistributionGamma/PMGammaDistribution.class.st
+++ b/src/Math-DistributionGamma/PMGammaDistribution.class.st
@@ -147,9 +147,7 @@ PMGammaDistribution >> randomCoefficientsForSmallAlpha [
{ #category : #information }
PMGammaDistribution >> randomForLargeAlpha [
"Private - Generate a random number distributed according to the receiver
- when alpha > 1.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 4/3/99 "
+ when alpha > 1."
[ true] whileTrue: [
| u1 u2 c v y z w|
u1 := flatGenerator floatValue.
diff --git a/src/Math-DistributionGamma/PMIncompleteGammaFunction.class.st b/src/Math-DistributionGamma/PMIncompleteGammaFunction.class.st
index a7bc71cb6..0ee6188db 100644
--- a/src/Math-DistributionGamma/PMIncompleteGammaFunction.class.st
+++ b/src/Math-DistributionGamma/PMIncompleteGammaFunction.class.st
@@ -13,7 +13,7 @@ Class {
{ #category : #creation }
PMIncompleteGammaFunction class >> shape: aNumber [
"Defines a new instance of the receiver with paramater aNumber"
- ^super new initialize: aNumber
+ ^self new initialize: aNumber
]
{ #category : #private }
diff --git a/src/Math-FunctionFit/PMFunctionFit.class.st b/src/Math-FunctionFit/PMFunctionFit.class.st
index cdb385d3a..ae69428c4 100644
--- a/src/Math-FunctionFit/PMFunctionFit.class.st
+++ b/src/Math-FunctionFit/PMFunctionFit.class.st
@@ -29,9 +29,6 @@ PMFunctionFit class >> points: aDataHolder function: aBlock [
{ #category : #operation }
PMFunctionFit >> accumulate: aWeightedPoint [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/3/99 "
| f g |
f := result valueAndGradient: aWeightedPoint xValue.
g := f last.
diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st
index 5051acb76..d174563b4 100644
--- a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st
+++ b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st
@@ -14,12 +14,12 @@ ks rejectEqualityHypothesisWithAlpha: 0.05.""--> false""
"
Class {
#name : #PMKolmogorovSmirnov1Sample,
- #superclass : #PMKolmogorovSmirnov,
+ #superclass : #PMKolmogorovSmirnovSample,
#instVars : [
'distribution',
'popDistribution'
],
- #category : 'Math-KolmogorovSmirnov'
+ #category : #'Math-KolmogorovSmirnov'
}
{ #category : #'instance creation' }
@@ -32,52 +32,52 @@ PMKolmogorovSmirnov1Sample class >> data: aCollection [
^self new data: aCollection ;yourself
]
-{ #category : #accessing }
-PMKolmogorovSmirnov1Sample >> cdf: aBlock [
-"the cumulative distribution function to be used. can also be set via #populationDistribution:"
-popDistribution:=nil.
-compareWith := aBlock
-]
-
{ #category : #accessing }
PMKolmogorovSmirnov1Sample >> data: aCollection [
-distribution := PMKolmogorovsDistribution exampleSize: aCollection size.
-^data := aCollection asSortedCollection .
+ distribution := PMKolmogorovsDistribution
+ exampleSize: aCollection size.
+ ^ data := aCollection asSortedCollection
]
{ #category : #accessing }
PMKolmogorovSmirnov1Sample >> ksStatistic [
-"the kolmogorov-smirnov statistic D"
-|s d|
-self testDataComplete .
-s:=data size.
-d:=(1 to:s) collect: [:i||f| f:=compareWith value:(data at:i).(f -((i-1)/s))max: ((i/s)-f)].
-^d max.
+ "the kolmogorov-smirnov statistic D"
+ | s d |
+ s := data size.
+ d := (1 to: s)
+ collect: [ :i |
+ | f |
+ f := compareWith value: (data at: i).
+ f - ((i - 1) / s) max: i / s - f ].
+ ^ d max
]
{ #category : #accessing }
PMKolmogorovSmirnov1Sample >> pValue [
-"the probability of getting a ksStatistic <= the actual one"
-^distribution distributionValue: self ksStatistic .
+ "the probability of getting a ksStatistic <= the actual one"
+ ^ distribution distributionValue: self ksStatistic
]
{ #category : #accessing }
PMKolmogorovSmirnov1Sample >> populationDistribution: aDistribution [
-"utility, a simple alternative method to set cdf."
-popDistribution:=aDistribution.
-popDistribution distributionValue: 0.95."just a test whether it understands #distributionValue:, to raise a dnu early enough because of this block:"
-compareWith :=[:x|popDistribution distributionValue:x ]
+ "utility, a simple alternative method to set cdf."
+
+ popDistribution := aDistribution.
+ popDistribution distributionValue: 0.95. "just a test whether it understands #distributionValue:, to raise a dnu early enough because of this block:"
+ compareWith := [ :x | popDistribution distributionValue: x ]
]
{ #category : #printing }
-PMKolmogorovSmirnov1Sample >> print2On: aStream [
- aStream nextPutAll:' cdf: '.
- compareWith
- ifNil: [aStream nextPut: $-]
- ifNotNil:[popDistribution
- ifNil:[compareWith printOn: aStream]
- ifNotNil:[aStream nextPutAll: 'distributionValue of '. popDistribution printOn: aStream ]].
- aStream nextPut: $).
+PMKolmogorovSmirnov1Sample >> printOn: aStream [
+ super printOn: aStream.
+ aStream nextPutAll: ' cdf: '.
+ compareWith
+ ifNil: [ aStream nextPut: $- ]
+ ifNotNil: [ popDistribution
+ ifNil: [ compareWith printOn: aStream ]
+ ifNotNil: [ aStream nextPutAll: 'distributionValue of '.
+ popDistribution printOn: aStream ] ].
+ aStream nextPut: $)
]
diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st
index 62e19103e..0791765c8 100644
--- a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st
+++ b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st
@@ -22,14 +22,14 @@ no aproximation is at the moment used for bigger datasizes, hence calcs will be
"
Class {
#name : #PMKolmogorovSmirnov2Sample,
- #superclass : #PMKolmogorovSmirnov,
+ #superclass : #PMKolmogorovSmirnovSample,
#instVars : [
'uCalcBlock',
'smallSize',
'bigSize',
'ksStatistic'
],
- #category : 'Math-KolmogorovSmirnov'
+ #category : #'Math-KolmogorovSmirnov'
}
{ #category : #'instance creation' }
@@ -38,97 +38,134 @@ PMKolmogorovSmirnov2Sample class >> compareData: aCollection withData: anotherCo
]
{ #category : #private }
-PMKolmogorovSmirnov2Sample >> cFrom:i and:j [
-"needs ksStatistic!"
-^ (i/smallSize -(j/bigSize))abs < ksStatistic ifTrue:[1]ifFalse:[0]
+PMKolmogorovSmirnov2Sample >> cFrom: i and: j [
+ "needs ksStatistic!"
+ ^ (i / smallSize - (j / bigSize)) abs < ksStatistic
+ ifTrue: [ 1 ]
+ ifFalse: [ 0 ]
]
{ #category : #accessing }
PMKolmogorovSmirnov2Sample >> data: aCollection [
-ksStatistic:=nil.
-^self makeCDFOf: aCollection intoFirst: true .
+ ksStatistic := nil.
+ ^ self makeCDFOf: aCollection intoFirst: true
]
{ #category : #initialization }
PMKolmogorovSmirnov2Sample >> initCachedUCalculation [
-"recursive calc, slow without memoization"
-uCalcBlock:=[:iandj||cij i j|
-i:=iandj first.j:=iandj second.
-cij:=self cFrom: i and: j.
-i*j=0
- ifTrue:[ cij]
- ifFalse:[cij * ((uCalcBlock value:{i.j-1})+(uCalcBlock value:{i-1.j}))]]memoized.
+ "recursive calc, slow without memoization"
+
+ uCalcBlock := [ :iandj |
+ | cij i j |
+ i := iandj first.
+ j := iandj second.
+ cij := self cFrom: i and: j.
+ i * j = 0
+ ifTrue: [ cij ]
+ ifFalse: [ cij
+ *
+ ((uCalcBlock
+ value:
+ {i.
+ (j - 1)})
+ +
+ (uCalcBlock
+ value:
+ {(i - 1).
+ j})) ] ] memoized
]
{ #category : #initialization }
PMKolmogorovSmirnov2Sample >> initKSStatistic [
| t |
- ksStatistic :=0.
- self initCachedUCalculation. "needs to be set lately, iow here"
+ ksStatistic := 0.
+ self initCachedUCalculation. "needs to be set lately, iow here"
smallSize := data size.
bigSize := compareWith size.
- smallSize > bigSize ifFalse: [ ^ self ].
+ smallSize > bigSize
+ ifFalse: [ ^ self ].
t := smallSize.
smallSize := bigSize.
- bigSize := t.
-
+ bigSize := t
]
{ #category : #accessing }
PMKolmogorovSmirnov2Sample >> ksStatistic [
-"the kolmogorov-smirnov statistic D"
-|c1 c2 cdfs s|
-self testDataComplete .
-self initKSStatistic .
-c1:=0. c2:=0.
-s:=smallSize + bigSize.
-cdfs := (SortedCollection new:s) addAll: data; addAll: compareWith; yourself.
-cdfs withIndexDo: [:a :i|
- (i> makeCDFOf: aCollection intoFirst: aBoolean [
-"if aCollection consists of numbers,
+ "if aCollection consists of numbers,
it returns a sorted array of (number->{cdf.aBoolean})"
-|cd s result|
-cd:=0.
-s:=aCollection size.
-result:=aCollection asBag sortedElements do:[:a|
- cd:=a value/s+cd.
- a value: {cd. aBoolean}].
-^aBoolean ifTrue: [ data:=result ]
- ifFalse:[compareWith :=result]
+
+ | cd s result |
+ cd := 0.
+ s := aCollection size.
+ result := aCollection asBag sortedElements
+ do: [ :a |
+ cd := a value / s + cd.
+ a
+ value:
+ {cd.
+ aBoolean} ].
+ ^ aBoolean
+ ifTrue: [ data := result ]
+ ifFalse: [ compareWith := result ]
]
{ #category : #accessing }
PMKolmogorovSmirnov2Sample >> otherData: aCollection [
-ksStatistic:=nil.
-^self makeCDFOf: aCollection intoFirst: false .
+ ksStatistic := nil.
+ ^ self makeCDFOf: aCollection intoFirst: false
]
{ #category : #accessing }
PMKolmogorovSmirnov2Sample >> pValue [
-"uses procedure explained in:
+ "uses procedure explained in:
Kim, P. J. & Jennrich, R. I.
'Tables of the exact sampling distribution of the two-sample Kolmogorov–Smirnov criterion...'
in 'Selected Tables in Mathematical Statistics Volume I' (1973)."
-ksStatistic ifNil: [self ksStatistic ].
-^ (uCalcBlock value: {smallSize.bigSize})/ ((smallSize + bigSize) take:smallSize)
+
+ ksStatistic ifNil: [ self ksStatistic ].
+ ^ (uCalcBlock
+ value:
+ {smallSize.
+ bigSize}) / (smallSize + bigSize take: smallSize)
]
{ #category : #printing }
-PMKolmogorovSmirnov2Sample >> print2On: aStream [
+PMKolmogorovSmirnov2Sample >> printOn: aStream [
+ super printOn: aStream.
aStream nextPutAll: ' otherDataSize: '.
- compareWith ifNil:[aStream nextPut: $-]ifNotNil:[compareWith size printOn: aStream].
- aStream nextPut: $).
-
+ compareWith
+ ifNil: [ aStream nextPut: $- ]
+ ifNotNil: [ compareWith size printOn: aStream ].
+ aStream nextPut: $)
]
diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnovSample.class.st
similarity index 50%
rename from src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov.class.st
rename to src/Math-KolmogorovSmirnov/PMKolmogorovSmirnovSample.class.st
index 60e72b31b..5f326bde4 100644
--- a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov.class.st
+++ b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnovSample.class.st
@@ -2,60 +2,49 @@
abstract class, use KolmogorovSmirnov1Sample or KolmogorovSmirnov2Sample
"
Class {
- #name : #PMKolmogorovSmirnov,
+ #name : #PMKolmogorovSmirnovSample,
#superclass : #Object,
#instVars : [
'data',
'compareWith'
],
- #category : 'Math-KolmogorovSmirnov'
+ #category : #'Math-KolmogorovSmirnov'
}
{ #category : #accessing }
-PMKolmogorovSmirnov >> data: aCollection [
+PMKolmogorovSmirnovSample >> data: aCollection [
^self subclassResponsibility
]
{ #category : #accessing }
-PMKolmogorovSmirnov >> ksStatistic [
+PMKolmogorovSmirnovSample >> ksStatistic [
"the kolmogorov-smirnov statistic D"
^self subclassResponsibility
]
{ #category : #accessing }
-PMKolmogorovSmirnov >> pValue [
+PMKolmogorovSmirnovSample >> pValue [
"the probability of getting a ksStatistic <= the actual one"
^self subclassResponsibility
]
{ #category : #printing }
-PMKolmogorovSmirnov >> print1On: aStream [
- super printOn: aStream .
+PMKolmogorovSmirnovSample >> printOn: aStream [
+ super printOn: aStream.
aStream nextPutAll: '(dataSize: '.
- data ifNil:[aStream nextPut: $-]ifNotNil:[data size printOn: aStream].
-
-]
-
-{ #category : #printing }
-PMKolmogorovSmirnov >> print2On: aStream [
-^self subclassResponsibility
-]
-
-{ #category : #printing }
-PMKolmogorovSmirnov >> printOn: aStream [
- self print1On: aStream .
- self print2On: aStream .
-
+ data
+ ifNil: [ aStream nextPut: $- ]
+ ifNotNil: [ data size printOn: aStream ]
]
{ #category : #accessing }
-PMKolmogorovSmirnov >> rejectEqualityHypothesisWithAlpha: aFloat [
+PMKolmogorovSmirnovSample >> rejectEqualityHypothesisWithAlpha: aFloat [
^self pValue > (1-aFloat)
]
{ #category : #private }
-PMKolmogorovSmirnov >> testDataComplete [
+PMKolmogorovSmirnovSample >> testDataComplete [
(data isNil or:[compareWith isNil ]) ifTrue: [ self error:'data not completely set' ].
]
diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovsDistribution.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovsDistribution.class.st
index 204cddca7..cb00c7004 100644
--- a/src/Math-KolmogorovSmirnov/PMKolmogorovsDistribution.class.st
+++ b/src/Math-KolmogorovSmirnov/PMKolmogorovsDistribution.class.st
@@ -12,7 +12,7 @@ Class {
'distribution',
'n'
],
- #category : 'Math-KolmogorovSmirnov'
+ #category : #'Math-KolmogorovSmirnov'
}
{ #category : #information }
diff --git a/src/Math-Matrix/ManifestMathMatrix.class.st b/src/Math-Matrix/ManifestMathMatrix.class.st
deleted file mode 100644
index 73f66980a..000000000
--- a/src/Math-Matrix/ManifestMathMatrix.class.st
+++ /dev/null
@@ -1,23 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathMatrix,
- #superclass : #PackageManifest,
- #category : 'Math-Matrix'
-}
-
-{ #category : #'code-critics' }
-ManifestMathMatrix class >> ruleRBInconsistentMethodClassificationRuleV1FalsePositive [
- ^ #(#(#(#RGMethodDefinition #(#PMMatrix #tr #false)) #'2017-02-11T12:20:26.44992+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathMatrix class >> ruleRBRefersToClassRuleV1FalsePositive [
- ^ #(#(#(#RGClassDefinition #(#PMMatrix)) #'2017-02-10T16:21:29.311293+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathMatrix class >> ruleRBSelfSentNotImplementedRuleV1FalsePositive [
- ^ #(#(#(#RGClassDefinition #(#PMMatrix)) #'2017-02-11T12:20:10.550284+02:00') )
-]
diff --git a/src/Math-Matrix/PMJacobiTransformation.class.st b/src/Math-Matrix/PMJacobiTransformation.class.st
index 137489a90..924355ac1 100644
--- a/src/Math-Matrix/PMJacobiTransformation.class.st
+++ b/src/Math-Matrix/PMJacobiTransformation.class.st
@@ -1,5 +1,5 @@
"
-[[[
+[[[
| m jacobi eigenvalues eigenvectors |
m := PMSymmetricMatrix rows: #((84 -79 58 55)
(-79 84 -55 -58)
@@ -17,7 +17,7 @@ Class {
'lowerRows',
'transform'
],
- #category : 'Math-Matrix'
+ #category : #'Math-Matrix'
}
{ #category : #creation }
@@ -34,8 +34,6 @@ PMJacobiTransformation class >> new [
{ #category : #operation }
PMJacobiTransformation >> evaluateIteration [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
| indices |
indices := self largestOffDiagonalIndices.
self transformAt: ( indices at: 1) and: ( indices at: 2).
@@ -44,9 +42,7 @@ PMJacobiTransformation >> evaluateIteration [
{ #category : #transformation }
PMJacobiTransformation >> exchangeAt: anInteger [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Private"
| temp n |
n := anInteger + 1.
temp := result at: n.
@@ -63,9 +59,7 @@ PMJacobiTransformation >> exchangeAt: anInteger [
{ #category : #operation }
PMJacobiTransformation >> finalizeIterations [
"Transfer the eigenValues into a vector and set this as the result.
- eigen values and transform matrix are sorted using a bubble sort.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ eigen values and transform matrix are sorted using a bubble sort."
| n |
n := 0.
@@ -78,9 +72,7 @@ PMJacobiTransformation >> finalizeIterations [
{ #category : #initialization }
PMJacobiTransformation >> initialize: aSymmetricMatrix [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Private"
| n |
n := aSymmetricMatrix numberOfRows.
lowerRows := Array new: n.
@@ -89,15 +81,12 @@ PMJacobiTransformation >> initialize: aSymmetricMatrix [
[ :k |
lowerRows at: k put: ( ( aSymmetricMatrix rowAt: k) copyFrom: 1 to: k).
transform at: k put: ( ( Array new: n) atAllPut: 0; at: k put: 1; yourself).
- ].
- ^self
+ ]
]
{ #category : #information }
PMJacobiTransformation >> largestOffDiagonalIndices [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Private"
| n m abs |
n := 2.
m := 1.
@@ -119,9 +108,7 @@ PMJacobiTransformation >> largestOffDiagonalIndices [
{ #category : #display }
PMJacobiTransformation >> printOn: aStream [
- "Append to the argument aStream, a sequence of characters that describes the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Append to the argument aStream, a sequence of characters that describes the receiver."
| first |
first := true.
lowerRows do:
@@ -134,9 +121,7 @@ PMJacobiTransformation >> printOn: aStream [
{ #category : #transformation }
PMJacobiTransformation >> sortEigenValues [
- "Private - Use a bubble sort.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Private - Use a bubble sort."
| n bound m |
n := lowerRows size.
bound := n.
@@ -155,16 +140,12 @@ PMJacobiTransformation >> sortEigenValues [
{ #category : #information }
PMJacobiTransformation >> transform [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
^PMMatrix rows: transform
]
{ #category : #transformation }
PMJacobiTransformation >> transformAt: anInteger1 and: anInteger2 [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 1/6/99 "
+ "Private"
| d t s c tau apq app aqq arp arq |
apq := ( lowerRows at: anInteger2) at: anInteger1.
apq = 0
diff --git a/src/Math-Matrix/PMLargestEigenValueFinder.class.st b/src/Math-Matrix/PMLargestEigenValueFinder.class.st
index 02ab3d37e..06dfac388 100644
--- a/src/Math-Matrix/PMLargestEigenValueFinder.class.st
+++ b/src/Math-Matrix/PMLargestEigenValueFinder.class.st
@@ -50,27 +50,21 @@ PMLargestEigenValueFinder class >> matrix: aMatrix precision: aNumber [
{ #category : #information }
PMLargestEigenValueFinder >> eigenvalue [
- "Answer the eigen value found by the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
+ "Answer the eigen value found by the receiver."
^result
]
{ #category : #information }
PMLargestEigenValueFinder >> eigenvector [
- "Answer the normalized eigen vector found by the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
+ "Answer the normalized eigen vector found by the receiver."
^eigenvector * (1 / eigenvector norm)
]
{ #category : #operation }
PMLargestEigenValueFinder >> evaluateIteration [
- "Iterate the product of the matrix of the eigen vector and the transpose.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 6/1/99 "
+ "Iterate the product of the matrix of the eigen vector and the transpose."
| oldEigenvalue |
oldEigenvalue := result.
@@ -87,17 +81,13 @@ PMLargestEigenValueFinder >> evaluateIteration [
{ #category : #initialization }
PMLargestEigenValueFinder >> initialize: aMatrix [
- "Defines the matrix for the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
+ "Defines the matrix for the receiver."
matrix := aMatrix.
]
{ #category : #operation }
PMLargestEigenValueFinder >> initializeIterations [
- "Initialize the iterations (subclasses must write their own method and call this one last).
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 6/1/99 "
+ "Initialize the iterations (subclasses must write their own method and call this one last)."
eigenvector := PMVector new: matrix numberOfRows.
eigenvector atAllPut: 1.0.
@@ -107,9 +97,7 @@ PMLargestEigenValueFinder >> initializeIterations [
{ #category : #creation }
PMLargestEigenValueFinder >> nextLargestEigenValueFinder [
- "Return an eigen value finder for the same eigen values of the receiver except the one found.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
+ "Return an eigen value finder for the same eigen values of the receiver except the one found."
| norm |
norm := 1 / (eigenvector * transposeEigenvector).
diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st
index 89823ece3..c4042dd64 100644
--- a/src/Math-Matrix/PMMatrix.class.st
+++ b/src/Math-Matrix/PMMatrix.class.st
@@ -31,7 +31,7 @@ b := PMMatrix rows: #( ( 1 2 3 ) (-2 1 7)).
c := a * b.
"Elementwise matrix product"
-d := a dot:b.
+d := a hadamardProduct: b.
"This is how we can create a vector"
a := #(1 4 9 16 25) asPMVector.
@@ -124,6 +124,22 @@ PMMatrix class >> rows: anArrayOrVector [
^ self new initializeRows: anArrayOrVector
]
+{ #category : #'instance creation' }
+PMMatrix class >> rows: rowsInteger columns: columnsInteger [
+
+ ^ self new initializeRows: rowsInteger columns: columnsInteger
+]
+
+{ #category : #'instance creation' }
+PMMatrix class >> rows: nRows columns: nCols element: fillElement [
+ " Answer a new matrix of nRows x nCols initialized with fillElement in all cells "
+
+ ^ (self new initializeRows: nRows columns: nCols)
+ atAllPut: fillElement;
+ yourself
+
+]
+
{ #category : #'as yet unclassified' }
PMMatrix class >> rows: rows columns: columns random: aMaxNumber [
"Answer a new Matrix of the given dimensions filled with random numbers"
@@ -211,12 +227,27 @@ PMMatrix >> addWithSymmetricMatrix: aMatrix [
^ aMatrix addWithRegularMatrix: self
]
+{ #category : #'as yet unclassified' }
+PMMatrix >> argMaxOnColumns [
+ ^ self columnsCollect: [ :each | each argMax ]
+]
+
+{ #category : #'as yet unclassified' }
+PMMatrix >> argMaxOnRows [
+ ^ self rowsCollect: [ :each | each argMax ]
+]
+
{ #category : #transformation }
PMMatrix >> asSymmetricMatrix [
"Convert the receiver to a symmetric matrix (no check is made)."
^ PMSymmetricMatrix rows: rows
]
+{ #category : #converting }
+PMMatrix >> asVector [
+ ^ self flattenRows.
+]
+
{ #category : #'cell accessing' }
PMMatrix >> at: aRowIndex at: aColumnIndex [
"Answers the aRowIndex-th, aColumnIndex-th entry in the receiver."
@@ -231,6 +262,13 @@ PMMatrix >> at: rowIndex at: columnIndex put: value [
]
+{ #category : #'cell accessing' }
+PMMatrix >> atAllPut: element [
+ "Put element at every one of the receiver's cells."
+
+ self rowsDo: [ : row | row atAllPut: element ]
+]
+
{ #category : #'cell accessing' }
PMMatrix >> atColumn: anInteger [
@@ -246,6 +284,19 @@ PMMatrix >> atColumn: aColumnIndex put: aCollection [
]
+{ #category : #'cell accessing' }
+PMMatrix >> atColumn: columnIndex put: aValue repeat: repNumber [
+ " Example: self atColumn: 1 fillWith: 'BM1818' repeat: 3
+ produces
+ [ 'BM1818' nil nil nil
+ 'BM1818' nil nil nil
+ 'BM1818' nil nil nil
+ nil nil nil nil
+ nil nil nil nil ]
+"
+ 1 to: repNumber do: [ : index | self rowAt: index columnAt: columnIndex put: aValue ].
+]
+
{ #category : #'cell accessing' }
PMMatrix >> atColumn: aColumnNumber put: aCollection startingAt: rowNumber [
" Fill the receiver with aCollection at aColumnNumber begining at rowNumber. "
@@ -326,17 +377,15 @@ PMMatrix >> columnsDo: aBlock [
{ #category : #operation }
PMMatrix >> cos [
"Apply cos to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each cos])
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each cos ])
]
{ #category : #operation }
PMMatrix >> cosh [
"Apply cosh to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each cosh])
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each cosh ])
]
{ #category : #transformation }
@@ -363,12 +412,6 @@ PMMatrix >> dimension [
^ self rows size @ (self rows at: 1) size
]
-{ #category : #operation }
-PMMatrix >> dot: aMatrix [
- "Answers the elementwise product of the receiver with aMatrix."
- ^ aMatrix elementwiseProductWithMatrix: self
-]
-
{ #category : #operation }
PMMatrix >> eigen [
"Computes all eigenvalues and eigenvectors of a matrix.
@@ -386,7 +429,7 @@ PMMatrix >> elementwiseProductWithMatrix: aMatrix [
"Answers the elementwise product between aMatrix and the receiver as a Matrix."
| n |
n := 0.
- ^ PMMatrix rows: ( aMatrix rowsCollect: [ :each | n := n + 1. each dot: ( self rowAt: n)])
+ ^ self class rows: ( aMatrix rowsCollect: [ :each | n := n + 1. each hadamardProduct: ( self rowAt: n)])
]
@@ -398,6 +441,27 @@ PMMatrix >> equalsTo: aMatrix [
^ true
]
+{ #category : #'as yet unclassified' }
+PMMatrix >> flattenColumns [
+ | answer |
+ answer := #().
+ self columnsDo: [ :each | answer := answer , each asArray ].
+ ^ answer asPMVector
+]
+
+{ #category : #'as yet unclassified' }
+PMMatrix >> flattenRows [
+ | answer |
+ answer := #().
+ self rowsDo: [ :each | answer := answer , each asArray ].
+ ^ answer asPMVector
+]
+
+{ #category : #operation }
+PMMatrix >> hadamardProduct: aMatrix [
+ ^ aMatrix elementwiseProductWithMatrix: self
+]
+
{ #category : #comparing }
PMMatrix >> hash [
^ rows hash
@@ -415,6 +479,13 @@ PMMatrix >> initializeRows: anArrayOrVector [
rows := anArrayOrVector asPMVector collect: [ :each | each asPMVector].
]
+{ #category : #initialization }
+PMMatrix >> initializeRows: rowsInteger columns: columnsInteger [
+ "Build empty components for a matrix."
+
+ rows := (1 to: rowsInteger) asPMVector collect: [ :each | PMVector new: columnsInteger ].
+]
+
{ #category : #operation }
PMMatrix >> inverse [
"Answer the inverse of the receiver."
@@ -452,7 +523,7 @@ PMMatrix >> isSymmetric [
{ #category : #private }
PMMatrix >> largestPowerOf2SmallerThan: anInteger [
- "Private - "
+ "Private"
| m m2|
m := 2.
[ m2 := m * 2.
@@ -463,9 +534,7 @@ PMMatrix >> largestPowerOf2SmallerThan: anInteger [
{ #category : #operation }
PMMatrix >> log [
"Apply log to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each log])
+ ^ PMMatrix rows: ( self rowsCollect: [ :each | each log])
]
@@ -523,6 +592,17 @@ PMMatrix >> orthogonalize [
]
+{ #category : #'as yet unclassified' }
+PMMatrix >> principalDiagonal [
+ "https://en.wikipedia.org/wiki/Diagonal#Matrices for definitions"
+ | diag |
+ "Check for square"
+ self isSquare ifFalse: [ self error: 'Diagonal is not defined for a matrix that is not square.' ].
+ diag := PMVector new: self rows size.
+ (1 to: diag size) do: [ :i | diag at: i put: (self at:i at: i) ].
+ ^ diag
+]
+
{ #category : #printing }
PMMatrix >> printOn: aStream [
(rows isNil or: [rows first isNil])
@@ -718,21 +798,25 @@ PMMatrix >> setDiagonal: aVector [
^self
]
+{ #category : #operation }
+PMMatrix >> sign [
+ "Apply sign to each element of a matrix"
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each sign ])
+]
+
{ #category : #operation }
PMMatrix >> sin [
"Apply sin to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each sin])
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each sin ])
]
{ #category : #operation }
PMMatrix >> sinh [
"Apply sinh to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each sinh])
-
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each sinh ])
]
{ #category : #private }
@@ -758,9 +842,8 @@ PMMatrix >> split [
{ #category : #operation }
PMMatrix >> sqrt [
"Apply sqrt to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each sqrt])
+
+ ^ PMMatrix rows: ( self rowsCollect: [ :each | each sqrt])
]
{ #category : #operation }
@@ -829,18 +912,15 @@ PMMatrix >> swapColumn: anIndex withColumn: a2Index [
{ #category : #operation }
PMMatrix >> tan [
"Apply tan to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each tan])
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each tan ])
]
{ #category : #operation }
PMMatrix >> tanh [
"Apply tanh to each element of a matrix"
- | n |
- n := 0.
- ^ PMMatrix rows: ( self rowsCollect: [ :each | n := n + 1. each tanh])
-
+
+ ^ PMMatrix rows: (self rowsCollect: [ :each | each tanh ])
]
{ #category : #operation }
diff --git a/src/Math-Matrix/PMSingularValueDecomposition.class.st b/src/Math-Matrix/PMSingularValueDecomposition.class.st
index 6e9710a07..9753ef804 100644
--- a/src/Math-Matrix/PMSingularValueDecomposition.class.st
+++ b/src/Math-Matrix/PMSingularValueDecomposition.class.st
@@ -50,43 +50,35 @@ PMSingularValueDecomposition class >> decompose: aMatrix [
{ #category : #initialization }
PMSingularValueDecomposition >> initialize: aMatrix [
-
| symU symV eigenU eigenV diag |
m := aMatrix numberOfRows.
n := aMatrix numberOfColumns.
-
symU := aMatrix * aMatrix transpose.
symV := aMatrix transpose * aMatrix.
-
+
"Expensive computation"
eigenU := symU eigen.
eigenV := symV eigen.
-
u := (PMMatrix rows: eigenU vectors) transpose.
v := (PMMatrix rows: eigenV vectors) transpose.
-
- m < n
- ifTrue: [ diag := eigenU values ]
- ifFalse: [ diag := eigenV values ].
-
+ diag := m < n
+ ifTrue: [ eigenU values ]
+ ifFalse: [ eigenV values ].
s := PMMatrix rows: m columns: n random: 0.
- s setDiagonal: diag sqrt.
+ s setDiagonal: diag sqrt
]
{ #category : #accessing }
PMSingularValueDecomposition >> leftSingularForm [
-
^ u
]
{ #category : #accessing }
PMSingularValueDecomposition >> rightSingularForm [
-
^ v
]
{ #category : #accessing }
PMSingularValueDecomposition >> sForm [
-
^ s
]
diff --git a/src/Math-Matrix/PMSymmetricMatrix.class.st b/src/Math-Matrix/PMSymmetricMatrix.class.st
index d8ef2e773..fbfce867b 100644
--- a/src/Math-Matrix/PMSymmetricMatrix.class.st
+++ b/src/Math-Matrix/PMSymmetricMatrix.class.st
@@ -96,8 +96,9 @@ PMSymmetricMatrix >> addWithSymmetricMatrix: aMatrix [
{ #category : #transformation }
PMSymmetricMatrix >> asSymmetricMatrix [
-"simple speed up"
-^self
+ "simple speed up"
+
+ ^ self
]
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/Collection.extension.st b/src/Math-Numerical/Collection.extension.st
similarity index 84%
rename from src/Math-DHB-Numerical/Collection.extension.st
rename to src/Math-Numerical/Collection.extension.st
index bb640f99e..a77e4c520 100644
--- a/src/Math-DHB-Numerical/Collection.extension.st
+++ b/src/Math-Numerical/Collection.extension.st
@@ -1,6 +1,6 @@
Extension { #name : #Collection }
-{ #category : #'*Math-DHB-Numerical' }
+{ #category : #'*Math-Numerical' }
Collection >> asPMVector [
| aVector index |
diff --git a/src/Math-DHB-Numerical/Integer.extension.st b/src/Math-Numerical/Integer.extension.st
similarity index 53%
rename from src/Math-DHB-Numerical/Integer.extension.st
rename to src/Math-Numerical/Integer.extension.st
index 52db9133e..aa381d423 100644
--- a/src/Math-DHB-Numerical/Integer.extension.st
+++ b/src/Math-Numerical/Integer.extension.st
@@ -1,16 +1,14 @@
Extension { #name : #Integer }
-{ #category : #'*Math-DHB-Numerical' }
+{ #category : #'*Math-Numerical' }
Integer >> gamma [
self > 0
ifFalse: [^ self error: 'Attempt to compute the Gamma function of a non-positive integer'].
^ (self - 1) factorial.
]
-{ #category : #'*Math-DHB-Numerical' }
+{ #category : #'*Math-Numerical' }
Integer >> random [
- "Answer a random integer between 0 and the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/2/99 "
+ "Answer a random integer between 0 and the receiver."
^ PMMitchellMooreGenerator new integerValue: self
]
diff --git a/src/Math-Numerical/Number.extension.st b/src/Math-Numerical/Number.extension.st
new file mode 100644
index 000000000..31ef61b6a
--- /dev/null
+++ b/src/Math-Numerical/Number.extension.st
@@ -0,0 +1,102 @@
+Extension { #name : #Number }
+
+{ #category : #'*Math-Numerical' }
+Number >> addPolynomial: aPolynomial [
+ ^aPolynomial addNumber: self
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> beta: aNumber [
+ "Computes the beta function of the receiver and aNumber"
+
+ ^ (self logBeta: aNumber) exp
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> dividingPolynomial: aPolynomial [
+ ^aPolynomial timesNumber: (1 / self)
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> equalsTo: aNumber [
+ "compare to Float>>closeTo:"
+ ^self relativelyEqualsTo: aNumber upTo: PMFloatingPointMachine new defaultNumericalPrecision
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> errorFunction [
+ "Answer the error function for the receiver."
+ ^ PMErfApproximation new value: self
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> gamma [
+ "Compute the Gamma function for the receiver."
+ ^ self > 1
+ ifTrue: [ ^ PMLanczosFormula new gamma: self]
+ ifFalse:[ self < 0
+ ifTrue: [ Float pi / ( ( Float pi * self) sin * ( 1 - self) gamma)]
+ ifFalse:[ ( PMLanczosFormula new gamma: ( self + 1)) / self]
+ ]
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> logBeta: aNumber [
+ "Computes the logarithm of the beta function of the receiver and aNumber"
+
+ ^ self logGamma + aNumber logGamma - (self + aNumber) logGamma
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> logGamma [
+ "Computes the log of the Gamma function (for positive numbers only)"
+ ^self > 1
+ ifTrue: [ PMLanczosFormula new logGamma: self]
+ ifFalse:[ self > 0
+ ifTrue: [ ( PMLanczosFormula new logGamma: ( self + 1) ) - self ln ]
+ ifFalse: [ ^self error: 'Argument for the log gamma function must be positive']
+ ]
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> productWithMatrix: aMatrix [
+^aMatrix class rows: (aMatrix rowsCollect: [:r| self productWithVector: r])
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> productWithVector: aVector [
+ "Answers a new vector product of the receiver with aVector."
+ ^aVector collect: [ :each | each * self]
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> random [
+ "Answers a random number distributed between 0 and the receiver."
+ ^self class random * self
+]
+
+{ #category : #'*Math-Numerical' }
+Number class >> random [
+ "Answers a random number between 0 and the receiver."
+ ^ PMMitchellMooreGenerator new floatValue
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> relativelyEqualsTo: aNumber upTo: aSmallNumber [
+ "compare to Float>>closeTo:
+ generally called from Number>>equalsTo:"
+ | norm |
+ norm := self abs max: aNumber abs.
+ ^norm <= PMFloatingPointMachine new defaultNumericalPrecision
+ or: [ (self - aNumber) abs < ( aSmallNumber * norm)]
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> subtractToPolynomial: aPolynomial [
+ ^aPolynomial addNumber: self negated
+]
+
+{ #category : #'*Math-Numerical' }
+Number >> timesPolynomial: aPolynomial [
+ ^aPolynomial timesNumber: self
+]
diff --git a/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st b/src/Math-Numerical/PMBisectionZeroFinder.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st
rename to src/Math-Numerical/PMBisectionZeroFinder.class.st
index f8e92c903..d8ca7dfb6 100644
--- a/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st
+++ b/src/Math-Numerical/PMBisectionZeroFinder.class.st
@@ -8,7 +8,7 @@ Class {
'positiveX',
'negativeX'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #operation }
diff --git a/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st b/src/Math-Numerical/PMBulirschStoerInterpolator.class.st
similarity index 92%
rename from src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st
rename to src/Math-Numerical/PMBulirschStoerInterpolator.class.st
index 1112b2986..62bd3455c 100644
--- a/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st
+++ b/src/Math-Numerical/PMBulirschStoerInterpolator.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMBulirschStoerInterpolator,
#superclass : #PMNevilleInterpolator,
- #category : 'Math-DHB-Numerical-Math-Interpolator'
+ #category : #'Math-Numerical-Math-Interpolator'
}
{ #category : #private }
diff --git a/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st b/src/Math-Numerical/PMCDFNewtonZeroFinder.class.st
similarity index 95%
rename from src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st
rename to src/Math-Numerical/PMCDFNewtonZeroFinder.class.st
index a5a1e15c4..85050894a 100644
--- a/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st
+++ b/src/Math-Numerical/PMCDFNewtonZeroFinder.class.st
@@ -7,7 +7,7 @@ Class {
#instVars : [
'old'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #operation }
diff --git a/src/Math-DHB-Numerical/PMCauchyDistribution.class.st b/src/Math-Numerical/PMCauchyDistribution.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMCauchyDistribution.class.st
rename to src/Math-Numerical/PMCauchyDistribution.class.st
index 381e60cd0..50e2bffbc 100644
--- a/src/Math-DHB-Numerical/PMCauchyDistribution.class.st
+++ b/src/Math-Numerical/PMCauchyDistribution.class.st
@@ -5,7 +5,7 @@ Class {
'mu',
'beta'
],
- #category : 'Math-DHB-Numerical-Math-Distribution'
+ #category : #'Math-Numerical-Math-Distribution'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st b/src/Math-Numerical/PMCovarianceAccumulator.class.st
similarity index 76%
rename from src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st
rename to src/Math-Numerical/PMCovarianceAccumulator.class.st
index fc251caf1..905e1b5d3 100644
--- a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st
+++ b/src/Math-Numerical/PMCovarianceAccumulator.class.st
@@ -1,10 +1,15 @@
+"
+It has one additional instance variable compared to its superclass:
+
+- covariance accumulates the components of the covariance matrix; for efficiency reason, only the lower half of the matrix is computed since it is symmetric.
+"
Class {
#name : #PMCovarianceAccumulator,
#superclass : #PMVectorAccumulator,
#instVars : [
'covariance'
],
- #category : 'Math-DHB-Numerical-Math-UtilsAccumulator'
+ #category : #'Math-Numerical-Math-UtilsAccumulator'
}
{ #category : #transformation }
@@ -40,9 +45,10 @@ PMCovarianceAccumulator >> initialize: anInteger [
^super initialize: anInteger
]
-{ #category : #transformation }
+{ #category : #initialization }
PMCovarianceAccumulator >> reset [
"Set all accumulators to zero."
+
super reset.
- covariance do: [ :each | each atAllPut: 0].
+ covariance do: [ :each | each atAllPut: 0 ]
]
diff --git a/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st b/src/Math-Numerical/PMDecimalFloatingNumber.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st
rename to src/Math-Numerical/PMDecimalFloatingNumber.class.st
index dc8bc9e6a..d5d5cfafd 100644
--- a/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st
+++ b/src/Math-Numerical/PMDecimalFloatingNumber.class.st
@@ -17,7 +17,7 @@ Class {
#classVars : [
'Digits'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMExponentialDistribution.class.st b/src/Math-Numerical/PMExponentialDistribution.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMExponentialDistribution.class.st
rename to src/Math-Numerical/PMExponentialDistribution.class.st
index fde747d7e..495f5e3ac 100644
--- a/src/Math-DHB-Numerical/PMExponentialDistribution.class.st
+++ b/src/Math-Numerical/PMExponentialDistribution.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'beta'
],
- #category : 'Math-DHB-Numerical-Math-Distribution'
+ #category : #'Math-Numerical-Math-Distribution'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st b/src/Math-Numerical/PMFisherTippettDistribution.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st
rename to src/Math-Numerical/PMFisherTippettDistribution.class.st
index 4c90c18c4..fa9e30269 100644
--- a/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st
+++ b/src/Math-Numerical/PMFisherTippettDistribution.class.st
@@ -5,7 +5,7 @@ Class {
'alpha',
'beta'
],
- #category : 'Math-DHB-Numerical-Math-Distribution'
+ #category : #'Math-Numerical-Math-Distribution'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st b/src/Math-Numerical/PMFunctionOptimizer.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMFunctionOptimizer.class.st
rename to src/Math-Numerical/PMFunctionOptimizer.class.st
index 605735cbf..d27bfaf34 100644
--- a/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st
+++ b/src/Math-Numerical/PMFunctionOptimizer.class.st
@@ -5,7 +5,7 @@ Class {
'optimizingPointClass',
'bestPoints'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMFunctionalIterator.class.st b/src/Math-Numerical/PMFunctionalIterator.class.st
similarity index 96%
rename from src/Math-DHB-Numerical/PMFunctionalIterator.class.st
rename to src/Math-Numerical/PMFunctionalIterator.class.st
index bd0bf20ae..8287fbe9f 100644
--- a/src/Math-DHB-Numerical/PMFunctionalIterator.class.st
+++ b/src/Math-Numerical/PMFunctionalIterator.class.st
@@ -16,7 +16,7 @@ Class {
#instVars : [
'functionBlock'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st b/src/Math-Numerical/PMGeneticOptimizer.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMGeneticOptimizer.class.st
rename to src/Math-Numerical/PMGeneticOptimizer.class.st
index b1f9763b8..26e82e4e2 100644
--- a/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st
+++ b/src/Math-Numerical/PMGeneticOptimizer.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'chromosomeManager'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st b/src/Math-Numerical/PMHillClimbingOptimizer.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st
rename to src/Math-Numerical/PMHillClimbingOptimizer.class.st
index 037422365..ff272566e 100644
--- a/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st
+++ b/src/Math-Numerical/PMHillClimbingOptimizer.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'unidimensionalFinder'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #initialization }
diff --git a/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st b/src/Math-Numerical/PMHistogrammedDistribution.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st
rename to src/Math-Numerical/PMHistogrammedDistribution.class.st
index db82646d4..55ffb26af 100644
--- a/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st
+++ b/src/Math-Numerical/PMHistogrammedDistribution.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'histogram'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st b/src/Math-Numerical/PMIncompleteBetaFractionTermServer.class.st
similarity index 58%
rename from src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st
rename to src/Math-Numerical/PMIncompleteBetaFractionTermServer.class.st
index 733274b83..71aa9aaf7 100644
--- a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st
+++ b/src/Math-Numerical/PMIncompleteBetaFractionTermServer.class.st
@@ -5,7 +5,7 @@ Class {
'alpha1',
'alpha2'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
@@ -20,15 +20,15 @@ PMIncompleteBetaFractionTermServer >> setParameter: aNumber1 second: aNumber2 [
]
{ #category : #information }
-PMIncompleteBetaFractionTermServer >> termsAt: anInteger [
-
+PMIncompleteBetaFractionTermServer >> termsAt: anInteger [
| n n2 |
n := anInteger // 2.
n2 := 2 * n.
- ^Array with: ( n2 < anInteger
- ifTrue:
- [x negated * (alpha1 + n) * (alpha1 + alpha2 + n)
- / ((alpha1 + n2) * (alpha1 + 1 + n2))]
- ifFalse: [x * n * (alpha2 - n) / ((alpha1 + n2) * (alpha1 - 1 + n2))])
- with: 1
+ ^ Array
+ with:
+ (n2 < anInteger
+ ifTrue:
+ [ x negated * (alpha1 + n) * (alpha1 + alpha2 + n) / ((alpha1 + n2) * (alpha1 + 1 + n2)) ]
+ ifFalse: [ x * n * (alpha2 - n) / ((alpha1 + n2) * (alpha1 - 1 + n2)) ])
+ with: 1
]
diff --git a/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st b/src/Math-Numerical/PMIncompleteBetaFunctionFraction.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st
rename to src/Math-Numerical/PMIncompleteBetaFunctionFraction.class.st
index 57e212b0a..fa2eb7679 100644
--- a/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st
+++ b/src/Math-Numerical/PMIncompleteBetaFunctionFraction.class.st
@@ -11,7 +11,7 @@ Class {
'alpha1',
'alpha2'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st b/src/Math-Numerical/PMIncompleteGammaFractionTermServer.class.st
similarity index 94%
rename from src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st
rename to src/Math-Numerical/PMIncompleteGammaFractionTermServer.class.st
index a565882c0..7ed7ab202 100644
--- a/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st
+++ b/src/Math-Numerical/PMIncompleteGammaFractionTermServer.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'alpha'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st b/src/Math-Numerical/PMIncompleteGammaSeriesTermServer.class.st
similarity index 94%
rename from src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st
rename to src/Math-Numerical/PMIncompleteGammaSeriesTermServer.class.st
index c63dc15c7..fe48ab911 100644
--- a/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st
+++ b/src/Math-Numerical/PMIncompleteGammaSeriesTermServer.class.st
@@ -5,7 +5,7 @@ Class {
'alpha',
'sum'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st b/src/Math-Numerical/PMLagrangeInterpolator.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st
rename to src/Math-Numerical/PMLagrangeInterpolator.class.st
index cf465e162..11cf49d81 100644
--- a/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st
+++ b/src/Math-Numerical/PMLagrangeInterpolator.class.st
@@ -13,7 +13,7 @@ Class {
#instVars : [
'pointCollection'
],
- #category : 'Math-DHB-Numerical-Math-Interpolator'
+ #category : #'Math-Numerical-Math-Interpolator'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMLanczosFormula.class.st b/src/Math-Numerical/PMLanczosFormula.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMLanczosFormula.class.st
rename to src/Math-Numerical/PMLanczosFormula.class.st
index f2935653e..34da15b11 100644
--- a/src/Math-DHB-Numerical/PMLanczosFormula.class.st
+++ b/src/Math-Numerical/PMLanczosFormula.class.st
@@ -20,7 +20,7 @@ Class {
#classVars : [
'UniqueInstance'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st b/src/Math-Numerical/PMLaplaceDistribution.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMLaplaceDistribution.class.st
rename to src/Math-Numerical/PMLaplaceDistribution.class.st
index 42727b063..fd0077397 100644
--- a/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st
+++ b/src/Math-Numerical/PMLaplaceDistribution.class.st
@@ -5,7 +5,7 @@ Class {
'mu',
'beta'
],
- #category : 'Math-DHB-Numerical-Math-Distribution'
+ #category : #'Math-Numerical-Math-Distribution'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMLeastSquareFit.class.st b/src/Math-Numerical/PMLeastSquareFit.class.st
similarity index 99%
rename from src/Math-DHB-Numerical/PMLeastSquareFit.class.st
rename to src/Math-Numerical/PMLeastSquareFit.class.st
index 45ef541ea..f2caaced2 100644
--- a/src/Math-DHB-Numerical/PMLeastSquareFit.class.st
+++ b/src/Math-Numerical/PMLeastSquareFit.class.st
@@ -9,7 +9,7 @@ Class {
'constants',
'degreeOfFreedom'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMLineSearch.class.st b/src/Math-Numerical/PMLineSearch.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMLineSearch.class.st
rename to src/Math-Numerical/PMLineSearch.class.st
index f8da00500..74eac714c 100644
--- a/src/Math-DHB-Numerical/PMLineSearch.class.st
+++ b/src/Math-Numerical/PMLineSearch.class.st
@@ -39,7 +39,7 @@ Class {
'useCubicApproximation',
'extendedResult'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #'instance creation' }
diff --git a/src/Math-DHB-Numerical/PMLinearRegression.class.st b/src/Math-Numerical/PMLinearRegression.class.st
similarity index 96%
rename from src/Math-DHB-Numerical/PMLinearRegression.class.st
rename to src/Math-Numerical/PMLinearRegression.class.st
index 17e33300a..f8e9e3977 100644
--- a/src/Math-DHB-Numerical/PMLinearRegression.class.st
+++ b/src/Math-Numerical/PMLinearRegression.class.st
@@ -12,14 +12,12 @@ Class {
'intercept',
'correlationCoefficient'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
PMLinearRegression class >> new [
- "Create a new instance of the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 12/2/99 "
+ "Create a new instance of the receiver."
^( super new) reset; yourself
]
diff --git a/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st b/src/Math-Numerical/PMLogNormalDistribution.class.st
similarity index 99%
rename from src/Math-DHB-Numerical/PMLogNormalDistribution.class.st
rename to src/Math-Numerical/PMLogNormalDistribution.class.st
index 967e26612..2f5463611 100644
--- a/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st
+++ b/src/Math-Numerical/PMLogNormalDistribution.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'normalDistribution'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMMaximizingPoint.class.st b/src/Math-Numerical/PMMaximizingPoint.class.st
similarity index 84%
rename from src/Math-DHB-Numerical/PMMaximizingPoint.class.st
rename to src/Math-Numerical/PMMaximizingPoint.class.st
index a9812adc6..5e522fd7e 100644
--- a/src/Math-DHB-Numerical/PMMaximizingPoint.class.st
+++ b/src/Math-Numerical/PMMaximizingPoint.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMMaximizingPoint,
#superclass : #PMMinimizingPoint,
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st b/src/Math-Numerical/PMMaximumLikelihoodHistogramFit.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st
rename to src/Math-Numerical/PMMaximumLikelihoodHistogramFit.class.st
index a97d4e7c3..fb067f9b8 100644
--- a/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st
+++ b/src/Math-Numerical/PMMaximumLikelihoodHistogramFit.class.st
@@ -5,7 +5,7 @@ Class {
'count',
'countVariance'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #operation }
diff --git a/src/Math-DHB-Numerical/PMMinimizingPoint.class.st b/src/Math-Numerical/PMMinimizingPoint.class.st
similarity index 95%
rename from src/Math-DHB-Numerical/PMMinimizingPoint.class.st
rename to src/Math-Numerical/PMMinimizingPoint.class.st
index 53e05cd4b..53db5f82e 100644
--- a/src/Math-DHB-Numerical/PMMinimizingPoint.class.st
+++ b/src/Math-Numerical/PMMinimizingPoint.class.st
@@ -5,7 +5,7 @@ Class {
'value',
'position'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st b/src/Math-Numerical/PMMultiVariableGeneralOptimizer.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st
rename to src/Math-Numerical/PMMultiVariableGeneralOptimizer.class.st
index e97954700..2a7fee842 100644
--- a/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st
+++ b/src/Math-Numerical/PMMultiVariableGeneralOptimizer.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMMultiVariableGeneralOptimizer,
#superclass : #PMFunctionOptimizer,
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #operation }
diff --git a/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st b/src/Math-Numerical/PMNevilleInterpolator.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMNevilleInterpolator.class.st
rename to src/Math-Numerical/PMNevilleInterpolator.class.st
index 156286d88..e182725c2 100644
--- a/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st
+++ b/src/Math-Numerical/PMNevilleInterpolator.class.st
@@ -5,7 +5,7 @@ Class {
'leftErrors',
'rightErrors'
],
- #category : 'Math-DHB-Numerical-Math-Interpolator'
+ #category : #'Math-Numerical-Math-Interpolator'
}
{ #category : #private }
diff --git a/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st b/src/Math-Numerical/PMNewtonInterpolator.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMNewtonInterpolator.class.st
rename to src/Math-Numerical/PMNewtonInterpolator.class.st
index 42c70dac6..7ecf8cf46 100644
--- a/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st
+++ b/src/Math-Numerical/PMNewtonInterpolator.class.st
@@ -13,7 +13,7 @@ Class {
#instVars : [
'coefficients'
],
- #category : 'Math-DHB-Numerical-Math-Interpolator'
+ #category : #'Math-Numerical-Math-Interpolator'
}
{ #category : #transformation }
diff --git a/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st b/src/Math-Numerical/PMNewtonZeroFinder.class.st
similarity index 96%
rename from src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st
rename to src/Math-Numerical/PMNewtonZeroFinder.class.st
index 7d3ed5e87..bcc248c61 100644
--- a/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st
+++ b/src/Math-Numerical/PMNewtonZeroFinder.class.st
@@ -30,14 +30,12 @@ Class {
'lineSearch',
'lineSearchFunctionBlock'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #creation }
PMNewtonZeroFinder class >> function: aBlock1 derivative: aBlock2 [
- "Convenience method to create a instance with given function block.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 7/1/99 "
+ "Convenience method to create a instance with given function block."
^(self new) setFunction: aBlock1; setDerivative: aBlock2; yourself
]
diff --git a/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st b/src/Math-Numerical/PMOneVariableFunctionOptimizer.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st
rename to src/Math-Numerical/PMOneVariableFunctionOptimizer.class.st
index 0c8264d50..b5982e190 100644
--- a/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st
+++ b/src/Math-Numerical/PMOneVariableFunctionOptimizer.class.st
@@ -4,7 +4,7 @@ Class {
#classVars : [
'GoldenSection'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st b/src/Math-Numerical/PMOptimizingBracketFinder.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st
rename to src/Math-Numerical/PMOptimizingBracketFinder.class.st
index 7e23d598f..98bb97e4a 100644
--- a/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st
+++ b/src/Math-Numerical/PMOptimizingBracketFinder.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMOptimizingBracketFinder,
#superclass : #PMOneVariableFunctionOptimizer,
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMPointSeries.class.st b/src/Math-Numerical/PMPointSeries.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMPointSeries.class.st
rename to src/Math-Numerical/PMPointSeries.class.st
index 59d4994c6..482188389 100644
--- a/src/Math-DHB-Numerical/PMPointSeries.class.st
+++ b/src/Math-Numerical/PMPointSeries.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'points'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
diff --git a/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st b/src/Math-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st
similarity index 96%
rename from src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st
rename to src/Math-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st
index e2b96a38e..0baa2c47b 100644
--- a/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st
+++ b/src/Math-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMProbabilityDensityWithUnknownDistribution,
#superclass : #PMProbabilityDensity,
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st b/src/Math-Numerical/PMProbabilityDistributionFunction.class.st
similarity index 64%
rename from src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st
rename to src/Math-Numerical/PMProbabilityDistributionFunction.class.st
index 98295518f..5019ea3cd 100644
--- a/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st
+++ b/src/Math-Numerical/PMProbabilityDistributionFunction.class.st
@@ -4,28 +4,22 @@ Class {
#instVars : [
'probabilityDensity'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
PMProbabilityDistributionFunction class >> density: aProbabilityDensity [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/4/99 "
^self new initialize: aProbabilityDensity
]
{ #category : #initialization }
PMProbabilityDistributionFunction >> initialize: aProbabilityDensity [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/4/99 "
+ "Private"
probabilityDensity := aProbabilityDensity.
^self
]
{ #category : #information }
PMProbabilityDistributionFunction >> value: aNumber [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/4/99 "
^probabilityDensity distributionValue: aNumber
]
diff --git a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st
similarity index 62%
rename from src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st
rename to src/Math-Numerical/PMProjectedOneVariableFunction.class.st
index 3282e064f..fd22a81dc 100644
--- a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st
+++ b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st
@@ -6,27 +6,22 @@ Class {
'function',
'argument'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
PMProjectedOneVariableFunction class >> function: aVectorFunction [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
^super new initialize: aVectorFunction
]
{ #category : #information }
PMProjectedOneVariableFunction >> argumentWith: aNumber [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
+
^argument at: index put: aNumber; yourself
]
{ #category : #transformation }
PMProjectedOneVariableFunction >> bumpIndex [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
index isNil
ifTrue: [ index := 1]
ifFalse:[ index := index + 1.
@@ -37,8 +32,6 @@ PMProjectedOneVariableFunction >> bumpIndex [
{ #category : #information }
PMProjectedOneVariableFunction >> index [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
index isNil
ifTrue: [ index := 1].
^index
@@ -46,29 +39,21 @@ PMProjectedOneVariableFunction >> index [
{ #category : #initialization }
PMProjectedOneVariableFunction >> initialize: aFunction [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
function := aFunction.
^self
]
{ #category : #initialization }
PMProjectedOneVariableFunction >> setArgument: anArrayOrVector [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
argument := anArrayOrVector copy.
]
{ #category : #initialization }
PMProjectedOneVariableFunction >> setIndex: anInteger [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
index := anInteger.
]
{ #category : #information }
PMProjectedOneVariableFunction >> value: aNumber [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
^function value: ( self argumentWith: aNumber)
]
diff --git a/src/Math-DHB-Numerical/PMRombergIntegrator.class.st b/src/Math-Numerical/PMRombergIntegrator.class.st
similarity index 97%
rename from src/Math-DHB-Numerical/PMRombergIntegrator.class.st
rename to src/Math-Numerical/PMRombergIntegrator.class.st
index 38cbe422f..9ec1e9483 100644
--- a/src/Math-DHB-Numerical/PMRombergIntegrator.class.st
+++ b/src/Math-Numerical/PMRombergIntegrator.class.st
@@ -21,7 +21,7 @@ Class {
'points',
'interpolator'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st b/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st
similarity index 68%
rename from src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st
rename to src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st
index 0bd77eeed..9dba69d0a 100644
--- a/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st
+++ b/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st
@@ -6,14 +6,12 @@ Class {
'count',
'binWidth'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #creation }
PMScaledProbabilityDensityFunction class >> histogram: aHistogram against: aProbabilityDensityFunction [
- "Create a new instance of the receiver with given probability density function and histogram.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 3/3/99 "
+ "Create a new instance of the receiver with given probability density function and histogram."
^self new
initialize: aProbabilityDensityFunction
binWidth: aHistogram binWidth
@@ -22,9 +20,7 @@ PMScaledProbabilityDensityFunction class >> histogram: aHistogram against: aProb
{ #category : #creation }
PMScaledProbabilityDensityFunction class >> histogram: aHistogram distributionClass: aProbabilityDensityFunctionClass [
- "Create a new instance of the receiver with given probability density function and histogram.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 3/3/99"
+ "Create a new instance of the receiver with given probability density function and histogram."
| dp |
^(dp := aProbabilityDensityFunctionClass fromHistogram: aHistogram) isNil
@@ -34,25 +30,19 @@ PMScaledProbabilityDensityFunction class >> histogram: aHistogram distributionCl
{ #category : #transformation }
PMScaledProbabilityDensityFunction >> changeParametersBy: aVector [
- "Modify the parameters of the receiver by aVector.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/3/99 "
+ "Modify the parameters of the receiver by aVector"
count := count + aVector last.
probabilityDensityFunction changeParametersBy: aVector.
]
{ #category : #information }
PMScaledProbabilityDensityFunction >> distributionFunction [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/4/99 "
^probabilityDensityFunction distributionFunction
]
{ #category : #initialization }
PMScaledProbabilityDensityFunction >> initialize: aProbabilityDensityFunction binWidth: aNumber count: anInteger [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 3/3/99 "
+ "Private"
probabilityDensityFunction := aProbabilityDensityFunction.
binWidth := aNumber.
@@ -62,15 +52,11 @@ PMScaledProbabilityDensityFunction >> initialize: aProbabilityDensityFunction bi
{ #category : #information }
PMScaledProbabilityDensityFunction >> parameters [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/3/99 "
^probabilityDensityFunction parameters copyWith: count
]
{ #category : #display }
PMScaledProbabilityDensityFunction >> printOn: aStream [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/4/99 "
super printOn: aStream.
aStream nextPut: $[;
nextPutAll: probabilityDensityFunction class distributionName;
@@ -79,16 +65,11 @@ PMScaledProbabilityDensityFunction >> printOn: aStream [
{ #category : #transformation }
PMScaledProbabilityDensityFunction >> setCount: aNumber [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 12/3/99 "
count := aNumber.
]
{ #category : #information }
-PMScaledProbabilityDensityFunction >> value: aNumber [
- "
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 3/3/99 "
+PMScaledProbabilityDensityFunction >> value: aNumber [
^(probabilityDensityFunction value: aNumber) * binWidth * count
]
@@ -97,9 +78,7 @@ PMScaledProbabilityDensityFunction >> value: aNumber [
PMScaledProbabilityDensityFunction >> valueAndGradient: aNumber [
"Answers an Array containing the value of the receiver at aNumber
and the gradient of the receiver's respective to the receiver's
- parameters evaluated at aNumber.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/3/99 "
+ parameters evaluated at aNumber."
| g temp |
g := probabilityDensityFunction valueAndGradient: aNumber.
diff --git a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st b/src/Math-Numerical/PMSeriesTermServer.class.st
similarity index 76%
rename from src/Math-DHB-Numerical/PMSeriesTermServer.class.st
rename to src/Math-Numerical/PMSeriesTermServer.class.st
index 804f05d7d..52db49989 100644
--- a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st
+++ b/src/Math-Numerical/PMSeriesTermServer.class.st
@@ -5,10 +5,10 @@ Class {
'x',
'lastTerm'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #initialization }
PMSeriesTermServer >> setArgument: aNumber [
- x := aNumber asFloat.
+ x := aNumber asFloat
]
diff --git a/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st b/src/Math-Numerical/PMSimplexOptimizer.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMSimplexOptimizer.class.st
rename to src/Math-Numerical/PMSimplexOptimizer.class.st
index 59750fa6c..f1ebe50f8 100644
--- a/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st
+++ b/src/Math-Numerical/PMSimplexOptimizer.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'worstVector'
],
- #category : 'Math-DHB-Numerical-Math-FunctionIterator'
+ #category : #'Math-Numerical-Math-FunctionIterator'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st b/src/Math-Numerical/PMSimpsonIntegrator.class.st
similarity index 91%
rename from src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st
rename to src/Math-Numerical/PMSimpsonIntegrator.class.st
index 9870be10b..2349de7f1 100644
--- a/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st
+++ b/src/Math-Numerical/PMSimpsonIntegrator.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMSimpsonIntegrator,
#superclass : #PMTrapezeIntegrator,
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #operation }
diff --git a/src/Math-DHB-Numerical/PMSplineInterpolator.class.st b/src/Math-Numerical/PMSplineInterpolator.class.st
similarity index 98%
rename from src/Math-DHB-Numerical/PMSplineInterpolator.class.st
rename to src/Math-Numerical/PMSplineInterpolator.class.st
index 60c5af4c5..bd4498c8c 100644
--- a/src/Math-DHB-Numerical/PMSplineInterpolator.class.st
+++ b/src/Math-Numerical/PMSplineInterpolator.class.st
@@ -5,7 +5,7 @@ Class {
'startPointDerivative',
'endPointDerivative'
],
- #category : 'Math-DHB-Numerical-Math-Interpolator'
+ #category : #'Math-Numerical-Math-Interpolator'
}
{ #category : #transformation }
diff --git a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st b/src/Math-Numerical/PMTrapezeIntegrator.class.st
similarity index 86%
rename from src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st
rename to src/Math-Numerical/PMTrapezeIntegrator.class.st
index a35c1f684..da842e5df 100644
--- a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st
+++ b/src/Math-Numerical/PMTrapezeIntegrator.class.st
@@ -12,7 +12,7 @@ Class {
'sum',
'step'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
@@ -26,12 +26,6 @@ PMTrapezeIntegrator class >> function: aBlock from: aNumber1 to: aNumber2 [
^super new initialize: aBlock from: aNumber1 to: aNumber2
]
-{ #category : #creation }
-PMTrapezeIntegrator class >> new [
- "Private"
- ^self error: 'Method new:from:to: must be used'
-]
-
{ #category : #operation }
PMTrapezeIntegrator >> computeInitialValues [
"Private"
@@ -56,9 +50,7 @@ PMTrapezeIntegrator >> from: aNumber1 to: aNumber2 [
{ #category : #transformation }
PMTrapezeIntegrator >> higherOrderSum [
- "Private -
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 26/4/99 "
+ "Private"
| x newSum |
x := step / 2 + from.
newSum := 0.
diff --git a/src/Math-DHB-Numerical/PMTriangularDistribution.class.st b/src/Math-Numerical/PMTriangularDistribution.class.st
similarity index 99%
rename from src/Math-DHB-Numerical/PMTriangularDistribution.class.st
rename to src/Math-Numerical/PMTriangularDistribution.class.st
index 3a98b8e68..01e5f05af 100644
--- a/src/Math-DHB-Numerical/PMTriangularDistribution.class.st
+++ b/src/Math-Numerical/PMTriangularDistribution.class.st
@@ -6,7 +6,7 @@ Class {
'highLimit',
'peak'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-DHB-Numerical/PMUniformDistribution.class.st b/src/Math-Numerical/PMUniformDistribution.class.st
similarity index 84%
rename from src/Math-DHB-Numerical/PMUniformDistribution.class.st
rename to src/Math-Numerical/PMUniformDistribution.class.st
index 00b62684a..69d59ed63 100644
--- a/src/Math-DHB-Numerical/PMUniformDistribution.class.st
+++ b/src/Math-Numerical/PMUniformDistribution.class.st
@@ -5,21 +5,17 @@ Class {
'lowLimit',
'highLimit'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #public }
PMUniformDistribution class >> distributionName [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 4/3/99 "
^'Uniform distribution'
]
{ #category : #public }
PMUniformDistribution class >> from: aNumber1 to: aNumber2 [
- "Create a new instance of the receiver with given limits.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/2/99 "
+ "Create a new instance of the receiver with given limits."
^super new initialize: aNumber1 to: aNumber2
]
@@ -28,9 +24,7 @@ PMUniformDistribution class >> fromHistogram: aHistogram [
"Create an instance of the receiver with parameters estimated from the
given histogram using best guesses. This method can be used to
find the initial values for a fit.
- Default returns nil (must be implemented by subclass).
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 12/3/99 "
+ Default returns nil (must be implemented by subclass)."
| b c|
b := aHistogram standardDeviation * 1.73205080756888 "12 sqrt / 2".
b = 0
@@ -41,9 +35,7 @@ PMUniformDistribution class >> fromHistogram: aHistogram [
{ #category : #public }
PMUniformDistribution class >> new [
- "Create a new instance of the receiver with limits 0 and 1.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/2/99 "
+ "Create a new instance of the receiver with limits 0 and 1."
^self from: 0 to: 1
]
diff --git a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st b/src/Math-Numerical/PMVectorAccumulator.class.st
similarity index 72%
rename from src/Math-DHB-Numerical/PMVectorAccumulator.class.st
rename to src/Math-Numerical/PMVectorAccumulator.class.st
index a52770d67..dece9a968 100644
--- a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st
+++ b/src/Math-Numerical/PMVectorAccumulator.class.st
@@ -1,5 +1,9 @@
"
-I'm a simple object summing vectors. THe idea that I does not keep the data but information that are representative of the accumulated data.
+I'm a simple object summing vectors. The idea that I does not keep the data but information that are representative of the accumulated data.
+
+The class VectorAccumulator has two instance variables:
+- count counts the number of vectors accumulated in the object so far;
+- average keeps the average of the accumulated vector.
"
Class {
@@ -9,7 +13,7 @@ Class {
'count',
'average'
],
- #category : 'Math-DHB-Numerical-Math-UtilsAccumulator'
+ #category : #'Math-Numerical-Math-UtilsAccumulator'
}
{ #category : #'instance creation' }
@@ -19,7 +23,6 @@ PMVectorAccumulator class >> new: anInteger [
{ #category : #transformation }
PMVectorAccumulator >> accumulate: aVectorOrArray [
-
| delta |
count := count + 1.
delta := average - aVectorOrArray asPMVector scaleBy: 1 / count.
@@ -29,36 +32,31 @@ PMVectorAccumulator >> accumulate: aVectorOrArray [
{ #category : #operations }
PMVectorAccumulator >> average [
-
- ^average
+ ^ average
]
{ #category : #operations }
PMVectorAccumulator >> count [
-
- ^count
+ ^ count
]
{ #category : #initialization }
PMVectorAccumulator >> initialize: anInteger [
-
average := PMVector new: anInteger.
- self reset.
- ^ self
+ self reset
]
{ #category : #printing }
PMVectorAccumulator >> printOn: aStream [
-
super printOn: aStream.
aStream space.
count printOn: aStream.
aStream space.
- average printOn: aStream.
+ average printOn: aStream
]
{ #category : #initialization }
PMVectorAccumulator >> reset [
count := 0.
- average atAllPut: 0.
+ average atAllPut: 0
]
diff --git a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st b/src/Math-Numerical/PMVectorProjectedFunction.class.st
similarity index 58%
rename from src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st
rename to src/Math-Numerical/PMVectorProjectedFunction.class.st
index b2f0ed550..bd632efcf 100644
--- a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st
+++ b/src/Math-Numerical/PMVectorProjectedFunction.class.st
@@ -1,48 +1,37 @@
Class {
#name : #PMVectorProjectedFunction,
#superclass : #PMProjectedOneVariableFunction,
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
PMVectorProjectedFunction >> argumentWith: aNumber [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
+
^aNumber * self direction + self origin
]
{ #category : #information }
PMVectorProjectedFunction >> direction [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
^index
]
{ #category : #initialization }
PMVectorProjectedFunction >> direction: aVector [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
index := aVector.
]
{ #category : #information }
PMVectorProjectedFunction >> origin [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
^argument
]
{ #category : #initialization }
PMVectorProjectedFunction >> origin: aVector [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
argument := aVector.
]
{ #category : #display }
PMVectorProjectedFunction >> printOn: aStream [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 2/22/00 "
self origin printOn: aStream.
aStream nextPutAll: ' ('.
self direction printOn: aStream.
diff --git a/src/Math-DHB-Numerical/PMWeibullDistribution.class.st b/src/Math-Numerical/PMWeibullDistribution.class.st
similarity index 99%
rename from src/Math-DHB-Numerical/PMWeibullDistribution.class.st
rename to src/Math-Numerical/PMWeibullDistribution.class.st
index ba8597040..5ef1c1f36 100644
--- a/src/Math-DHB-Numerical/PMWeibullDistribution.class.st
+++ b/src/Math-Numerical/PMWeibullDistribution.class.st
@@ -6,7 +6,7 @@ Class {
'beta',
'norm'
],
- #category : 'Math-DHB-Numerical'
+ #category : #'Math-Numerical'
}
{ #category : #information }
diff --git a/src/Math-Numerical/package.st b/src/Math-Numerical/package.st
new file mode 100644
index 000000000..4a4309202
--- /dev/null
+++ b/src/Math-Numerical/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Numerical' }
diff --git a/src/Math-ODE/ExplicitSolver.class.st b/src/Math-ODE/ExplicitSolver.class.st
deleted file mode 100644
index 435f288e4..000000000
--- a/src/Math-ODE/ExplicitSolver.class.st
+++ /dev/null
@@ -1,21 +0,0 @@
-Class {
- #name : #ExplicitSolver,
- #superclass : #ODESolver,
- #category : 'Math-ODE'
-}
-
-{ #category : #'as yet unclassified' }
-ExplicitSolver class >> stepperClass [
- ^ ExplicitStepper.
-]
-
-{ #category : #'announcement hooks' }
-ExplicitSolver >> announcementClass [
- ^ ExplicitSolverAnnouncement
-]
-
-{ #category : #'announcement hooks' }
-ExplicitSolver >> announcerClass [
-
- ^ ExplicitAnnouncer
-]
diff --git a/src/Math-ODE/ImplicitSolver.class.st b/src/Math-ODE/ImplicitSolver.class.st
deleted file mode 100644
index 0e696aadb..000000000
--- a/src/Math-ODE/ImplicitSolver.class.st
+++ /dev/null
@@ -1,22 +0,0 @@
-Class {
- #name : #ImplicitSolver,
- #superclass : #ODESolver,
- #category : 'Math-ODE'
-}
-
-{ #category : #'as yet unclassified' }
-ImplicitSolver class >> stepperClass [
- ^ ImplicitStepper.
-]
-
-{ #category : #'announcement hooks' }
-ImplicitSolver >> announcementClass [
-
- ^ ImplicitSolverAnnouncement
-]
-
-{ #category : #'announcement hooks' }
-ImplicitSolver >> announcerClass [
-
- ^ ImplicitAnnouncer
-]
diff --git a/src/Math-ODE/AB2Solver.class.st b/src/Math-ODE/PMAB2Solver.class.st
similarity index 82%
rename from src/Math-ODE/AB2Solver.class.st
rename to src/Math-ODE/PMAB2Solver.class.st
index 536d8f680..c946be1ba 100644
--- a/src/Math-ODE/AB2Solver.class.st
+++ b/src/Math-ODE/PMAB2Solver.class.st
@@ -3,23 +3,23 @@ We can't use AB2 method until we have two old solution values. A AB2 method is
"
Class {
- #name : #AB2Solver,
- #superclass : #ExplicitSolver,
- #category : 'Math-ODE'
+ #name : #PMAB2Solver,
+ #superclass : #PMExplicitSolver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB2Solver class >> firstStepperClass [
- ^ MidpointStepper
+PMAB2Solver class >> firstStepperClass [
+ ^ PMMidpointStepper
]
{ #category : #'as yet unclassified' }
-AB2Solver class >> stepperClass [
- ^ AB2Stepper
+PMAB2Solver class >> stepperClass [
+ ^ PMAB2Stepper
]
{ #category : #'as yet unclassified' }
-AB2Solver >> firstStepStartTime: t [
+PMAB2Solver >> firstStepStartTime: t [
state := stepper doStep: state time: t stepSize: self dt.
self announceState: state time: t + self dt.
lastTime := t + self dt.
@@ -27,12 +27,12 @@ AB2Solver >> firstStepStartTime: t [
]
{ #category : #'as yet unclassified' }
-AB2Solver >> firstStepperClass [
+PMAB2Solver >> firstStepperClass [
^ self class firstStepperClass
]
{ #category : #solving }
-AB2Solver >> lastStepPrevState: prevState endTime: endTime [
+PMAB2Solver >> lastStepPrevState: prevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -47,7 +47,7 @@ AB2Solver >> lastStepPrevState: prevState endTime: endTime [
]
{ #category : #'as yet unclassified' }
-AB2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
+PMAB2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
|previousState|
previousState := prevState.
"don't go to end time to avoid overrunning"
@@ -68,7 +68,7 @@ AB2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTi
]
{ #category : #'as yet unclassified' }
-AB2Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMAB2Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState statesPair|
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/AB2Stepper.class.st b/src/Math-ODE/PMAB2Stepper.class.st
similarity index 68%
rename from src/Math-ODE/AB2Stepper.class.st
rename to src/Math-ODE/PMAB2Stepper.class.st
index 6fe44ada8..9ffb8976a 100644
--- a/src/Math-ODE/AB2Stepper.class.st
+++ b/src/Math-ODE/PMAB2Stepper.class.st
@@ -2,33 +2,33 @@
It is stepper for Adams - Bashforth method of order 2. We can't use AB2 method until we have two old solution values. A AB2 method is explicit. We found starting point with Midpoint Method (RK2).
"
Class {
- #name : #AB2Stepper,
- #superclass : #ExplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMAB2Stepper,
+ #superclass : #PMExplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB2Stepper class >> order [
+PMAB2Stepper class >> order [
"AB2 is a second order method."
^ 2
]
{ #category : #stepping }
-AB2Stepper >> doStep: aState prevState: prevState time: t [
+PMAB2Stepper >> doStep: aState prevState: prevState time: t [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
^ (self stepSize / 2) * (3 * (system state: aState time: t) - (system state: prevState time: t - self stepSize)) + aState
]
{ #category : #stepping }
-AB2Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
+PMAB2Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
self stepSize: timeStep.
^ self doStep: aState prevState: prevState time: t .
]
{ #category : #stepping }
-AB2Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime [
+PMAB2Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -37,7 +37,7 @@ AB2Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfT
]
{ #category : #stepping }
-AB2Stepper >> lastStep: aState prevState: prevState time: t stepSize: timeStep deltaT: incrementOfTime [
+PMAB2Stepper >> lastStep: aState prevState: prevState time: t stepSize: timeStep deltaT: incrementOfTime [
self stepSize: timeStep.
^ self lastStep: aState prevState: prevState time: t deltaT: incrementOfTime .
diff --git a/src/Math-ODE/AB3Solver.class.st b/src/Math-ODE/PMAB3Solver.class.st
similarity index 86%
rename from src/Math-ODE/AB3Solver.class.st
rename to src/Math-ODE/PMAB3Solver.class.st
index 9d9e13cfc..3539105ba 100644
--- a/src/Math-ODE/AB3Solver.class.st
+++ b/src/Math-ODE/PMAB3Solver.class.st
@@ -3,23 +3,23 @@ We can't use AB3 method until we have three old solution values. A AB3 method i
"
Class {
- #name : #AB3Solver,
- #superclass : #AB2Solver,
- #category : 'Math-ODE'
+ #name : #PMAB3Solver,
+ #superclass : #PMAB2Solver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB3Solver class >> secondStepperClass [
- ^ AB2Stepper
+PMAB3Solver class >> secondStepperClass [
+ ^ PMAB2Stepper
]
{ #category : #'as yet unclassified' }
-AB3Solver class >> stepperClass [
- ^ AB3Stepper
+PMAB3Solver class >> stepperClass [
+ ^ PMAB3Stepper
]
{ #category : #'as yet unclassified' }
-AB3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
+PMAB3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -35,7 +35,7 @@ AB3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime:
]
{ #category : #'as yet unclassified' }
-AB3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
+PMAB3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
|previousState previousPrevState |
previousState := prevState.
previousPrevState:=prevPrevState.
@@ -61,7 +61,7 @@ AB3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTim
]
{ #category : #'as yet unclassified' }
-AB3Solver >> secondStepPrevState: prevState startTime: t [
+PMAB3Solver >> secondStepPrevState: prevState startTime: t [
state := stepper doStep: state prevState: prevState time: t stepSize: self dt.
self announceState: state time: t + self dt.
@@ -70,12 +70,12 @@ AB3Solver >> secondStepPrevState: prevState startTime: t [
]
{ #category : #'as yet unclassified' }
-AB3Solver >> secondStepperClass [
+PMAB3Solver >> secondStepperClass [
^ self class secondStepperClass
]
{ #category : #'as yet unclassified' }
-AB3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMAB3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState prevPrevState statesPair |
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/AB3Stepper.class.st b/src/Math-ODE/PMAB3Stepper.class.st
similarity index 69%
rename from src/Math-ODE/AB3Stepper.class.st
rename to src/Math-ODE/PMAB3Stepper.class.st
index adbba8d09..1f00815e4 100644
--- a/src/Math-ODE/AB3Stepper.class.st
+++ b/src/Math-ODE/PMAB3Stepper.class.st
@@ -3,19 +3,19 @@ It is stepper for Adams - Bashforth method of order 3. We can't use AB3 method u
"
Class {
- #name : #AB3Stepper,
- #superclass : #ExplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMAB3Stepper,
+ #superclass : #PMExplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB3Stepper class >> order [
+PMAB3Stepper class >> order [
"AB3 is a third order method."
^ 3
]
{ #category : #stepping }
-AB3Stepper >> doStep: thisState prevState:prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime [
+PMAB3Stepper >> doStep: thisState prevState:prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -24,13 +24,13 @@ AB3Stepper >> doStep: thisState prevState:prevState prevPrevState: prevPrevState
]
{ #category : #stepping }
-AB3Stepper >> doStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime stepSize: timeStep [
+PMAB3Stepper >> doStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime stepSize: timeStep [
self stepSize: timeStep.
^ self doStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime .
]
{ #category : #stepping }
-AB3Stepper >> lastStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime deltaT: incrementOfTime [
+PMAB3Stepper >> lastStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime deltaT: incrementOfTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -39,7 +39,7 @@ AB3Stepper >> lastStep: thisState prevState: prevState prevPrevState: prevPrevSt
]
{ #category : #stepping }
-AB3Stepper >> lastStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime stepSize: timeStep deltaT: incrementOfTime [
+PMAB3Stepper >> lastStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime stepSize: timeStep deltaT: incrementOfTime [
self stepSize: timeStep.
^ self lastStep: thisState prevState: prevState prevPrevState: prevPrevState prevPrevTime: prevPrevTime deltaT: incrementOfTime .
]
diff --git a/src/Math-ODE/AB4Solver.class.st b/src/Math-ODE/PMAB4Solver.class.st
similarity index 88%
rename from src/Math-ODE/AB4Solver.class.st
rename to src/Math-ODE/PMAB4Solver.class.st
index fc13ddacd..70f008831 100644
--- a/src/Math-ODE/AB4Solver.class.st
+++ b/src/Math-ODE/PMAB4Solver.class.st
@@ -3,23 +3,23 @@ We can't use AB4 method until we have four old solution values. A AB4 method is
"
Class {
- #name : #AB4Solver,
- #superclass : #AB3Solver,
- #category : 'Math-ODE'
+ #name : #PMAB4Solver,
+ #superclass : #PMAB3Solver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB4Solver class >> stepperClass [
- ^ AB4Stepper
+PMAB4Solver class >> stepperClass [
+ ^ PMAB4Stepper
]
{ #category : #'as yet unclassified' }
-AB4Solver class >> thirdStepperClass [
- ^ AB3Stepper
+PMAB4Solver class >> thirdStepperClass [
+ ^ PMAB3Stepper
]
{ #category : #'as yet unclassified' }
-AB4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initState:initState endTime: endTime [
+PMAB4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initState:initState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -36,7 +36,7 @@ AB4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initState
]
{ #category : #'as yet unclassified' }
-AB4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initState: initState startTime: initialTime endTime: endTime [
+PMAB4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initState: initState startTime: initialTime endTime: endTime [
|previousState previousPrevState initialState |
previousState := prevState.
@@ -67,7 +67,7 @@ AB4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initStat
]
{ #category : #'as yet unclassified' }
-AB4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMAB4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
| prevState prevPrevState statesPair initState |
self system: aSystem.
self stepper: (self firstStepperClass onSystem: self system).
@@ -160,7 +160,7 @@ AB4Solver >> solve: aSystem startState: initialState startTime: initialTime endT
]
{ #category : #'as yet unclassified' }
-AB4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startTime: t [
+PMAB4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startTime: t [
state := stepper doStep: state
prevState: prevState
prevPrevState: prevPrevState
@@ -172,6 +172,6 @@ AB4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startTi
]
{ #category : #'as yet unclassified' }
-AB4Solver >> thirdStepperClass [
+PMAB4Solver >> thirdStepperClass [
^ self class thirdStepperClass
]
diff --git a/src/Math-ODE/AB4Stepper.class.st b/src/Math-ODE/PMAB4Stepper.class.st
similarity index 67%
rename from src/Math-ODE/AB4Stepper.class.st
rename to src/Math-ODE/PMAB4Stepper.class.st
index b74f61e11..658d93b28 100644
--- a/src/Math-ODE/AB4Stepper.class.st
+++ b/src/Math-ODE/PMAB4Stepper.class.st
@@ -3,19 +3,19 @@ It is stepper for Adams - Bashforth method of order 4. We can't use AB4 method u
"
Class {
- #name : #AB4Stepper,
- #superclass : #ExplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMAB4Stepper,
+ #superclass : #PMExplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AB4Stepper class >> order [
+PMAB4Stepper class >> order [
"AB4 is a fourth order method."
^ 4
]
{ #category : #stepping }
-AB4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime [
+PMAB4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -23,13 +23,13 @@ AB4Stepper >> doStep3State: thirdState secondState:secondState firstState: first
]
{ #category : #stepping }
-AB4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime stepSize: timeStep [
+PMAB4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime stepSize: timeStep [
self stepSize: timeStep.
^ self doStep3State: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime .
]
{ #category : #stepping }
-AB4Stepper >> lastStep: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime deltaT: incrementOfTime [
+PMAB4Stepper >> lastStep: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime deltaT: incrementOfTime [
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -38,7 +38,7 @@ AB4Stepper >> lastStep: thirdState secondState:secondState firstState: firstStat
]
{ #category : #stepping }
-AB4Stepper >> lastStep: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime deltaT: incrementOfTime stepSize: timeStep [
+PMAB4Stepper >> lastStep: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime deltaT: incrementOfTime stepSize: timeStep [
self stepSize: timeStep.
^ self lastStep: thirdState secondState:secondState firstState: firstState initState: initState initTime: initTime deltaT: incrementOfTime .
diff --git a/src/Math-ODE/AM3Solver.class.st b/src/Math-ODE/PMAM3Solver.class.st
similarity index 82%
rename from src/Math-ODE/AM3Solver.class.st
rename to src/Math-ODE/PMAM3Solver.class.st
index 5fb41482c..23a0d9811 100644
--- a/src/Math-ODE/AM3Solver.class.st
+++ b/src/Math-ODE/PMAM3Solver.class.st
@@ -3,23 +3,23 @@ We can't use AM3 method until we have old solution value and approximate new one
"
Class {
- #name : #AM3Solver,
- #superclass : #ImplicitSolver,
- #category : 'Math-ODE'
+ #name : #PMAM3Solver,
+ #superclass : #PMImplicitSolver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AM3Solver class >> firstStepperClass [
- ^ TrapezoidStepper
+PMAM3Solver class >> firstStepperClass [
+ ^ PMTrapezoidStepper
]
{ #category : #'as yet unclassified' }
-AM3Solver class >> stepperClass [
- ^ AM3Stepper
+PMAM3Solver class >> stepperClass [
+ ^ PMAM3Stepper
]
{ #category : #'as yet unclassified' }
-AM3Solver >> firstStepStartTime: t [
+PMAM3Solver >> firstStepStartTime: t [
state := stepper doStep: state time: t stepSize: self dt.
self announceState: state time: t + self dt.
lastTime := t + self dt.
@@ -27,12 +27,12 @@ AM3Solver >> firstStepStartTime: t [
]
{ #category : #'as yet unclassified' }
-AM3Solver >> firstStepperClass [
+PMAM3Solver >> firstStepperClass [
^ self class firstStepperClass
]
{ #category : #'as yet unclassified' }
-AM3Solver >> lastStepPrevState: prevState endTime: endTime [
+PMAM3Solver >> lastStepPrevState: prevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -47,7 +47,7 @@ AM3Solver >> lastStepPrevState: prevState endTime: endTime [
]
{ #category : #'as yet unclassified' }
-AM3Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
+PMAM3Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
|previousState|
previousState := prevState.
"don't go to end time to avoid overrunning"
@@ -68,7 +68,7 @@ AM3Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTi
]
{ #category : #'as yet unclassified' }
-AM3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMAM3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState statesPair|
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/AM3Stepper.class.st b/src/Math-ODE/PMAM3Stepper.class.st
similarity index 83%
rename from src/Math-ODE/AM3Stepper.class.st
rename to src/Math-ODE/PMAM3Stepper.class.st
index ac6f1d661..075a953a7 100644
--- a/src/Math-ODE/AM3Stepper.class.st
+++ b/src/Math-ODE/PMAM3Stepper.class.st
@@ -4,19 +4,19 @@ An s-step Adams - Moulton method can reach order s+1.
We can't use AM3 method until we have old solution value and approximate new one. A AM3 method is implicit.
"
Class {
- #name : #AM3Stepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMAM3Stepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AM3Stepper class >> order [
+PMAM3Stepper class >> order [
"AM3 is a third order method."
^ 3
]
{ #category : #stepping }
-AM3Stepper >> doStep: aState prevState: prevState time: t [
+PMAM3Stepper >> doStep: aState prevState: prevState time: t [
| approximateState1 approximateState2 |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -36,7 +36,7 @@ AM3Stepper >> doStep: aState prevState: prevState time: t [
]
{ #category : #stepping }
-AM3Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
+PMAM3Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
@@ -44,7 +44,7 @@ AM3Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
]
{ #category : #stepping }
-AM3Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime [
+PMAM3Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime [
| approximateState1 approximateState2 |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -64,7 +64,7 @@ AM3Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfT
]
{ #category : #stepping }
-AM3Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime stepSize: timeStep [
+PMAM3Stepper >> lastStep: aState prevState: prevState time: t deltaT: incrementOfTime stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
diff --git a/src/Math-ODE/AM4Solver.class.st b/src/Math-ODE/PMAM4Solver.class.st
similarity index 86%
rename from src/Math-ODE/AM4Solver.class.st
rename to src/Math-ODE/PMAM4Solver.class.st
index 16718caa8..4763c3ccd 100644
--- a/src/Math-ODE/AM4Solver.class.st
+++ b/src/Math-ODE/PMAM4Solver.class.st
@@ -3,23 +3,23 @@ We can't use AM4 method until we have two old solution values and approximate n
"
Class {
- #name : #AM4Solver,
- #superclass : #AM3Solver,
- #category : 'Math-ODE'
+ #name : #PMAM4Solver,
+ #superclass : #PMAM3Solver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AM4Solver class >> secondStepperClass [
- ^ AM3Stepper
+PMAM4Solver class >> secondStepperClass [
+ ^ PMAM3Stepper
]
{ #category : #'as yet unclassified' }
-AM4Solver class >> stepperClass [
- ^ AM4Stepper
+PMAM4Solver class >> stepperClass [
+ ^ PMAM4Stepper
]
{ #category : #'as yet unclassified' }
-AM4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
+PMAM4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -35,7 +35,7 @@ AM4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime:
]
{ #category : #'as yet unclassified' }
-AM4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
+PMAM4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
|previousState previousPrevState |
previousState := prevState.
previousPrevState:=prevPrevState.
@@ -59,7 +59,7 @@ AM4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTim
]
{ #category : #'as yet unclassified' }
-AM4Solver >> secondStepPrevState: prevState startTime: t [
+PMAM4Solver >> secondStepPrevState: prevState startTime: t [
state := stepper doStep: state prevState: prevState time: t stepSize: self dt.
self announceState: state time: t + self dt.
@@ -68,12 +68,12 @@ AM4Solver >> secondStepPrevState: prevState startTime: t [
]
{ #category : #'as yet unclassified' }
-AM4Solver >> secondStepperClass [
+PMAM4Solver >> secondStepperClass [
^ self class secondStepperClass
]
{ #category : #'as yet unclassified' }
-AM4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMAM4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState prevPrevState statesPair |
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/AM4Stepper.class.st b/src/Math-ODE/PMAM4Stepper.class.st
similarity index 81%
rename from src/Math-ODE/AM4Stepper.class.st
rename to src/Math-ODE/PMAM4Stepper.class.st
index e7b9e14a2..9d1ab3151 100644
--- a/src/Math-ODE/AM4Stepper.class.st
+++ b/src/Math-ODE/PMAM4Stepper.class.st
@@ -4,19 +4,19 @@ An s-step Adams - Moulton method can reach order s+1.
We can't use AM4 method until we have two old solution values and approximate new one. A AM4 method is implicit.
"
Class {
- #name : #AM4Stepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMAM4Stepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-AM4Stepper class >> order [
+PMAM4Stepper class >> order [
"AM4 is a fourth order method."
^ 4
]
{ #category : #stepping }
-AM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t [
+PMAM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t [
| approximateState1 approximateState2 |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -38,7 +38,7 @@ AM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState t
]
{ #category : #stepping }
-AM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t stepSize: timeStep [
+PMAM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
@@ -50,7 +50,7 @@ AM4Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState t
]
{ #category : #stepping }
-AM4Stepper >> lastStep: aState prevState: prevState prevPrevState: prevPrevState time: t deltaT: incrementOfTime [
+PMAM4Stepper >> lastStep: aState prevState: prevState prevPrevState: prevPrevState time: t deltaT: incrementOfTime [
| approximateState1 approximateState2 |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -72,7 +72,7 @@ AM4Stepper >> lastStep: aState prevState: prevState prevPrevState: prevPrevState
]
{ #category : #stepping }
-AM4Stepper >> lastStep: aState prevState: prevState prevPrevState: prevPrevState time: t deltaT: incrementOfTime stepSize: timeStep [
+PMAM4Stepper >> lastStep: aState prevState: prevState prevPrevState: prevPrevState time: t deltaT: incrementOfTime stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
diff --git a/src/Math-ODE/BDF2Solver.class.st b/src/Math-ODE/PMBDF2Solver.class.st
similarity index 81%
rename from src/Math-ODE/BDF2Solver.class.st
rename to src/Math-ODE/PMBDF2Solver.class.st
index 8c9f313e3..2860a0f71 100644
--- a/src/Math-ODE/BDF2Solver.class.st
+++ b/src/Math-ODE/PMBDF2Solver.class.st
@@ -3,23 +3,23 @@ We can't use BDF2 method until we have old solution value and approximate new on
"
Class {
- #name : #BDF2Solver,
- #superclass : #ImplicitSolver,
- #category : 'Math-ODE'
+ #name : #PMBDF2Solver,
+ #superclass : #PMImplicitSolver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF2Solver class >> firstStepperClass [
- ^ ImplicitStepper
+PMBDF2Solver class >> firstStepperClass [
+ ^ PMImplicitStepper
]
{ #category : #'as yet unclassified' }
-BDF2Solver class >> stepperClass [
- ^ BDF2Stepper
+PMBDF2Solver class >> stepperClass [
+ ^ PMBDF2Stepper
]
{ #category : #'as yet unclassified' }
-BDF2Solver >> firstStepStartTime: t [
+PMBDF2Solver >> firstStepStartTime: t [
state := stepper doStep: state time: t stepSize: self dt.
self announceState: state time: t + self dt.
@@ -28,12 +28,12 @@ BDF2Solver >> firstStepStartTime: t [
]
{ #category : #'as yet unclassified' }
-BDF2Solver >> firstStepperClass [
+PMBDF2Solver >> firstStepperClass [
^ self class firstStepperClass
]
{ #category : #'as yet unclassified' }
-BDF2Solver >> lastStepPrevState: prevState endTime: endTime [
+PMBDF2Solver >> lastStepPrevState: prevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -47,7 +47,7 @@ BDF2Solver >> lastStepPrevState: prevState endTime: endTime [
]
{ #category : #'as yet unclassified' }
-BDF2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
+PMBDF2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endTime [
|previousState|
previousState := prevState.
@@ -69,7 +69,7 @@ BDF2Solver >> mainStepsPrevState: prevState startTime: initialTime endTime: endT
]
{ #category : #'as yet unclassified' }
-BDF2Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMBDF2Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState statesPair|
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/BDF2Stepper.class.st b/src/Math-ODE/PMBDF2Stepper.class.st
similarity index 73%
rename from src/Math-ODE/BDF2Stepper.class.st
rename to src/Math-ODE/PMBDF2Stepper.class.st
index 76734af41..9ccc03358 100644
--- a/src/Math-ODE/BDF2Stepper.class.st
+++ b/src/Math-ODE/PMBDF2Stepper.class.st
@@ -5,19 +5,19 @@ It is stepper for Backward differentiation formulas method of order 2. We can't
"
Class {
- #name : #BDF2Stepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMBDF2Stepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF2Stepper class >> order [
+PMBDF2Stepper class >> order [
"BDF2 is a second order method."
^ 2
]
{ #category : #stepping }
-BDF2Stepper >> doStep: aState prevState: prevState time: t [
+PMBDF2Stepper >> doStep: aState prevState: prevState time: t [
|approximateState |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -26,7 +26,7 @@ approximateState := (system state: aState time: t) * self stepSize + aState.
]
{ #category : #stepping }
-BDF2Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
+PMBDF2Stepper >> doStep: aState prevState: prevState time: t stepSize: timeStep [
self stepSize: timeStep.
^ self doStep: aState prevState: prevState time: t
]
diff --git a/src/Math-ODE/BDF3Solver.class.st b/src/Math-ODE/PMBDF3Solver.class.st
similarity index 86%
rename from src/Math-ODE/BDF3Solver.class.st
rename to src/Math-ODE/PMBDF3Solver.class.st
index 7b5468ad8..20ce58478 100644
--- a/src/Math-ODE/BDF3Solver.class.st
+++ b/src/Math-ODE/PMBDF3Solver.class.st
@@ -3,23 +3,23 @@ We can't use BDF3 method until we have two old solution values and approximate
"
Class {
- #name : #BDF3Solver,
- #superclass : #BDF2Solver,
- #category : 'Math-ODE'
+ #name : #PMBDF3Solver,
+ #superclass : #PMBDF2Solver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF3Solver class >> secondStepperClass [
- ^ BDF2Stepper
+PMBDF3Solver class >> secondStepperClass [
+ ^ PMBDF2Stepper
]
{ #category : #'as yet unclassified' }
-BDF3Solver class >> stepperClass [
- ^ BDF3Stepper
+PMBDF3Solver class >> stepperClass [
+ ^ PMBDF3Stepper
]
{ #category : #'as yet unclassified' }
-BDF3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
+PMBDF3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -34,7 +34,7 @@ BDF3Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState endTime:
]
{ #category : #'as yet unclassified' }
-BDF3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
+PMBDF3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTime: initialTime endTime: endTime [
|previousState previousPrevState |
previousState := prevState.
previousPrevState:=prevPrevState.
@@ -58,7 +58,7 @@ BDF3Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState startTi
]
{ #category : #'as yet unclassified' }
-BDF3Solver >> secondStepPrevState: prevState startTime: t [
+PMBDF3Solver >> secondStepPrevState: prevState startTime: t [
state := stepper doStep: state prevState: prevState time: t stepSize: self dt.
self announceState: state time: t + self dt.
@@ -67,12 +67,12 @@ BDF3Solver >> secondStepPrevState: prevState startTime: t [
]
{ #category : #'as yet unclassified' }
-BDF3Solver >> secondStepperClass [
+PMBDF3Solver >> secondStepperClass [
^ self class secondStepperClass
]
{ #category : #'as yet unclassified' }
-BDF3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMBDF3Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
|prevState prevPrevState statesPair |
self system: aSystem.
self stepper: ((self firstStepperClass) onSystem: self system).
diff --git a/src/Math-ODE/BDF3Stepper.class.st b/src/Math-ODE/PMBDF3Stepper.class.st
similarity index 70%
rename from src/Math-ODE/BDF3Stepper.class.st
rename to src/Math-ODE/PMBDF3Stepper.class.st
index b25a42f3e..195175d14 100644
--- a/src/Math-ODE/BDF3Stepper.class.st
+++ b/src/Math-ODE/PMBDF3Stepper.class.st
@@ -5,19 +5,19 @@ We can't use BDF3 method until we have two old solution values and approximate
"
Class {
- #name : #BDF3Stepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMBDF3Stepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF3Stepper class >> order [
+PMBDF3Stepper class >> order [
"BDF3 is a third order method."
^ 3
]
{ #category : #stepping }
-BDF3Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t [
+PMBDF3Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t [
|approximateState |
self stepSize isNil
ifTrue: [ self error: 'step size required by stepper' ].
@@ -26,7 +26,7 @@ approximateState := (system state: aState time: t) * self stepSize + aState.
]
{ #category : #stepping }
-BDF3Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t stepSize: timeStep [
+PMBDF3Stepper >> doStep: aState prevState: prevState prevPrevState: prevPrevState time: t stepSize: timeStep [
self stepSize: timeStep.
^ self doStep: aState prevState: prevState prevPrevState: prevPrevState time: t
]
diff --git a/src/Math-ODE/BDF4Solver.class.st b/src/Math-ODE/PMBDF4Solver.class.st
similarity index 88%
rename from src/Math-ODE/BDF4Solver.class.st
rename to src/Math-ODE/PMBDF4Solver.class.st
index 52fced2c1..737103eee 100644
--- a/src/Math-ODE/BDF4Solver.class.st
+++ b/src/Math-ODE/PMBDF4Solver.class.st
@@ -3,23 +3,23 @@ We can't use BDF4 method until we have three old solution values and approximat
"
Class {
- #name : #BDF4Solver,
- #superclass : #BDF3Solver,
- #category : 'Math-ODE'
+ #name : #PMBDF4Solver,
+ #superclass : #PMBDF3Solver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF4Solver class >> stepperClass [
- ^ BDF4Stepper
+PMBDF4Solver class >> stepperClass [
+ ^ PMBDF4Stepper
]
{ #category : #'as yet unclassified' }
-BDF4Solver class >> thirdStepperClass [
- ^ BDF3Stepper
+PMBDF4Solver class >> thirdStepperClass [
+ ^ PMBDF3Stepper
]
{ #category : #'as yet unclassified' }
-BDF4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initState:initState endTime: endTime [
+PMBDF4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initState:initState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -35,7 +35,7 @@ BDF4Solver >> lastStepPrevState: prevState prevPrevState: prevPrevState initStat
]
{ #category : #'as yet unclassified' }
-BDF4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initState: initState startTime: initialTime endTime: endTime [
+PMBDF4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initState: initState startTime: initialTime endTime: endTime [
|previousState previousPrevState initialState |
previousState := prevState.
@@ -66,7 +66,7 @@ BDF4Solver >> mainStepsPrevState: prevState prevPrevState: prevPrevState initSta
]
{ #category : #'as yet unclassified' }
-BDF4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMBDF4Solver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
| prevState prevPrevState statesPair initState |
self system: aSystem.
self stepper: (self firstStepperClass onSystem: self system).
@@ -160,7 +160,7 @@ BDF4Solver >> solve: aSystem startState: initialState startTime: initialTime end
]
{ #category : #'as yet unclassified' }
-BDF4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startTime: t [
+PMBDF4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startTime: t [
state := stepper doStep: state
prevState: prevState
prevPrevState: prevPrevState
@@ -172,6 +172,6 @@ BDF4Solver >> thirdStepPrevState: prevState prevPrevState: prevPrevState startT
]
{ #category : #'as yet unclassified' }
-BDF4Solver >> thirdStepperClass [
+PMBDF4Solver >> thirdStepperClass [
^ self class thirdStepperClass
]
diff --git a/src/Math-ODE/BDF4Stepper.class.st b/src/Math-ODE/PMBDF4Stepper.class.st
similarity index 72%
rename from src/Math-ODE/BDF4Stepper.class.st
rename to src/Math-ODE/PMBDF4Stepper.class.st
index 65b3e45f0..f44f52b9c 100644
--- a/src/Math-ODE/BDF4Stepper.class.st
+++ b/src/Math-ODE/PMBDF4Stepper.class.st
@@ -4,19 +4,19 @@ We can't use BDF4 method until we have three old solution values and approximat
"
Class {
- #name : #BDF4Stepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMBDF4Stepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-BDF4Stepper class >> order [
+PMBDF4Stepper class >> order [
"BDF4 is a fourth order method."
^ 4
]
{ #category : #stepping }
-BDF4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState
+PMBDF4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState
thirdTime: t [
|approximateState |
self stepSize isNil
@@ -26,7 +26,7 @@ approximateState := (system state: thirdState time: t) * self stepSize + thirdSt
]
{ #category : #stepping }
-BDF4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState
+PMBDF4Stepper >> doStep3State: thirdState secondState:secondState firstState: firstState initState: initState
thirdTime: t stepSize: timeStep [
self stepSize: timeStep.
^ self doStep3State: thirdState secondState:secondState firstState: firstState initState: initState thirdTime: t
diff --git a/src/Math-ODE/ButcherTableauStepper.class.st b/src/Math-ODE/PMButcherTableauStepper.class.st
similarity index 72%
rename from src/Math-ODE/ButcherTableauStepper.class.st
rename to src/Math-ODE/PMButcherTableauStepper.class.st
index f38b3ee3d..d8ce5f0d9 100644
--- a/src/Math-ODE/ButcherTableauStepper.class.st
+++ b/src/Math-ODE/PMButcherTableauStepper.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #ButcherTableauStepper,
- #superclass : #Stepper,
+ #name : #PMButcherTableauStepper,
+ #superclass : #PMStepper,
#instVars : [
'stageIncrements',
'stageCoefficients',
'stageWeights'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'instance creation' }
-ButcherTableauStepper class >> eulerStepper [
+PMButcherTableauStepper class >> eulerStepper [
| a b |
a := PMMatrix rows: #((0)).
b := #(1).
@@ -18,7 +18,7 @@ ButcherTableauStepper class >> eulerStepper [
]
{ #category : #'instance creation' }
-ButcherTableauStepper class >> kuttaThreeEighthsStepper [
+PMButcherTableauStepper class >> kuttaThreeEighthsStepper [
| a b |
a := PMMatrix rows: #((0 0 0 0) ((1 / 3) 0 0 0) ((-1 / 3 ) 1 0 0) (0 1 -1 1)).
b := #((1 / 8) (3 / 8) (3 / 8) (1 / 8)).
@@ -26,7 +26,7 @@ ButcherTableauStepper class >> kuttaThreeEighthsStepper [
]
{ #category : #'instance creation' }
-ButcherTableauStepper class >> rungeKuttaStepper [
+PMButcherTableauStepper class >> rungeKuttaStepper [
| a b |
a := PMMatrix rows: #((0 0 0 0) (0.5 0 0 0) (0 0.5 0 0) (0 0 1 0)).
b := #((1 / 6) (1 / 3) (1 / 3) (1 / 6)).
@@ -34,7 +34,7 @@ ButcherTableauStepper class >> rungeKuttaStepper [
]
{ #category : #'instance creation' }
-ButcherTableauStepper class >> rungeStepper [
+PMButcherTableauStepper class >> rungeStepper [
| a b |
a := PMMatrix rows: #((0 0) (0.5 0)).
b := #(0 1).
@@ -42,7 +42,7 @@ ButcherTableauStepper class >> rungeStepper [
]
{ #category : #'instance creation' }
-ButcherTableauStepper class >> stageWeights: anArray stageCoefficients: aMatrix [
+PMButcherTableauStepper class >> stageWeights: anArray stageCoefficients: aMatrix [
| c |
"stageWeights is the array b, stageCoefficients is the lower triangular matrix A"
self assert: [anArray sum = 1].
@@ -58,7 +58,7 @@ ButcherTableauStepper class >> stageWeights: anArray stageCoefficients: aMatrix
]
{ #category : #stepping }
-ButcherTableauStepper >> doStep: aStateTime stepSize: dt [
+PMButcherTableauStepper >> doStep: aStateTime stepSize: dt [
"not complete"
| stages stageCount stateDifference|
self isInitialized.
@@ -80,12 +80,12 @@ ButcherTableauStepper >> doStep: aStateTime stepSize: dt [
]
{ #category : #stepping }
-ButcherTableauStepper >> doStep: aState time: aTime stepSize: dt [
- ^ self doStep: (StateTime state: aState time: aTime) stepSize: dt.
+PMButcherTableauStepper >> doStep: aState time: aTime stepSize: dt [
+ ^ self doStep: (PMStateTime state: aState time: aTime) stepSize: dt.
]
{ #category : #assertion }
-ButcherTableauStepper >> isInitialized [
+PMButcherTableauStepper >> isInitialized [
self assert: [stageCoefficients notNil].
self assert: [stageIncrements notNil].
self assert: [stageWeights notNil].
@@ -94,35 +94,35 @@ ButcherTableauStepper >> isInitialized [
]
{ #category : #accessing }
-ButcherTableauStepper >> stageCoefficients [
+PMButcherTableauStepper >> stageCoefficients [
^ stageCoefficients
]
{ #category : #accessing }
-ButcherTableauStepper >> stageCoefficients: aMatrix [
+PMButcherTableauStepper >> stageCoefficients: aMatrix [
stageCoefficients := aMatrix
]
{ #category : #accessing }
-ButcherTableauStepper >> stageIncrements [
+PMButcherTableauStepper >> stageIncrements [
^ stageIncrements
]
{ #category : #accessing }
-ButcherTableauStepper >> stageIncrements: anArray [
+PMButcherTableauStepper >> stageIncrements: anArray [
stageIncrements := anArray
]
{ #category : #accessing }
-ButcherTableauStepper >> stageWeights [
+PMButcherTableauStepper >> stageWeights [
^ stageWeights
]
{ #category : #accessing }
-ButcherTableauStepper >> stageWeights: anArray [
+PMButcherTableauStepper >> stageWeights: anArray [
stageWeights := anArray
]
diff --git a/src/Math-ODE/ExplicitAnnouncer.class.st b/src/Math-ODE/PMExplicitAnnouncer.class.st
similarity index 71%
rename from src/Math-ODE/ExplicitAnnouncer.class.st
rename to src/Math-ODE/PMExplicitAnnouncer.class.st
index a3f8a57b2..805b7c897 100644
--- a/src/Math-ODE/ExplicitAnnouncer.class.st
+++ b/src/Math-ODE/PMExplicitAnnouncer.class.st
@@ -2,7 +2,7 @@
An ExplicitAnnouncer is used by ODESolver to announce step results (ExplicitSolverAnnouncement).
"
Class {
- #name : #ExplicitAnnouncer,
+ #name : #PMExplicitAnnouncer,
#superclass : #Announcer,
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/ExplicitMultiStepper.class.st b/src/Math-ODE/PMExplicitMultiStepper.class.st
similarity index 70%
rename from src/Math-ODE/ExplicitMultiStepper.class.st
rename to src/Math-ODE/PMExplicitMultiStepper.class.st
index 4847ed8b2..ea5ec6d2d 100644
--- a/src/Math-ODE/ExplicitMultiStepper.class.st
+++ b/src/Math-ODE/PMExplicitMultiStepper.class.st
@@ -4,7 +4,7 @@ Explicit means that the new state of the ode can be computed explicitly from the
"
Class {
- #name : #ExplicitMultiStepper,
- #superclass : #MultiStepper,
- #category : 'Math-ODE'
+ #name : #PMExplicitMultiStepper,
+ #superclass : #PMMultiStepper,
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/PMExplicitSolver.class.st b/src/Math-ODE/PMExplicitSolver.class.st
new file mode 100644
index 000000000..02b42dff5
--- /dev/null
+++ b/src/Math-ODE/PMExplicitSolver.class.st
@@ -0,0 +1,21 @@
+Class {
+ #name : #PMExplicitSolver,
+ #superclass : #PMODESolver,
+ #category : #'Math-ODE'
+}
+
+{ #category : #'as yet unclassified' }
+PMExplicitSolver class >> stepperClass [
+ ^ PMExplicitStepper.
+]
+
+{ #category : #'announcement hooks' }
+PMExplicitSolver >> announcementClass [
+ ^ PMExplicitSolverAnnouncement
+]
+
+{ #category : #'announcement hooks' }
+PMExplicitSolver >> announcerClass [
+
+ ^ PMExplicitAnnouncer
+]
diff --git a/src/Math-ODE/ExplicitSolverAnnouncement.class.st b/src/Math-ODE/PMExplicitSolverAnnouncement.class.st
similarity index 59%
rename from src/Math-ODE/ExplicitSolverAnnouncement.class.st
rename to src/Math-ODE/PMExplicitSolverAnnouncement.class.st
index 3e53392ee..a42dd6199 100644
--- a/src/Math-ODE/ExplicitSolverAnnouncement.class.st
+++ b/src/Math-ODE/PMExplicitSolverAnnouncement.class.st
@@ -2,32 +2,32 @@
An ExplicitSolverAnnouncement is a record of a step in an explicit system. It contains a time and a state.
"
Class {
- #name : #ExplicitSolverAnnouncement,
+ #name : #PMExplicitSolverAnnouncement,
#superclass : #Announcement,
#instVars : [
't',
'state'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #accessing }
-ExplicitSolverAnnouncement class >> state: aState time: aTime [
+PMExplicitSolverAnnouncement class >> state: aState time: aTime [
^ self new state: aState time: aTime; yourself.
]
{ #category : #accessing }
-ExplicitSolverAnnouncement >> state [
+PMExplicitSolverAnnouncement >> state [
^ state
]
{ #category : #accessing }
-ExplicitSolverAnnouncement >> state: aState time: aTime [
+PMExplicitSolverAnnouncement >> state: aState time: aTime [
state:= aState.
t := aTime.
]
{ #category : #accessing }
-ExplicitSolverAnnouncement >> time [
+PMExplicitSolverAnnouncement >> time [
^ t
]
diff --git a/src/Math-ODE/ExplicitSolverSubscriber.class.st b/src/Math-ODE/PMExplicitSolverSubscriber.class.st
similarity index 63%
rename from src/Math-ODE/ExplicitSolverSubscriber.class.st
rename to src/Math-ODE/PMExplicitSolverSubscriber.class.st
index 3347c93d2..5be44ae16 100644
--- a/src/Math-ODE/ExplicitSolverSubscriber.class.st
+++ b/src/Math-ODE/PMExplicitSolverSubscriber.class.st
@@ -3,54 +3,54 @@ An ExplicitSolverSubscriber implements the minimal behavior to attach to an ODES
"
Class {
- #name : #ExplicitSolverSubscriber,
+ #name : #PMExplicitSolverSubscriber,
#superclass : #Object,
#instVars : [
'announcers',
'block'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'instance creation' }
-ExplicitSolverSubscriber class >> forAnnouncer: anAnnouncer [
+PMExplicitSolverSubscriber class >> forAnnouncer: anAnnouncer [
^ self new forAnnouncer: anAnnouncer.
]
{ #category : #'instance creation' }
-ExplicitSolverSubscriber class >> forSolver: anODESolver [
+PMExplicitSolverSubscriber class >> forSolver: anODESolver [
^ self forAnnouncer: anODESolver announcer
]
{ #category : #accessing }
-ExplicitSolverSubscriber >> announcers [
+PMExplicitSolverSubscriber >> announcers [
^ announcers
]
{ #category : #accessing }
-ExplicitSolverSubscriber >> block [
+PMExplicitSolverSubscriber >> block [
^ block
]
{ #category : #accessing }
-ExplicitSolverSubscriber >> block: aFormatBlock [
+PMExplicitSolverSubscriber >> block: aFormatBlock [
block := aFormatBlock
]
{ #category : #accessing }
-ExplicitSolverSubscriber >> defaultBlock [
+PMExplicitSolverSubscriber >> defaultBlock [
^ self subclassResponsibility
]
{ #category : #subscription }
-ExplicitSolverSubscriber >> forAnnouncer: anAnnouncer [
- anAnnouncer on: ExplicitSolverAnnouncement do: self block.
+PMExplicitSolverSubscriber >> forAnnouncer: anAnnouncer [
+ anAnnouncer on: PMExplicitSolverAnnouncement do: self block.
announcers add: anAnnouncer.
]
{ #category : #'initialize-release' }
-ExplicitSolverSubscriber >> initialize [
+PMExplicitSolverSubscriber >> initialize [
super initialize.
announcers := IdentitySet new.
block := self defaultBlock.
@@ -58,20 +58,20 @@ ExplicitSolverSubscriber >> initialize [
]
{ #category : #'initialize-release' }
-ExplicitSolverSubscriber >> release [
+PMExplicitSolverSubscriber >> release [
"stop announcers from sending messages"
self unsubscribe.
super release.
]
{ #category : #subscription }
-ExplicitSolverSubscriber >> unsubscribe [
+PMExplicitSolverSubscriber >> unsubscribe [
announcers do: [:ea | self unsubscribe: ea].
]
{ #category : #subscription }
-ExplicitSolverSubscriber >> unsubscribe: anAnnouncer [
+PMExplicitSolverSubscriber >> unsubscribe: anAnnouncer [
anAnnouncer unsubscribe: self.
announcers remove: anAnnouncer ifAbsent: [].
]
diff --git a/src/Math-ODE/ExplicitStepper.class.st b/src/Math-ODE/PMExplicitStepper.class.st
similarity index 83%
rename from src/Math-ODE/ExplicitStepper.class.st
rename to src/Math-ODE/PMExplicitStepper.class.st
index 63390d30f..f2ff6049c 100644
--- a/src/Math-ODE/ExplicitStepper.class.st
+++ b/src/Math-ODE/PMExplicitStepper.class.st
@@ -10,19 +10,19 @@ do_step( sys , in , dxdtin , t , out , dt )
Here, the additional parameter is the value of the function f at state x and time t.
"
Class {
- #name : #ExplicitStepper,
- #superclass : #Stepper,
- #category : 'Math-ODE'
+ #name : #PMExplicitStepper,
+ #superclass : #PMStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-ExplicitStepper class >> order [
+PMExplicitStepper class >> order [
"the default ExplicitStepper is a Euler Method, order 1"
^ 1
]
{ #category : #stepping }
-ExplicitStepper >> doStep: aState time: t [
+PMExplicitStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. The default implementation here is Euler Method. Subclasses should override"
self stepSize isNil ifTrue: [self error: 'step size required by stepper'].
^ self stepSize * (system state: aState time: t) + aState
@@ -30,7 +30,7 @@ ExplicitStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-ExplicitStepper >> doStep: aState time: t stepSize: timeStep [
+PMExplicitStepper >> doStep: aState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. The default implementation here is Euler Method. Subclasses should override"
| dxdt |
self stepSize: timeStep.
@@ -38,7 +38,7 @@ ExplicitStepper >> doStep: aState time: t stepSize: timeStep [
]
{ #category : #stepping }
-ExplicitStepper >> lastStep: aState time: t deltaT: incrementOfTime [
+PMExplicitStepper >> lastStep: aState time: t deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. The default implementation here is Euler Method. Subclasses should override"
self stepSize isNil ifTrue: [self error: 'step size required by stepper'].
^ self stepSize * (system state: aState time: t- self stepSize + incrementOfTime) + aState
@@ -46,7 +46,7 @@ ExplicitStepper >> lastStep: aState time: t deltaT: incrementOfTime [
]
{ #category : #stepping }
-ExplicitStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
+PMExplicitStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. The default implementation here is Euler Method. Subclasses should override"
| |
self stepSize: timeStep.
diff --git a/src/Math-ODE/ExplicitSystem.class.st b/src/Math-ODE/PMExplicitSystem.class.st
similarity index 92%
rename from src/Math-ODE/ExplicitSystem.class.st
rename to src/Math-ODE/PMExplicitSystem.class.st
index 74e07612c..3679a488b 100644
--- a/src/Math-ODE/ExplicitSystem.class.st
+++ b/src/Math-ODE/PMExplicitSystem.class.st
@@ -10,7 +10,7 @@ Other types of system function represent Hamiltonian systems or system which als
"
Class {
- #name : #ExplicitSystem,
- #superclass : #ODESystem,
- #category : 'Math-ODE'
+ #name : #PMExplicitSystem,
+ #superclass : #PMODESystem,
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/HeunStepper.class.st b/src/Math-ODE/PMHeunStepper.class.st
similarity index 80%
rename from src/Math-ODE/HeunStepper.class.st
rename to src/Math-ODE/PMHeunStepper.class.st
index bd3a21e06..ad24d8bae 100644
--- a/src/Math-ODE/HeunStepper.class.st
+++ b/src/Math-ODE/PMHeunStepper.class.st
@@ -3,19 +3,19 @@ Heun's method may refer to the improved or modified Euler's method (that is, the
"
Class {
- #name : #HeunStepper,
- #superclass : #ExplicitStepper,
- #category : 'Math-ODE'
+ #name : #PMHeunStepper,
+ #superclass : #PMExplicitStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-HeunStepper class >> order [
+PMHeunStepper class >> order [
"Heun's method is a second order method."
^ 2
]
{ #category : #stepping }
-HeunStepper >> doStep: aState time: t [
+PMHeunStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
| xi ti |
@@ -28,7 +28,7 @@ HeunStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-HeunStepper >> doStep: aState time: t stepSize: timeStep [
+PMHeunStepper >> doStep: aState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
^ self doStep: aState time: t.
diff --git a/src/Math-ODE/ImplicitAnnouncer.class.st b/src/Math-ODE/PMImplicitAnnouncer.class.st
similarity index 71%
rename from src/Math-ODE/ImplicitAnnouncer.class.st
rename to src/Math-ODE/PMImplicitAnnouncer.class.st
index ee4ce60f8..4f836d779 100644
--- a/src/Math-ODE/ImplicitAnnouncer.class.st
+++ b/src/Math-ODE/PMImplicitAnnouncer.class.st
@@ -2,7 +2,7 @@
An ImplicitAnnouncer is used by ODESolver to announce step results (ImplicitSolverAnnouncement).
"
Class {
- #name : #ImplicitAnnouncer,
+ #name : #PMImplicitAnnouncer,
#superclass : #Announcer,
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/ImplicitMidpointSolver.class.st b/src/Math-ODE/PMImplicitMidpointSolver.class.st
similarity index 71%
rename from src/Math-ODE/ImplicitMidpointSolver.class.st
rename to src/Math-ODE/PMImplicitMidpointSolver.class.st
index 619e22831..86b2dfc72 100644
--- a/src/Math-ODE/ImplicitMidpointSolver.class.st
+++ b/src/Math-ODE/PMImplicitMidpointSolver.class.st
@@ -3,18 +3,18 @@ The implicit midpoint method is equavelent to the so-called 2nd order Gauss meth
"
Class {
- #name : #ImplicitMidpointSolver,
- #superclass : #ImplicitSolver,
- #category : 'Math-ODE'
+ #name : #PMImplicitMidpointSolver,
+ #superclass : #PMImplicitSolver,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-ImplicitMidpointSolver class >> stepperClass [
- ^ ImplicitMidpointStepper
+PMImplicitMidpointSolver class >> stepperClass [
+ ^ PMImplicitMidpointStepper
]
{ #category : #'as yet unclassified' }
-ImplicitMidpointSolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMImplicitMidpointSolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
self system: aSystem.
stepper ifNil: [
diff --git a/src/Math-ODE/ImplicitMidpointStepper.class.st b/src/Math-ODE/PMImplicitMidpointStepper.class.st
similarity index 76%
rename from src/Math-ODE/ImplicitMidpointStepper.class.st
rename to src/Math-ODE/PMImplicitMidpointStepper.class.st
index 895defd4e..e9799c38e 100644
--- a/src/Math-ODE/ImplicitMidpointStepper.class.st
+++ b/src/Math-ODE/PMImplicitMidpointStepper.class.st
@@ -3,19 +3,19 @@ The implicit midpoint method is equavelent to the so-called 2nd order Gauss meth
"
Class {
- #name : #ImplicitMidpointStepper,
- #superclass : #ImplicitStepper,
- #category : 'Math-ODE'
+ #name : #PMImplicitMidpointStepper,
+ #superclass : #PMImplicitStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-ImplicitMidpointStepper class >> order [
+PMImplicitMidpointStepper class >> order [
"Implicit Midpoint is a second order method."
^ 2
]
{ #category : #stepping }
-ImplicitMidpointStepper >> doStep: aState time: t [
+PMImplicitMidpointStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
| xi1 xi2 ti |
@@ -29,7 +29,7 @@ ImplicitMidpointStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-ImplicitMidpointStepper >> doStep: aState time: t stepSize: timeStep [
+PMImplicitMidpointStepper >> doStep: aState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
^ self doStep: aState time: t.
diff --git a/src/Math-ODE/ImplicitMultiStepper.class.st b/src/Math-ODE/PMImplicitMultiStepper.class.st
similarity index 70%
rename from src/Math-ODE/ImplicitMultiStepper.class.st
rename to src/Math-ODE/PMImplicitMultiStepper.class.st
index e3fc929ca..bf145ab10 100644
--- a/src/Math-ODE/ImplicitMultiStepper.class.st
+++ b/src/Math-ODE/PMImplicitMultiStepper.class.st
@@ -5,7 +5,7 @@ Implicit methods find a solution by solving an equation involving the current s
"
Class {
- #name : #ImplicitMultiStepper,
- #superclass : #MultiStepper,
- #category : 'Math-ODE'
+ #name : #PMImplicitMultiStepper,
+ #superclass : #PMMultiStepper,
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/PMImplicitSolver.class.st b/src/Math-ODE/PMImplicitSolver.class.st
new file mode 100644
index 000000000..e0cb8232f
--- /dev/null
+++ b/src/Math-ODE/PMImplicitSolver.class.st
@@ -0,0 +1,22 @@
+Class {
+ #name : #PMImplicitSolver,
+ #superclass : #PMODESolver,
+ #category : #'Math-ODE'
+}
+
+{ #category : #'as yet unclassified' }
+PMImplicitSolver class >> stepperClass [
+ ^ PMImplicitStepper.
+]
+
+{ #category : #'announcement hooks' }
+PMImplicitSolver >> announcementClass [
+
+ ^ PMImplicitSolverAnnouncement
+]
+
+{ #category : #'announcement hooks' }
+PMImplicitSolver >> announcerClass [
+
+ ^ PMImplicitAnnouncer
+]
diff --git a/src/Math-ODE/ImplicitSolverAnnouncement.class.st b/src/Math-ODE/PMImplicitSolverAnnouncement.class.st
similarity index 60%
rename from src/Math-ODE/ImplicitSolverAnnouncement.class.st
rename to src/Math-ODE/PMImplicitSolverAnnouncement.class.st
index 192c6a1e6..b6c05223a 100644
--- a/src/Math-ODE/ImplicitSolverAnnouncement.class.st
+++ b/src/Math-ODE/PMImplicitSolverAnnouncement.class.st
@@ -3,32 +3,32 @@ An ImplicitSolverAnnouncement is a record of a step in an implicit system. It co
"
Class {
- #name : #ImplicitSolverAnnouncement,
+ #name : #PMImplicitSolverAnnouncement,
#superclass : #Announcement,
#instVars : [
't',
'state'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-ImplicitSolverAnnouncement class >> state: aState time: aTime [
+PMImplicitSolverAnnouncement class >> state: aState time: aTime [
^ self new state: aState time: aTime; yourself.
]
{ #category : #accessing }
-ImplicitSolverAnnouncement >> state [
+PMImplicitSolverAnnouncement >> state [
^ state
]
{ #category : #accessing }
-ImplicitSolverAnnouncement >> state: aState time: aTime [
+PMImplicitSolverAnnouncement >> state: aState time: aTime [
state:= aState.
t := aTime.
]
{ #category : #accessing }
-ImplicitSolverAnnouncement >> time [
+PMImplicitSolverAnnouncement >> time [
^ t
]
diff --git a/src/Math-ODE/ImplicitStepper.class.st b/src/Math-ODE/PMImplicitStepper.class.st
similarity index 83%
rename from src/Math-ODE/ImplicitStepper.class.st
rename to src/Math-ODE/PMImplicitStepper.class.st
index eeb0e8f41..7cd5e2ccd 100644
Binary files a/src/Math-ODE/ImplicitStepper.class.st and b/src/Math-ODE/PMImplicitStepper.class.st differ
diff --git a/src/Math-ODE/ImplicitSystem.class.st b/src/Math-ODE/PMImplicitSystem.class.st
similarity index 75%
rename from src/Math-ODE/ImplicitSystem.class.st
rename to src/Math-ODE/PMImplicitSystem.class.st
index a7b645e50..2f2b85b17 100644
--- a/src/Math-ODE/ImplicitSystem.class.st
+++ b/src/Math-ODE/PMImplicitSystem.class.st
@@ -6,17 +6,17 @@ Implicit routines need not only the function f(x,t) but also the Jacobian df/dx
A is a matrix and implicit routines need to solve the linear problem Ax = b
"
Class {
- #name : #ImplicitSystem,
- #superclass : #ODESystem,
+ #name : #PMImplicitSystem,
+ #superclass : #PMODESystem,
#instVars : [
'jacobian',
'dxdt'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #hooks }
-ImplicitSystem >> jacobianAtX: aState t: aTime [
+PMImplicitSystem >> jacobianAtX: aState t: aTime [
"calculate and store jacobian at this point df/dx"
self shouldBeImplemented
]
diff --git a/src/Math-ODE/MidpointStepper.class.st b/src/Math-ODE/PMMidpointStepper.class.st
similarity index 74%
rename from src/Math-ODE/MidpointStepper.class.st
rename to src/Math-ODE/PMMidpointStepper.class.st
index 6ebb04145..c85b3a31b 100644
--- a/src/Math-ODE/MidpointStepper.class.st
+++ b/src/Math-ODE/PMMidpointStepper.class.st
@@ -3,19 +3,19 @@ The midpoint method is also known as the modified Euler method or RK2. It is an
"
Class {
- #name : #MidpointStepper,
- #superclass : #ExplicitStepper,
- #category : 'Math-ODE'
+ #name : #PMMidpointStepper,
+ #superclass : #PMExplicitStepper,
+ #category : #'Math-ODE'
}
{ #category : #accessing }
-MidpointStepper class >> order [
+PMMidpointStepper class >> order [
"Midpoint is a second order method."
^ 2
]
{ #category : #stepping }
-MidpointStepper >> doStep: aState time: t [
+PMMidpointStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it."
| k1 k2 |
@@ -28,7 +28,7 @@ MidpointStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-MidpointStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
+PMMidpointStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it."
self stepSize: timeStep.
diff --git a/src/Math-ODE/MultiStepper.class.st b/src/Math-ODE/PMMultiStepper.class.st
similarity index 94%
rename from src/Math-ODE/MultiStepper.class.st
rename to src/Math-ODE/PMMultiStepper.class.st
index 7cab3a34a..26e246d04 100644
--- a/src/Math-ODE/MultiStepper.class.st
+++ b/src/Math-ODE/PMMultiStepper.class.st
@@ -8,7 +8,7 @@ The initialization uses a fourth-order Runge-Kutta stepper and after the call of
Many multistep methods are also explicit steppers, hence the parameter of do_step method do not differ from the explicit steppers.
"
Class {
- #name : #MultiStepper,
- #superclass : #Stepper,
- #category : 'Math-ODE'
+ #name : #PMMultiStepper,
+ #superclass : #PMStepper,
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/ODESolver.class.st b/src/Math-ODE/PMODESolver.class.st
similarity index 77%
rename from src/Math-ODE/ODESolver.class.st
rename to src/Math-ODE/PMODESolver.class.st
index 2de07fefd..e5a1cd678 100644
--- a/src/Math-ODE/ODESolver.class.st
+++ b/src/Math-ODE/PMODESolver.class.st
@@ -8,7 +8,7 @@ The main interface once the solver is set up (it has a stepper and a solver) is
Announcements are made when a step is taken.
"
Class {
- #name : #ODESolver,
+ #name : #PMODESolver,
#superclass : #Object,
#instVars : [
'stepper',
@@ -18,59 +18,59 @@ Class {
'lastTime',
'state'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'class variables' }
-ODESolver class >> stepperClass [
+PMODESolver class >> stepperClass [
^ShouldBeImplemented.
]
{ #category : #solving }
-ODESolver >> announceState: aState time: aTime [
+PMODESolver >> announceState: aState time: aTime [
self announcer announce: (self announcementClass state: aState time: aTime)
]
{ #category : #'announcement hooks' }
-ODESolver >> announcementClass [
+PMODESolver >> announcementClass [
^ self subclassResponsibility
]
{ #category : #accessing }
-ODESolver >> announcer [
+PMODESolver >> announcer [
^ announcer
]
{ #category : #accessing }
-ODESolver >> announcer: anAnnouncer [
+PMODESolver >> announcer: anAnnouncer [
announcer := anAnnouncer
]
{ #category : #'announcement hooks' }
-ODESolver >> announcerClass [
+PMODESolver >> announcerClass [
^ self subclassResponsibility
]
{ #category : #accessing }
-ODESolver >> dt [
+PMODESolver >> dt [
^ dt
]
{ #category : #accessing }
-ODESolver >> dt: aFloat [
+PMODESolver >> dt: aFloat [
dt := aFloat
]
{ #category : #initialize }
-ODESolver >> initialize [
+PMODESolver >> initialize [
super initialize.
announcer := self announcerClass new.
]
{ #category : #solving }
-ODESolver >> lastStepState: aState endTime: endTime [
+PMODESolver >> lastStepState: aState endTime: endTime [
"catch partial or full step at end"
(lastTime equalsTo: endTime )
ifFalse:
@@ -84,7 +84,7 @@ ODESolver >> lastStepState: aState endTime: endTime [
]
{ #category : #solving }
-ODESolver >> mainStepsState: aState startTime: initialTime endTime: endTime [
+PMODESolver >> mainStepsState: aState startTime: initialTime endTime: endTime [
state := aState.
"don't go to end time to avoid overrunning"
(initialTime to: endTime - self dt by: self dt) do:
@@ -101,7 +101,7 @@ ODESolver >> mainStepsState: aState startTime: initialTime endTime: endTime [
]
{ #category : #solving }
-ODESolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
+PMODESolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime [
self system: aSystem.
stepper ifNil: [
@@ -132,30 +132,30 @@ ODESolver >> solve: aSystem startState: initialState startTime: initialTime endT
]
{ #category : #solving }
-ODESolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime stepSize: timeStep [
+PMODESolver >> solve: aSystem startState: initialState startTime: initialTime endTime: endTime stepSize: timeStep [
self dt: timeStep.
^ self solve: aSystem startState: initialState startTime: initialTime endTime: endTime.
]
{ #category : #accessing }
-ODESolver >> stepper: aStepper [
+PMODESolver >> stepper: aStepper [
stepper := aStepper.
system notNil ifTrue: [stepper system: system].
]
{ #category : #private }
-ODESolver >> stepperClass [
+PMODESolver >> stepperClass [
^ self class stepperClass
]
{ #category : #accessing }
-ODESolver >> system [
+PMODESolver >> system [
^ system
]
{ #category : #accessing }
-ODESolver >> system: aSystem [
+PMODESolver >> system: aSystem [
system := aSystem.
stepper notNil ifTrue: [stepper system: aSystem].
]
diff --git a/src/Math-ODE/ODESystem.class.st b/src/Math-ODE/PMODESystem.class.st
similarity index 73%
rename from src/Math-ODE/ODESystem.class.st
rename to src/Math-ODE/PMODESystem.class.st
index 1312077f5..2dcba4103 100644
--- a/src/Math-ODE/ODESystem.class.st
+++ b/src/Math-ODE/PMODESystem.class.st
@@ -2,32 +2,32 @@
An ODESystem is a wrapper for a system of or a single ordinary differential equation.
"
Class {
- #name : #ODESystem,
+ #name : #PMODESystem,
#superclass : #Object,
#instVars : [
'block'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-ODESystem class >> block: aBlock [
+PMODESystem class >> block: aBlock [
^ (self new block: aBlock; yourself)
]
{ #category : #accessing }
-ODESystem >> block [
+PMODESystem >> block [
^ block
]
{ #category : #accessing }
-ODESystem >> block: aBlock [
+PMODESystem >> block: aBlock [
"aBlock should be dyadic, the first parameter is x, the second t"
self assert: aBlock argumentCount = 2.
^ block := aBlock
]
{ #category : #evaluation }
-ODESystem >> state: aState time: aTime [
+PMODESystem >> state: aState time: aTime [
^ self block value: aState value: aTime
]
diff --git a/src/Math-ODE/RungeKuttaStepper.class.st b/src/Math-ODE/PMRungeKuttaStepper.class.st
similarity index 82%
rename from src/Math-ODE/RungeKuttaStepper.class.st
rename to src/Math-ODE/PMRungeKuttaStepper.class.st
index ae70b43e5..416fabf1d 100644
--- a/src/Math-ODE/RungeKuttaStepper.class.st
+++ b/src/Math-ODE/PMRungeKuttaStepper.class.st
@@ -4,19 +4,19 @@ A RungeKuttaStepper is a specialization on Explicit Stepper that provides a hige
The RungeKuttaStepper is order 4, the error term is proportional to the step size to the fourth power.
"
Class {
- #name : #RungeKuttaStepper,
- #superclass : #ExplicitStepper,
- #category : 'Math-ODE'
+ #name : #PMRungeKuttaStepper,
+ #superclass : #PMExplicitStepper,
+ #category : #'Math-ODE'
}
{ #category : #accessing }
-RungeKuttaStepper class >> order [
+PMRungeKuttaStepper class >> order [
"RungeKutta is a fourth order method."
^ 4
]
{ #category : #stepping }
-RungeKuttaStepper >> doStep: aState time: t [
+PMRungeKuttaStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it."
| k1 k2 k3 k4 midPoint endPoint |
@@ -32,7 +32,7 @@ RungeKuttaStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-RungeKuttaStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
+PMRungeKuttaStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it."
self stepSize: timeStep.
diff --git a/src/Math-ODE/SimpleSymplecticSystem.class.st b/src/Math-ODE/PMSimpleSymplecticSystem.class.st
similarity index 83%
rename from src/Math-ODE/SimpleSymplecticSystem.class.st
rename to src/Math-ODE/PMSimpleSymplecticSystem.class.st
index 48380d201..aba4b52dd 100644
--- a/src/Math-ODE/SimpleSymplecticSystem.class.st
+++ b/src/Math-ODE/PMSimpleSymplecticSystem.class.st
@@ -11,7 +11,7 @@ As this case is very frequent we introduced a concept where only the nontrivial
"
Class {
- #name : #SimpleSymplecticSystem,
- #superclass : #SymplecticSystem,
- #category : 'Math-ODE'
+ #name : #PMSimpleSymplecticSystem,
+ #superclass : #PMSymplecticSystem,
+ #category : #'Math-ODE'
}
diff --git a/src/Math-ODE/StateRecorder.class.st b/src/Math-ODE/PMStateRecorder.class.st
similarity index 63%
rename from src/Math-ODE/StateRecorder.class.st
rename to src/Math-ODE/PMStateRecorder.class.st
index 50834a98f..58e6bc6db 100644
--- a/src/Math-ODE/StateRecorder.class.st
+++ b/src/Math-ODE/PMStateRecorder.class.st
@@ -4,23 +4,23 @@ A StateRecorder captures each step in an ODESolvers history.
It stores these as a sorted collection of StateTime object, in increasing time order.
"
Class {
- #name : #StateRecorder,
- #superclass : #ExplicitSolverSubscriber,
+ #name : #PMStateRecorder,
+ #superclass : #PMExplicitSolverSubscriber,
#instVars : [
'states'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #example }
-StateRecorder class >> demo [
+PMStateRecorder class >> demo [
"self demo"
| solver system recorder stepper |
- system := ExplicitSystem block: [:x :t | x collect: [:i | t]]. "exact solution x = 0.5 * t squared + x0"
+ system := PMExplicitSystem block: [:x :t | x collect: [:i | t]]. "exact solution x = 0.5 * t squared + x0"
- stepper := RungeKuttaStepper onSystem: system.
- solver := (ExplicitSolver new) stepper: stepper; system: system.
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := (PMExplicitSolver new) stepper: stepper; system: system.
recorder := self forSolver: solver.
"an example of moving backward in time with fractional dt"
@@ -35,23 +35,23 @@ StateRecorder class >> demo [
]
{ #category : #accessing }
-StateRecorder >> add: aState at: aTime [
- states add: (StateTime state: aState time: aTime).
+PMStateRecorder >> add: aState at: aTime [
+ states add: (PMStateTime state: aState time: aTime).
]
{ #category : #accessing }
-StateRecorder >> defaultBlock [
+PMStateRecorder >> defaultBlock [
^ [:ann | self add: ann state at: ann time].
]
{ #category : #'initialize-release' }
-StateRecorder >> initialize [
+PMStateRecorder >> initialize [
super initialize.
states := SortedCollection sortBlock: [:x :y | x time < y time].
^ self
]
{ #category : #accessing }
-StateRecorder >> states [
+PMStateRecorder >> states [
^ states
]
diff --git a/src/Math-ODE/StateTime.class.st b/src/Math-ODE/PMStateTime.class.st
similarity index 76%
rename from src/Math-ODE/StateTime.class.st
rename to src/Math-ODE/PMStateTime.class.st
index 9150ba0a6..5e8fd6684 100644
--- a/src/Math-ODE/StateTime.class.st
+++ b/src/Math-ODE/PMStateTime.class.st
@@ -4,24 +4,24 @@ A StateTime class is a generalization of point. It holds both a state and a time
We don't want to use Point, since state may be a vector quantity, and the behavior of array @ number is a little off (it stores points in an array, what we want is the array itself in state, and the scalar quantity in time).
"
Class {
- #name : #StateTime,
+ #name : #PMStateTime,
#superclass : #Object,
#instVars : [
'state',
'time'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'instance creation' }
-StateTime class >> state: aState time: aTime [
+PMStateTime class >> state: aState time: aTime [
^ self new
state: aState;
time: aTime.
]
{ #category : #printing }
-StateTime >> printOn: aStream [
+PMStateTime >> printOn: aStream [
"used for inspector. Using the point analogy"
state printOn: aStream.
aStream nextPut: $@.
@@ -30,21 +30,21 @@ StateTime >> printOn: aStream [
]
{ #category : #accessing }
-StateTime >> state [
+PMStateTime >> state [
^ state
]
{ #category : #accessing }
-StateTime >> state: anObject [
+PMStateTime >> state: anObject [
state := anObject
]
{ #category : #accessing }
-StateTime >> time [
+PMStateTime >> time [
^ time
]
{ #category : #accessing }
-StateTime >> time: anObject [
+PMStateTime >> time: anObject [
time := anObject
]
diff --git a/src/Math-ODE/Stepper.class.st b/src/Math-ODE/PMStepper.class.st
similarity index 80%
rename from src/Math-ODE/Stepper.class.st
rename to src/Math-ODE/PMStepper.class.st
index 029623456..658af2ca0 100644
--- a/src/Math-ODE/Stepper.class.st
+++ b/src/Math-ODE/PMStepper.class.st
@@ -11,53 +11,53 @@ Before calling doStep, it is important to associate the stepper with a system. T
"
Class {
- #name : #Stepper,
+ #name : #PMStepper,
#superclass : #Object,
#instVars : [
'system',
'dt'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #'instance creation' }
-Stepper class >> onSystem: aSystem [
+PMStepper class >> onSystem: aSystem [
^ self new system: aSystem.
]
{ #category : #accessing }
-Stepper class >> order [
+PMStepper class >> order [
"Answer the order of this stepper, which is undefined by default. Subclasses should override with their details."
^ nil
]
{ #category : #stepping }
-Stepper >> doStep: aState time: t stepSize: dt [
+PMStepper >> doStep: aState time: t stepSize: dt [
"This method should take one step from inState at time t of size dt, then answer it"
self subclassResponsibility
]
{ #category : #accessing }
-Stepper >> order [
+PMStepper >> order [
^ self class order
]
{ #category : #accessing }
-Stepper >> stepSize [
+PMStepper >> stepSize [
^ dt.
]
{ #category : #accessing }
-Stepper >> stepSize: timeStep [
+PMStepper >> stepSize: timeStep [
dt := timeStep.
]
{ #category : #accessing }
-Stepper >> system [
+PMStepper >> system [
^ system
]
{ #category : #accessing }
-Stepper >> system: aSystem [
+PMStepper >> system: aSystem [
system := aSystem.
]
diff --git a/src/Math-ODE/SymplecticSystem.class.st b/src/Math-ODE/PMSymplecticSystem.class.st
similarity index 73%
rename from src/Math-ODE/SymplecticSystem.class.st
rename to src/Math-ODE/PMSymplecticSystem.class.st
index f6fc5d1da..ba07c10a3 100644
--- a/src/Math-ODE/SymplecticSystem.class.st
+++ b/src/Math-ODE/PMSymplecticSystem.class.st
@@ -20,65 +20,65 @@ p'(t) = dV / dq = g(q)
The algorithmic implementation of this situation is described by a pair of callable objects for f and g with a specific parameter signature. Such a system should be implemented as a std::pair of functions or a functors. Symplectic systems are used in symplectic steppers like symplectic_rkn_sb3a_mclachlan.
"
Class {
- #name : #SymplecticSystem,
- #superclass : #ODESystem,
+ #name : #PMSymplecticSystem,
+ #superclass : #PMODESystem,
#instVars : [
'dqdt',
'firstBlock',
'dpdt',
'secondBlock'
],
- #category : 'Math-ODE'
+ #category : #'Math-ODE'
}
{ #category : #accessing }
-SymplecticSystem >> dpdt [
+PMSymplecticSystem >> dpdt [
^ dpdt
]
{ #category : #accessing }
-SymplecticSystem >> dpdt: anObject [
+PMSymplecticSystem >> dpdt: anObject [
dpdt := anObject
]
{ #category : #accessing }
-SymplecticSystem >> dqdt [
+PMSymplecticSystem >> dqdt [
^ dqdt
]
{ #category : #accessing }
-SymplecticSystem >> dqdt: anObject [
+PMSymplecticSystem >> dqdt: anObject [
dqdt := anObject
]
{ #category : #evaluation }
-SymplecticSystem >> first: pState [
+PMSymplecticSystem >> first: pState [
dqdt := firstBlock value: pState.
^ dqdt.
]
{ #category : #accessing }
-SymplecticSystem >> firstBlock [
+PMSymplecticSystem >> firstBlock [
^ firstBlock
]
{ #category : #accessing }
-SymplecticSystem >> firstBlock: anObject [
+PMSymplecticSystem >> firstBlock: anObject [
firstBlock := anObject
]
{ #category : #evaluation }
-SymplecticSystem >> second: qState [
+PMSymplecticSystem >> second: qState [
dpdt := secondBlock value: qState.
^ dpdt.
]
{ #category : #accessing }
-SymplecticSystem >> secondBlock [
+PMSymplecticSystem >> secondBlock [
^ secondBlock
]
{ #category : #accessing }
-SymplecticSystem >> secondBlock: anObject [
+PMSymplecticSystem >> secondBlock: anObject [
secondBlock := anObject
]
diff --git a/src/Math-ODE/TranscriptRecorder.class.st b/src/Math-ODE/PMTranscriptRecorder.class.st
similarity index 73%
rename from src/Math-ODE/TranscriptRecorder.class.st
rename to src/Math-ODE/PMTranscriptRecorder.class.st
index 530b7290a..eda9297a9 100644
--- a/src/Math-ODE/TranscriptRecorder.class.st
+++ b/src/Math-ODE/PMTranscriptRecorder.class.st
@@ -5,13 +5,13 @@ It prints a message to transcript when a step is taken by the solver.
The demo class method shows an example.
"
Class {
- #name : #TranscriptRecorder,
- #superclass : #ExplicitSolverSubscriber,
- #category : 'Math-ODE'
+ #name : #PMTranscriptRecorder,
+ #superclass : #PMExplicitSolverSubscriber,
+ #category : #'Math-ODE'
}
{ #category : #example }
-TranscriptRecorder class >> demo [
+PMTranscriptRecorder class >> demo [
"self demo"
| solver system recorder stepper |
"Transcript openAsMorphLabel: 'TransciptRecorderDemo'."
@@ -20,9 +20,9 @@ Transcript
show: 'TranscriptRecorder demo start';
cr.
-system := ExplicitSystem block: [:x : t | x collect: [:ea | t]].
-stepper := RungeKuttaStepper onSystem: system.
-solver := (ExplicitSolver new) stepper: stepper; system: system.
+system := PMExplicitSystem block: [:x : t | x collect: [:ea | t]].
+stepper := PMRungeKuttaStepper onSystem: system.
+solver := (PMExplicitSolver new) stepper: stepper; system: system.
Transcript show: system block; cr.
recorder := self forSolver: solver.
@@ -35,7 +35,7 @@ Transcript show: 'TranscriptRecorder demo end'; cr
]
{ #category : #accessing }
-TranscriptRecorder >> defaultBlock [
+PMTranscriptRecorder >> defaultBlock [
"this is the default transcript output"
^ [:ann | Transcript show: 'state: ';
show: ann state asString ;
diff --git a/src/Math-ODE/TrapezoidStepper.class.st b/src/Math-ODE/PMTrapezoidStepper.class.st
similarity index 81%
rename from src/Math-ODE/TrapezoidStepper.class.st
rename to src/Math-ODE/PMTrapezoidStepper.class.st
index d061eecdb..caaa426c4 100644
--- a/src/Math-ODE/TrapezoidStepper.class.st
+++ b/src/Math-ODE/PMTrapezoidStepper.class.st
@@ -5,19 +5,19 @@ The trapezoidal rule is an implicit second-order method, which can be considered
"
Class {
- #name : #TrapezoidStepper,
- #superclass : #ImplicitMultiStepper,
- #category : 'Math-ODE'
+ #name : #PMTrapezoidStepper,
+ #superclass : #PMImplicitMultiStepper,
+ #category : #'Math-ODE'
}
{ #category : #'as yet unclassified' }
-TrapezoidStepper class >> order [
+PMTrapezoidStepper class >> order [
"Trapezoid is a second order method."
^ 2
]
{ #category : #stepping }
-TrapezoidStepper >> doStep: aState time: t [
+PMTrapezoidStepper >> doStep: aState time: t [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
| xi1 xi2 ti |
self stepSize isNil
@@ -29,14 +29,14 @@ TrapezoidStepper >> doStep: aState time: t [
]
{ #category : #stepping }
-TrapezoidStepper >> doStep: aState time: t stepSize: timeStep [
+PMTrapezoidStepper >> doStep: aState time: t stepSize: timeStep [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
^ self doStep: aState time: t.
]
{ #category : #stepping }
-TrapezoidStepper >> lastStep: aState time: t deltaT: incrementOfTime [
+PMTrapezoidStepper >> lastStep: aState time: t deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
| xi1 xi2 ti |
self stepSize isNil
@@ -48,7 +48,7 @@ TrapezoidStepper >> lastStep: aState time: t deltaT: incrementOfTime [
]
{ #category : #stepping }
-TrapezoidStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
+PMTrapezoidStepper >> lastStep: aState time: t stepSize: timeStep deltaT: incrementOfTime [
"This method should take one step from inState at time t of size dt, and modify the state, then answer it. "
self stepSize: timeStep.
^ self lastStep: aState time: t deltaT: incrementOfTime.
diff --git a/src/Math-Permutation/ManifestMathPermutation.class.st b/src/Math-Permutation/ManifestMathPermutation.class.st
deleted file mode 100644
index e57bf5550..000000000
--- a/src/Math-Permutation/ManifestMathPermutation.class.st
+++ /dev/null
@@ -1,38 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathPermutation,
- #superclass : #PackageManifest,
- #category : #'Math-Permutation'
-}
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBCollectionProtocolRuleV1FalsePositive [
- ^ #(#(#(#RGMethodDefinition #(#'Permutation class' #generator: #true)) #'2018-07-07T11:52:50.239421+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBModifiesCollectionRuleV1FalsePositive [
- ^ #(#(#(#RGMethodDefinition #(#'Permutation class' #generator: #true)) #'2018-07-07T11:52:46.085547+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBSendsDifferentSuperRuleV1FalsePositive [
- ^ #(#(#(#RGMetaclassDefinition #(#'Permutation class' #PMPermutation)) #'2018-07-07T11:53:26.042043+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBSuperSendsRuleV1FalsePositive [
- ^ #(#(#(#RGMetaclassDefinition #(#'Permutation class' #PMPermutation)) #'2018-07-07T11:53:19.542428+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBTempsReadBeforeWrittenRuleV1FalsePositive [
- ^ #(#(#(#RGMethodDefinition #(#'Permutation class' #stirling1:over: #true)) #'2018-07-07T11:54:16.87423+02:00') )
-]
-
-{ #category : #'code-critics' }
-ManifestMathPermutation class >> ruleRBToDoRuleV1FalsePositive [
- ^ #(#(#(#RGMetaclassDefinition #(#'Permutation class' #PMPermutation)) #'2018-07-07T11:54:04.307575+02:00') )
-]
diff --git a/src/Math-Polynomials/PMPolynomial.class.st b/src/Math-Polynomials/PMPolynomial.class.st
index 495cc48ed..6ce3dafc5 100644
--- a/src/Math-Polynomials/PMPolynomial.class.st
+++ b/src/Math-Polynomials/PMPolynomial.class.st
@@ -222,8 +222,7 @@ PMPolynomial >> printOn: aStream [
n printOn: aStream]]].
n := n + 1].
- "add a quick check, print a zero if the polynomial has all zero coefficients
- Daniel Uber 11 May 2012"
+ "add a quick check, print a zero if the polynomial has all zero coefficients"
firstNonZeroCoefficientPrinted ifFalse: [0 printOn: aStream].
]
diff --git a/src/Math-PrincipalComponentAnalysis/ManifestMathPrincipalComponentAnalysis.class.st b/src/Math-PrincipalComponentAnalysis/ManifestMathPrincipalComponentAnalysis.class.st
deleted file mode 100644
index 95cea5f7c..000000000
--- a/src/Math-PrincipalComponentAnalysis/ManifestMathPrincipalComponentAnalysis.class.st
+++ /dev/null
@@ -1,8 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathPrincipalComponentAnalysis,
- #superclass : #PackageManifest,
- #category : 'Math-PrincipalComponentAnalysis'
-}
diff --git a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st
new file mode 100644
index 000000000..f3e9b4438
--- /dev/null
+++ b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st
@@ -0,0 +1,24 @@
+"
+PMDataTransformer is the abstract root class of transformers. All data transformers should implemen a fit and a method method.
+
+"
+Class {
+ #name : #PMDataTransformer,
+ #superclass : #Object,
+ #category : #'Math-PrincipalComponentAnalysis'
+}
+
+{ #category : #'as yet unclassified' }
+PMDataTransformer >> fit: aPMMatrix [
+ ^ self subclassResponsibility
+]
+
+{ #category : #'as yet unclassified' }
+PMDataTransformer >> fitAndTransform: aPMMatrix [
+ ^ (self fit: aPMMatrix) transform: aPMMatrix
+]
+
+{ #category : #transforming }
+PMDataTransformer >> transform: aPMMatrix [
+ ^ self subclassResponsibility
+]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st
index a20fbe66a..591c1771f 100644
--- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st
+++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st
@@ -1,53 +1,33 @@
-"
-I'm implementing a principle component analysis.
-Clients should first
-- create myself specifying a size which represents the number of elements on which I should be working.
-- accumulate: (give a certain amount of vectors of the elements to compare)
-- then ask for the components
-
-
-"
Class {
#name : #PMPrincipalComponentAnalyser,
#superclass : #Object,
#instVars : [
- 'accumulatorForCovarianceMatrix',
- 'jacobiTransform'
+ 'componentsNumber'
],
- #category : 'Math-PrincipalComponentAnalysis'
+ #category : #'Math-PrincipalComponentAnalysis'
}
-{ #category : #'instance creation' }
-PMPrincipalComponentAnalyser class >> new: anInteger [
- "anInteger is the size of the elements you will accumulate: the elements you want to compare using the component analysis."
- ^ self basicNew initialize: anInteger; yourself.
-]
-
-{ #category : #transformation }
-PMPrincipalComponentAnalyser >> accumulate: aPMVectorOrArray [
- accumulatorForCovarianceMatrix accumulate: aPMVectorOrArray
+{ #category : #accessing }
+PMPrincipalComponentAnalyser >> componentsNumber [
+ ^ componentsNumber
]
{ #category : #accessing }
-PMPrincipalComponentAnalyser >> components [
- "Precondition: accumulate: should have been used."
-
- ^ self jacobiTransform evaluate
+PMPrincipalComponentAnalyser >> componentsNumber: anInteger [
+ componentsNumber := anInteger
]
-{ #category : #initialization }
-PMPrincipalComponentAnalyser >> initialize: anInteger [
- accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: anInteger
+{ #category : #accessing }
+PMPrincipalComponentAnalyser >> fit: aPMMatrix [
+ ^ self subclassResponsibility
]
{ #category : #accessing }
-PMPrincipalComponentAnalyser >> jacobiTransform [
- ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ]
+PMPrincipalComponentAnalyser >> fitAndTransform: aPMMatrix [
+ ^ (self fit: aPMMatrix) transform: aPMMatrix
]
{ #category : #accessing }
-PMPrincipalComponentAnalyser >> transformMatrix [
- "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector"
-
- ^ self jacobiTransform transform
+PMPrincipalComponentAnalyser >> transform: aPMMatrix [
+ ^ self subclassResponsibility
]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st
new file mode 100644
index 000000000..76f96958e
--- /dev/null
+++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st
@@ -0,0 +1,62 @@
+"
+I'm implementing a principle component analysis with Jacobi transformation of the covariante matrix.
+Clients should first
+- create myself specifying a size which represents the number of elements on which I should be working.
+- accumulate: (give a certain amount of vectors of the elements to compare)
+- then ask for the components
+
+
+"
+Class {
+ #name : #PMPrincipalComponentAnalyserJacobiTransformation,
+ #superclass : #PMPrincipalComponentAnalyser,
+ #instVars : [
+ 'accumulatorForCovarianceMatrix',
+ 'jacobiTransform'
+ ],
+ #category : #'Math-PrincipalComponentAnalysis'
+}
+
+{ #category : #'instance creation' }
+PMPrincipalComponentAnalyserJacobiTransformation class >> new: anInteger [
+ "anInteger is the size of the elements you will accumulate: the elements you want to compare using the component analysis."
+ ^ self basicNew initialize: anInteger; yourself.
+]
+
+{ #category : #transformation }
+PMPrincipalComponentAnalyserJacobiTransformation >> accumulate: aPMVectorOrArray [
+ accumulatorForCovarianceMatrix accumulate: aPMVectorOrArray
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserJacobiTransformation >> components [
+ "Precondition: accumulate: should have been used."
+
+ ^ self jacobiTransform evaluate copyFrom: 1 to: componentsNumber
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserJacobiTransformation >> fit: aPMMatrix [
+ accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: aPMMatrix numberOfColumns.
+ aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ].
+ self components
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserJacobiTransformation >> jacobiTransform [
+ ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ]
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserJacobiTransformation >> transform: aPMMatrix [
+ "Apply dimensionality reduction to aPMMatrix"
+
+ ^ aPMMatrix * self transformMatrix transpose
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserJacobiTransformation >> transformMatrix [
+ "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector"
+
+ ^ PMMatrix rows: (self jacobiTransform transform rows copyFrom:1 to: componentsNumber )
+]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st
new file mode 100644
index 000000000..fb1eda853
--- /dev/null
+++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st
@@ -0,0 +1,71 @@
+Class {
+ #name : #PMPrincipalComponentAnalyserSVD,
+ #superclass : #PMPrincipalComponentAnalyser,
+ #instVars : [
+ 'svd',
+ 'u',
+ 'v'
+ ],
+ #category : #'Math-PrincipalComponentAnalysis'
+}
+
+{ #category : #examples }
+PMPrincipalComponentAnalyserSVD class >> example1 [
+
+"Extract 4 columns from original data"
+| d m pca m1 d1 |
+d := (DataFrame loadIris) columnsFrom: 1 to: 4.
+
+"Transform DF as matrix"
+m := PMMatrix rows: (d asArrayOfRows).
+
+"Data standardization (mean = 0 and variance = 1)"
+m := (PMStandardizationScaler new) fitAndTransform: m.
+
+"Compute PCA components"
+pca := PMPrincipalComponentAnalyserSVD new.
+pca componentsNumber: 2.
+pca fit: m.
+pca transformMatrix.
+
+m1 := pca transform: m.
+
+d1 := DataFrame fromRows: m1 rows.
+d1 addColumn: ((DataFrame loadIris) columnsFrom:5 to:5) asArrayOfColumns first named:''.
+d1 scatterplotMatrix.
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [
+ svd := aPMMatrix decompose.
+ u := svd leftSingularForm.
+ v := svd rightSingularForm.
+ self flipEigenvectorsSign
+
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserSVD >> flipEigenvectorsSign [
+ "flip eigenvectors sign to enforce deterministic output"
+ "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609"
+
+ | algo |
+ algo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v.
+
+ u := algo uFlipped .
+ v := algo vFlipped .
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserSVD >> transform: aPMMatrix [
+ "Apply dimensionality reduction to aPMMatrix"
+
+ ^ aPMMatrix * self transformMatrix transpose
+]
+
+{ #category : #accessing }
+PMPrincipalComponentAnalyserSVD >> transformMatrix [
+ "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector"
+
+ ^ PMMatrix rows: (v rows copyFrom: 1 to: componentsNumber)
+]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st
deleted file mode 100644
index 9947132ce..000000000
--- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st
+++ /dev/null
@@ -1,49 +0,0 @@
-Class {
- #name : #PMPrincipalComponentAnalyserTest,
- #superclass : #TestCase,
- #instVars : [
- 'average',
- 'covarianceMatrix',
- 'accumulator',
- 'server'
- ],
- #category : 'Math-PrincipalComponentAnalysis'
-}
-
-{ #category : #initialization }
-PMPrincipalComponentAnalyserTest >> setUp [
- accumulator := PMCovarianceAccumulator new: 5.
- server := PMPrincipalComponentAnalysisServer new.
- 100 timesRepeat: [ accumulator accumulate: server next ].
- average := accumulator average.
- covarianceMatrix := accumulator covarianceMatrix
-]
-
-{ #category : #tests }
-PMPrincipalComponentAnalyserTest >> testCanCreateCovarianceMatrix [
-
- self assert: average asArray equals:{ (101/2) . (-101/2) . (303/2) . -101 . -6767}.
- self assert: covarianceMatrix rows size equals: 5.
- self assert: covarianceMatrix isSymmetric
-]
-
-{ #category : #tests }
-PMPrincipalComponentAnalyserTest >> testEigenvalues [
- | actual expected analyser |
- analyser := PMPrincipalComponentAnalyser new: 5.
- 100 timesRepeat: [ analyser accumulate: server next ].
- actual := analyser components.
- expected := #(3.623277676214216e7 766.1878578405343 -8.608930577556605e-13 2.1213150252733508e-13 -1.9556315119125588e-13) asPMVector.
- (actual - expected) allButFirst allButFirst do: [ :each | self assert: each < 10e-8 ]
-]
-
-{ #category : #tests }
-PMPrincipalComponentAnalyserTest >> testLowEigenvalues [
- "this is a test without using the class API."
-
- | jacobi actual expected |
- jacobi := PMJacobiTransformation matrix: covarianceMatrix.
- actual := jacobi evaluate.
- expected := #(3.623277676214216e7 766.1878578405343 -8.608930577556605e-13 2.1213150252733508e-13 -1.9556315119125588e-13) asPMVector.
- actual - expected do: [ :each | self assert: each < 10e-8 ]
-]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServer.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServer.class.st
deleted file mode 100644
index 8575afb53..000000000
--- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServer.class.st
+++ /dev/null
@@ -1,30 +0,0 @@
-"
-Just a simple server data class for the tests
-"
-Class {
- #name : #PMPrincipalComponentAnalysisServer,
- #superclass : #Object,
- #instVars : [
- 'x',
- 'y'
- ],
- #category : 'Math-PrincipalComponentAnalysis'
-}
-
-{ #category : #initialization }
-PMPrincipalComponentAnalysisServer >> initialize [
- super initialize.
- x := 0.
- y := 0
-]
-
-{ #category : #accessing }
-PMPrincipalComponentAnalysisServer >> next [
- "Return a five elements array"
-
- x := x + 1.
- y := y - 2.
- ^ { x . y + x . x - y . y . x * y}
-
-
-]
diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServerTest.class.st
deleted file mode 100644
index 5db9e19ba..000000000
--- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServerTest.class.st
+++ /dev/null
@@ -1,13 +0,0 @@
-Class {
- #name : #PMPrincipalComponentAnalysisServerTest,
- #superclass : #TestCase,
- #category : 'Math-PrincipalComponentAnalysis'
-}
-
-{ #category : #tests }
-PMPrincipalComponentAnalysisServerTest >> testNext [
- | server |
- server := PMPrincipalComponentAnalysisServer new.
- self assert: server next equals: #(1 -1 3 -2 -2).
- self assert: server next equals: #(2 -2 6 -4 -8)
-]
diff --git a/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st
new file mode 100644
index 000000000..1edaf980a
--- /dev/null
+++ b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st
@@ -0,0 +1,87 @@
+"
+This class uses the SciKit-Learn SVD flip algorithm to ensure the signs of the eigenvectors correlate with the trend of the data.
+ Instance Variables
+ u: PMMatrix
+ v: PMMatrix
+
+"
+Class {
+ #name : #PMSciKitLearnSVDFlipAlgorithm,
+ #superclass : #Object,
+ #instVars : [
+ 'u',
+ 'v',
+ 'signs'
+ ],
+ #category : #'Math-PrincipalComponentAnalysis'
+}
+
+{ #category : #'instance creation' }
+PMSciKitLearnSVDFlipAlgorithm class >> flipU: u andV: v [
+ ^ self new
+ initializeWithU: u andV: v;
+ yourself
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> computeSignsFromU [
+ | maxAbsCols i maxElements |
+ maxAbsCols := u abs argMaxOnColumns.
+ i := 0.
+ maxElements := u transpose
+ rowsCollect: [ :each |
+ i := i + 1.
+ each at: (maxAbsCols at: i) ].
+ ^ maxElements sign asPMVector
+]
+
+{ #category : #initialization }
+PMSciKitLearnSVDFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [
+ "instantiate the algorithm"
+ u := uMatrix .
+ v := vMatrix .
+ signs := self computeSignsFromU .
+
+
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> signMatrixForU [
+ ^ PMMatrix
+ rows:
+ ((1 to: u numberOfRows)
+ inject: OrderedCollection new
+ into: [ :rows :eachRow |
+ rows
+ add: signs;
+ yourself ])
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> signMatrixForV [
+ | signsForV |
+ signsForV := self signs copyFrom: 1 to: v numberOfColumns.
+ ^ (PMMatrix
+ rows:
+ ((1 to: v numberOfRows)
+ inject: OrderedCollection new
+ into: [ :rows :eachRow |
+ rows
+ add: signsForV;
+ yourself ])) transpose
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> signs [
+ ^ signs
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> uFlipped [
+ ^ u hadamardProduct: (self signMatrixForU).
+]
+
+{ #category : #accessing }
+PMSciKitLearnSVDFlipAlgorithm >> vFlipped [
+ ^ v hadamardProduct: (self signMatrixForV) .
+]
diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st
new file mode 100644
index 000000000..78241d614
--- /dev/null
+++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st
@@ -0,0 +1,49 @@
+Class {
+ #name : #PMStandardizationScaler,
+ #superclass : #PMDataTransformer,
+ #instVars : [
+ 'accumulator'
+ ],
+ #category : #'Math-PrincipalComponentAnalysis'
+}
+
+{ #category : #'as yet unclassified' }
+PMStandardizationScaler >> fit: aPMMatrix [
+ "Compute the mean and the scale of a PMMatrix (in order to have a std of 1)"
+
+ accumulator := PMCovarianceAccumulator new: aPMMatrix numberOfColumns.
+ aPMMatrix rowsDo: [ :each | accumulator accumulate: each ]
+]
+
+{ #category : #accessing }
+PMStandardizationScaler >> mean [
+ ^ accumulator average
+]
+
+{ #category : #accessing }
+PMStandardizationScaler >> scale [
+ ^ self variance collect: [ :element |
+ | root |
+ root := element sqrt.
+ (root ~= 0) ifTrue: [ root ] ifFalse: [ 1.0 ]
+ ]
+]
+
+{ #category : #transforming }
+PMStandardizationScaler >> transform: aPMMatrix [
+ "Perform standardization by centering and scaling"
+
+ |mean scale|
+ mean := self mean.
+ scale := self scale.
+ ^ PMMatrix rows: ((PMMatrix rows: (aPMMatrix rowsCollect: [ :each | each - mean ])) rowsCollect: [ :each| each / scale])
+]
+
+{ #category : #information }
+PMStandardizationScaler >> variance [
+ "Return the diagonal of the covarianceMatrix"
+
+ | c |
+ c := accumulator covarianceMatrix.
+ ^ (1 to: c numberOfRows) collect: [ :each | c at: each at: each ]
+]
diff --git a/src/Math-Quaternion/Number.extension.st b/src/Math-Quaternion/Number.extension.st
index d381848d8..494ad387a 100644
--- a/src/Math-Quaternion/Number.extension.st
+++ b/src/Math-Quaternion/Number.extension.st
@@ -8,7 +8,7 @@ Number >> adaptToQuaternion: rcvr andSend: selector [
{ #category : #'*Math-Quaternion' }
Number >> asQuaternion [
- ^Quaternion
+ ^PMQuaternion
qr: self
qi: 0
qj: 0
@@ -17,7 +17,7 @@ Number >> asQuaternion [
{ #category : #'*Math-Quaternion' }
Number >> i: qi j: qj k: qk [
- ^Quaternion
+ ^PMQuaternion
qr: self
qi: qi
qj: qj
@@ -26,7 +26,7 @@ Number >> i: qi j: qj k: qk [
{ #category : #'*Math-Quaternion' }
Number >> j [
- ^Quaternion
+ ^PMQuaternion
qr: 0
qi: 0
qj: self
@@ -35,7 +35,7 @@ Number >> j [
{ #category : #'*Math-Quaternion' }
Number >> k [
- ^Quaternion
+ ^PMQuaternion
qr: 0
qi: 0
qj: 0
diff --git a/src/Math-Quaternion/PMComplex.extension.st b/src/Math-Quaternion/PMComplex.extension.st
index 9ebf0c9c7..ee6eb9ca7 100644
--- a/src/Math-Quaternion/PMComplex.extension.st
+++ b/src/Math-Quaternion/PMComplex.extension.st
@@ -8,7 +8,7 @@ PMComplex >> adaptToQuaternion: rcvr andSend: selector [
{ #category : #'*Math-Quaternion' }
PMComplex >> asQuaternion [
- ^ Quaternion
+ ^ PMQuaternion
qr: real
qi: imaginary
qj: 0
@@ -19,7 +19,7 @@ PMComplex >> asQuaternion [
PMComplex >> j [
"same as self * 1 j"
- ^Quaternion
+ ^PMQuaternion
qr: 0
qi: 0
qj: real
@@ -30,7 +30,7 @@ PMComplex >> j [
PMComplex >> k [
"same as self * 1 k"
- ^Quaternion
+ ^PMQuaternion
qr: 0
qi: 0
qj: imaginary negated
diff --git a/src/Math-Quaternion/Quaternion.class.st b/src/Math-Quaternion/PMQuaternion.class.st
similarity index 83%
rename from src/Math-Quaternion/Quaternion.class.st
rename to src/Math-Quaternion/PMQuaternion.class.st
index 5c226a2e0..4f3d1fee1 100644
--- a/src/Math-Quaternion/Quaternion.class.st
+++ b/src/Math-Quaternion/PMQuaternion.class.st
@@ -26,7 +26,7 @@ Instance Variables:
"
Class {
- #name : #Quaternion,
+ #name : #PMQuaternion,
#superclass : #Object,
#instVars : [
'qr',
@@ -34,11 +34,11 @@ Class {
'qj',
'qk'
],
- #category : 'Math-Quaternion'
+ #category : #'Math-Quaternion'
}
{ #category : #'constants access' }
-Quaternion class >> one [
+PMQuaternion class >> one [
^self
qr: 1
qi: 0
@@ -47,7 +47,7 @@ Quaternion class >> one [
]
{ #category : #'instance creation' }
-Quaternion class >> qr: qr qi: qi qj: qj qk: qk [
+PMQuaternion class >> qr: qr qi: qi qj: qj qk: qk [
^self basicNew
qr: qr
qi: qi
@@ -56,7 +56,7 @@ Quaternion class >> qr: qr qi: qi qj: qj qk: qk [
]
{ #category : #'*Math-Quaternion' }
-Quaternion class >> random [
+PMQuaternion class >> random [
"Answers a random quaternion with abs at most one."
^ (0.5 - Float random)
@@ -66,7 +66,7 @@ Quaternion class >> random [
]
{ #category : #'constants access' }
-Quaternion class >> zero [
+PMQuaternion class >> zero [
^self
qr: 0
qi: 0
@@ -75,7 +75,7 @@ Quaternion class >> zero [
]
{ #category : #arithmetic }
-Quaternion >> * aQuaternion [
+PMQuaternion >> * aQuaternion [
"Answer the result of multiplying self with aQuaternion.
Distribute the product (qr + qi i +qj j + qk k)*(tr+ti i + tj j + tk k)
with rules i*i=j*j=k*k=-1 and i*j=-k, j*k=-i, k*i=-j"
@@ -101,7 +101,7 @@ Quaternion >> * aQuaternion [
]
{ #category : #arithmetic }
-Quaternion >> + aQuaternion [
+PMQuaternion >> + aQuaternion [
^ aQuaternion isQuaternion
ifTrue: [self species
qr: qr + aQuaternion qr
@@ -112,7 +112,7 @@ Quaternion >> + aQuaternion [
]
{ #category : #arithmetic }
-Quaternion >> - aQuaternion [
+PMQuaternion >> - aQuaternion [
^ aQuaternion isQuaternion
ifTrue: [self species
qr: qr - aQuaternion qr
@@ -123,12 +123,12 @@ Quaternion >> - aQuaternion [
]
{ #category : #arithmetic }
-Quaternion >> / aQuaternion [
+PMQuaternion >> / aQuaternion [
^self * aQuaternion reciprocal
]
{ #category : #comparing }
-Quaternion >> = aQuaternion [
+PMQuaternion >> = aQuaternion [
"Answer true if both quaternion are equals.
A quaternion might also equal a Complex or a Number or other kind of numbers.
Implementation note: only work if Complex Octonion or other kind answer true to isNumber."
@@ -143,7 +143,7 @@ Quaternion >> = aQuaternion [
]
{ #category : #arithmetic }
-Quaternion >> abs [
+PMQuaternion >> abs [
"Return the magnitude (or absolute value) of the quaternion.
Care for overflow or underflow"
@@ -160,41 +160,36 @@ Quaternion >> abs [
]
{ #category : #converting }
-Quaternion >> adaptToComplex: rcvr andSend: selector [
+PMQuaternion >> adaptToComplex: rcvr andSend: selector [
"If I am involved in arithmetic with a Complex, convert it to a Quaternion."
^ rcvr asQuaternion perform: selector with: self
]
{ #category : #converting }
-Quaternion >> adaptToFloat: rcvr andSend: selector [
+PMQuaternion >> adaptToFloat: rcvr andSend: selector [
"If I am involved in arithmetic with a Float, convert it to a Quaternion."
^ rcvr asQuaternion perform: selector with: self
]
{ #category : #converting }
-Quaternion >> adaptToFraction: rcvr andSend: selector [
+PMQuaternion >> adaptToFraction: rcvr andSend: selector [
"If I am involved in arithmetic with a Fraction, convert it to a Quaternion."
^ rcvr asQuaternion perform: selector with: self
]
{ #category : #converting }
-Quaternion >> adaptToInteger: rcvr andSend: selector [
+PMQuaternion >> adaptToInteger: rcvr andSend: selector [
"If I am involved in arithmetic with an Integer, convert it to a Quaternion."
^ rcvr asQuaternion perform: selector with: self
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> addPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99
-
- added to Quaternion 11 May 2012 Daniel Uber
- "
+PMQuaternion >> addPolynomial: aPolynomial [
^aPolynomial addNumber: self
]
{ #category : #accessing }
-Quaternion >> angle [
+PMQuaternion >> angle [
"answer the rotation angle associated with the receiver"
| sinThetaSur2 cosThetaSur2 |
@@ -204,14 +199,14 @@ Quaternion >> angle [
]
{ #category : #accessing }
-Quaternion >> angleInDegrees [
+PMQuaternion >> angleInDegrees [
"answer the rotation angle in degrees associated with the receiver"
^self angle radiansToDegrees
]
{ #category : #converting }
-Quaternion >> asQuaternion [
+PMQuaternion >> asQuaternion [
"Convert the receiver into a quaternion.
Do nothing, i am already a quaternion"
@@ -219,7 +214,7 @@ Quaternion >> asQuaternion [
]
{ #category : #arithmetic }
-Quaternion >> conjugated [
+PMQuaternion >> conjugated [
"Return the conjugate of this quaternion number."
^self species
@@ -230,7 +225,7 @@ Quaternion >> conjugated [
]
{ #category : #'mathematical functions' }
-Quaternion >> cos [
+PMQuaternion >> cos [
"Answer the receiver cosine"
| z w |
@@ -246,21 +241,19 @@ Quaternion >> cos [
]
{ #category : #'mathematical functions' }
-Quaternion >> cosh [
+PMQuaternion >> cosh [
"Answer the receiver hyperbolic cosine"
^(self exp + self negated exp) / 2
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> dividingPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99 "
+PMQuaternion >> dividingPolynomial: aPolynomial [
^aPolynomial timesNumber: (1 / self)
]
{ #category : #'mathematical functions' }
-Quaternion >> exp [
+PMQuaternion >> exp [
"Answer the receiver exponential"
| z w |
@@ -276,7 +269,7 @@ Quaternion >> exp [
]
{ #category : #private }
-Quaternion >> floatClass [
+PMQuaternion >> floatClass [
"Answer the class suitable for doing floating point operations.
In default Squeak, this is Float.
In an image with single and double IEEE 754 floating point numbers,
@@ -286,12 +279,12 @@ Quaternion >> floatClass [
]
{ #category : #comparing }
-Quaternion >> hash [
+PMQuaternion >> hash [
^(((qi hash bitXor: qj hash) bitXor: qk hash) bitXor: qr hash)
]
{ #category : #converting }
-Quaternion >> i [
+PMQuaternion >> i [
"Answer the product of the receiver with pure imaginary i.
This is the same as self * 1 i"
@@ -303,7 +296,7 @@ Quaternion >> i [
]
{ #category : #testing }
-Quaternion >> isNumber [
+PMQuaternion >> isNumber [
"Answer true just like Complex, our unreal part is just a bit more complex.
Note that this message is needed to make equality tests pass due to Number>>= implementation."
@@ -311,21 +304,21 @@ Quaternion >> isNumber [
]
{ #category : #testing }
-Quaternion >> isQuaternion [
+PMQuaternion >> isQuaternion [
"always answer true since the receiver is a quaternion"
^true
]
{ #category : #testing }
-Quaternion >> isZero [
+PMQuaternion >> isZero [
"answer true if the receiver is null, false otherwise"
^qr isZero and: [qi isZero and: [qj isZero and: [qk isZero]]]
]
{ #category : #converting }
-Quaternion >> j [
+PMQuaternion >> j [
"Answer the product of the receiver with pure imaginary j.
This is the same as self * 1 j"
@@ -338,7 +331,7 @@ Quaternion >> j [
]
{ #category : #converting }
-Quaternion >> k [
+PMQuaternion >> k [
"Answer the product of the receiver with pure imaginary k.
This is the same as self * 1 k"
@@ -351,7 +344,7 @@ Quaternion >> k [
]
{ #category : #'mathematical functions' }
-Quaternion >> ln [
+PMQuaternion >> ln [
"Answer the receiver natural logarithm"
| z |
@@ -374,14 +367,14 @@ Quaternion >> ln [
]
{ #category : #'mathematical functions' }
-Quaternion >> log [
+PMQuaternion >> log [
"Answer receiver base 10 logarithm."
^self ln / 10 ln
]
{ #category : #arithmetic }
-Quaternion >> negated [
+PMQuaternion >> negated [
^self species
qr: qr negated
qi: qi negated
@@ -390,42 +383,40 @@ Quaternion >> negated [
]
{ #category : #printing }
-Quaternion >> printOn: aStream [
+PMQuaternion >> printOn: aStream [
"Print a representation of the receiver onto aStream"
self storeOn: aStream
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> productWithVector: aVector [
- "Answers a new vector product of the receiver with aVector.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
+PMQuaternion >> productWithVector: aVector [
+ "Answers a new vector product of the receiver with aVector."
^aVector collect: [ :each | each * self]
]
{ #category : #accessing }
-Quaternion >> qi [
+PMQuaternion >> qi [
^qi
]
{ #category : #accessing }
-Quaternion >> qj [
+PMQuaternion >> qj [
^qj
]
{ #category : #accessing }
-Quaternion >> qk [
+PMQuaternion >> qk [
^qk
]
{ #category : #accessing }
-Quaternion >> qr [
+PMQuaternion >> qr [
^qr
]
{ #category : #private }
-Quaternion >> qr: a0 qi: a1 qj: a2 qk: a3 [
+PMQuaternion >> qr: a0 qi: a1 qj: a2 qk: a3 [
qr := a0.
qi := a1.
qj := a2.
@@ -433,7 +424,7 @@ Quaternion >> qr: a0 qi: a1 qj: a2 qk: a3 [
]
{ #category : #'mathematical functions' }
-Quaternion >> raisedTo: aNumber [
+PMQuaternion >> raisedTo: aNumber [
"Answer the receiver raised to aNumber."
aNumber isInteger ifTrue:
@@ -450,7 +441,7 @@ Quaternion >> raisedTo: aNumber [
]
{ #category : #'mathematical functions' }
-Quaternion >> raisedToInteger: operand [
+PMQuaternion >> raisedToInteger: operand [
"Answer the receiver raised to the power operand, an Integer."
"implementation note: this code is copied from Number.
@@ -475,20 +466,20 @@ Quaternion >> raisedToInteger: operand [
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> random [
+PMQuaternion >> random [
"analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
^ self class random * self.
]
{ #category : #accessing }
-Quaternion >> real [
+PMQuaternion >> real [
"answer the real part of the receiver"
^qr
]
{ #category : #arithmetic }
-Quaternion >> reciprocal [
+PMQuaternion >> reciprocal [
"Trivial algorithm:
^self conjugated / self squaredNorm
may overflow"
@@ -507,7 +498,7 @@ Quaternion >> reciprocal [
]
{ #category : #converting }
-Quaternion >> reduce [
+PMQuaternion >> reduce [
"Answer the receiver transformed to a lower generality, if
such a transformation is possible without losing information.
If not, answer the receiver"
@@ -519,7 +510,7 @@ Quaternion >> reduce [
]
{ #category : #'mathematical functions' }
-Quaternion >> sin [
+PMQuaternion >> sin [
"Answer the receiver sine"
| z w |
@@ -535,24 +526,24 @@ Quaternion >> sin [
]
{ #category : #'mathematical functions' }
-Quaternion >> sinh [
+PMQuaternion >> sinh [
"Answer the receiver hyperbolic sine"
^(self exp - self negated exp) / 2
]
{ #category : #'mathematical functions' }
-Quaternion >> squared [
+PMQuaternion >> squared [
^self * self
]
{ #category : #arithmetic }
-Quaternion >> squaredNorm [
+PMQuaternion >> squaredNorm [
^qr squared + qi squared + qj squared + qk squared
]
{ #category : #printing }
-Quaternion >> storeOn: aStream [
+PMQuaternion >> storeOn: aStream [
"Store a representation of the receiver onto aStream that can be interpreted.
Two possible forms are:
a + b i + c j + d k
@@ -580,21 +571,19 @@ Quaternion >> storeOn: aStream [
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> subtractToPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99 "
+PMQuaternion >> subtractToPolynomial: aPolynomial [
^aPolynomial addNumber: self negated
]
{ #category : #'mathematical functions' }
-Quaternion >> tan [
+PMQuaternion >> tan [
"Answer the receiver tangent"
^self sin / self cos
]
{ #category : #'mathematical functions' }
-Quaternion >> tanh [
+PMQuaternion >> tanh [
"Answer the hyperbolic tangent"
| ep em |
@@ -604,16 +593,12 @@ Quaternion >> tanh [
]
{ #category : #'*Math-Quaternion' }
-Quaternion >> timesPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99
- added to Complex class 12 May 2012, Daniel Uber
- "
+PMQuaternion >> timesPolynomial: aPolynomial [
^aPolynomial timesNumber: self
]
{ #category : #accessing }
-Quaternion >> unreal [
+PMQuaternion >> unreal [
"answer the unreal part of the receiver"
^self species
diff --git a/src/Math-Quaternion/PMQuaternion.extension.st b/src/Math-Quaternion/PMQuaternion.extension.st
new file mode 100644
index 000000000..8c26825d1
--- /dev/null
+++ b/src/Math-Quaternion/PMQuaternion.extension.st
@@ -0,0 +1,43 @@
+Extension { #name : #PMQuaternion }
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> addPolynomial: aPolynomial [
+ ^aPolynomial addNumber: self
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> dividingPolynomial: aPolynomial [
+ ^aPolynomial timesNumber: (1 / self)
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> productWithVector: aVector [
+ "Answers a new vector product of the receiver with aVector."
+ ^aVector collect: [ :each | each * self]
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion class >> random [
+ "Answers a random quaternion with abs at most one."
+
+ ^ (0.5 - Float random)
+ i: (0.5 - Float random)
+ j: (0.5 - Float random)
+ k: (0.5 - Float random).
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> random [
+ "analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
+ ^ self class random * self.
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> subtractToPolynomial: aPolynomial [
+ ^aPolynomial addNumber: self negated
+]
+
+{ #category : #'*Math-Quaternion' }
+PMQuaternion >> timesPolynomial: aPolynomial [
+ ^aPolynomial timesNumber: self
+]
diff --git a/src/Math-Quaternion/Quaternion.extension.st b/src/Math-Quaternion/Quaternion.extension.st
deleted file mode 100644
index 5a6d05c6c..000000000
--- a/src/Math-Quaternion/Quaternion.extension.st
+++ /dev/null
@@ -1,58 +0,0 @@
-Extension { #name : #Quaternion }
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> addPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99
-
- added to Quaternion 11 May 2012 Daniel Uber
- "
- ^aPolynomial addNumber: self
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> dividingPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99 "
- ^aPolynomial timesNumber: (1 / self)
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> productWithVector: aVector [
- "Answers a new vector product of the receiver with aVector.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 11/2/99 "
- ^aVector collect: [ :each | each * self]
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> random [
- "analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
- ^ self class random * self.
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion class >> random [
- "Answers a random quaternion with abs at most one."
-
- ^ (0.5 - Float random)
- i: (0.5 - Float random)
- j: (0.5 - Float random)
- k: (0.5 - Float random).
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> subtractToPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 19/4/99 "
- ^aPolynomial addNumber: self negated
-]
-
-{ #category : #'*Math-Quaternion' }
-Quaternion >> timesPolynomial: aPolynomial [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/4/99
- added to Complex class 12 May 2012, Daniel Uber
- "
- ^aPolynomial timesNumber: self
-]
diff --git a/src/Math-Random/ManifestMathRandom.class.st b/src/Math-Random/ManifestMathRandom.class.st
deleted file mode 100644
index b328d7cc0..000000000
--- a/src/Math-Random/ManifestMathRandom.class.st
+++ /dev/null
@@ -1,8 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathRandom,
- #superclass : #PackageManifest,
- #category : 'Math-Random'
-}
diff --git a/src/Math-Random/PMBernoulliGenerator.class.st b/src/Math-Random/PMBernoulliGenerator.class.st
index 2fed1918f..2ca8a0c9e 100644
--- a/src/Math-Random/PMBernoulliGenerator.class.st
+++ b/src/Math-Random/PMBernoulliGenerator.class.st
@@ -1,5 +1,5 @@
"
-A BernoulliGenerator is simulates a Bernoulli Process. This is a discrete process, with probability of p for success, and 1-p for failure.
+A PMBernoulliGenerator is simulates a Bernoulli Process. This is a discrete process, with probability of p for success, and 1-p for failure.
next
answer 1 if success event, 0 otherwise
@@ -24,7 +24,7 @@ Class {
#instVars : [
'probability'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
diff --git a/src/Math-Random/PMBinomialGenerator.class.st b/src/Math-Random/PMBinomialGenerator.class.st
index c2a8e6a53..7bead9d2d 100644
--- a/src/Math-Random/PMBinomialGenerator.class.st
+++ b/src/Math-Random/PMBinomialGenerator.class.st
@@ -1,5 +1,5 @@
"
-A BinomialGenerator yields results from a binomial distribution with probability p and n trials. The generator is the underlying random source.
+A PMBinomialGenerator yields results from a binomial distribution with probability p and n trials. The generator is the underlying random source.
If each independent event has probability 0> numberOfTrials: numberOfTrials probabilityOfSuccess
yourself
]
+{ #category : #accessing }
+PMBinomialGenerator >> expectedValue [
+ ^ numberOfTrials * probability
+]
+
{ #category : #initialization }
PMBinomialGenerator >> initialize [
self generator: PMParkMillerMinimumRandomGenerator new.
diff --git a/src/Math-Random/PMConstantGenerator.class.st b/src/Math-Random/PMConstantGenerator.class.st
index 8cb495092..5c004c49b 100644
--- a/src/Math-Random/PMConstantGenerator.class.st
+++ b/src/Math-Random/PMConstantGenerator.class.st
@@ -1,5 +1,5 @@
"
-A ConstantGenerator is still a number generator but a simple one :)
+A PMConstantGenerator is still a number generator but a simple one :)
"
Class {
#name : #PMConstantGenerator,
@@ -7,7 +7,7 @@ Class {
#instVars : [
'constant'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance-creation' }
diff --git a/src/Math-Random/PMExplicitInverseCongruentialRandomGenerator.class.st b/src/Math-Random/PMExplicitInverseCongruentialRandomGenerator.class.st
index dbc5c6966..0345cda3d 100644
--- a/src/Math-Random/PMExplicitInverseCongruentialRandomGenerator.class.st
+++ b/src/Math-Random/PMExplicitInverseCongruentialRandomGenerator.class.st
@@ -1,5 +1,5 @@
"
-An ExplicitInverseCongruentialGenerator is an explicit inversive congruential generator, constructed according to ""Good random number generators are (not so) easy to find"" by P. Hellekalek (1998) and extended euclidean algorithm.
+A PMExplicitInverseCongruentialGenerator is an explicit inversive congruential generator, constructed according to ""Good random number generators are (not so) easy to find"" by P. Hellekalek (1998) and extended euclidean algorithm.
Developed by Konstantin Nizheradze
Instance Variables
@@ -11,10 +11,10 @@ nextN
- next number of the sequence of random numbers. It is also the parameter at extended euclidean algorythm
nextValue
- - next modulo inverse value, calculated by extended euclidean algorythm
+ - next modulo inverse value, calculated by extended euclidean algorithm
p
- - parameter at extended euclidean algorythm
+ - parameter at extended euclidean algorithm
"
Class {
@@ -26,7 +26,7 @@ Class {
'nextValue',
'nextModInv'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #initialization }
diff --git a/src/Math-Random/PMExponentialGenerator.class.st b/src/Math-Random/PMExponentialGenerator.class.st
index 98936f8b1..f20112889 100644
--- a/src/Math-Random/PMExponentialGenerator.class.st
+++ b/src/Math-Random/PMExponentialGenerator.class.st
@@ -1,5 +1,5 @@
"
-An ExponentialGenerator uses a uniform random variable in [0,1] to sample from an exponential distribution.
+A PMExponentialGenerator uses a uniform random variable in [0,1] to sample from an exponential distribution.
The exponential distribution has a single parameter beta, here denoted as mean.
@@ -19,7 +19,7 @@ Class {
#instVars : [
'mean'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
@@ -35,6 +35,13 @@ PMExponentialGenerator class >> new [
^ self mean: 1
]
+{ #category : #accessing }
+PMExponentialGenerator >> expectedValue [
+ "Returns the mean/expectation value"
+ ^ mean
+
+]
+
{ #category : #accessing }
PMExponentialGenerator >> mean [
^ mean
diff --git a/src/Math-Random/PMGaussianGenerator.class.st b/src/Math-Random/PMGaussianGenerator.class.st
index b9559acd1..41e7e148b 100644
--- a/src/Math-Random/PMGaussianGenerator.class.st
+++ b/src/Math-Random/PMGaussianGenerator.class.st
@@ -1,5 +1,5 @@
"
-A GaussianGenerator uses a Normal Distribution.
+A PMGaussianGenerator uses a Normal Distribution.
"
Class {
@@ -10,7 +10,7 @@ Class {
'standardDeviation',
'nextGaussian'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #testing }
diff --git a/src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st b/src/Math-Random/PMLaplaceGenerator.class.st
similarity index 95%
rename from src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st
rename to src/Math-Random/PMLaplaceGenerator.class.st
index 1b5c0bfe6..738e7634f 100644
--- a/src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st
+++ b/src/Math-Random/PMLaplaceGenerator.class.st
@@ -11,7 +11,7 @@ Class {
'laplaceDistribution',
'next'
],
- #category : 'Math-RandomDistributionBased'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
diff --git a/src/Math-Random/PMLehmerRandomGenerator.class.st b/src/Math-Random/PMLehmerRandomGenerator.class.st
index e6b2a47f7..3dc1ba7a6 100644
--- a/src/Math-Random/PMLehmerRandomGenerator.class.st
+++ b/src/Math-Random/PMLehmerRandomGenerator.class.st
@@ -1,12 +1,12 @@
"
This generator uses the Lehmer's Linear Congruential method.
-LehmerRandom new next
+PMLehmerRandomGenerator new next
"
Class {
#name : #PMLehmerRandomGenerator,
- #superclass : #PMRandomGenerator,
- #category : 'Math-Random'
+ #superclass : #PMPseudoRandomNumberGenerator,
+ #category : #'Math-Random'
}
{ #category : #'stream access' }
diff --git a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st
index a39fd0a3e..1ad21e0f9 100644
--- a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st
+++ b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st
@@ -1,15 +1,15 @@
"
I use a quick and dirty Linear Congruential generator.
-LCRandom new next.
+PMLinearCongruentialRandomGenerator new next.
"
Class {
#name : #PMLinearCongruentialRandomGenerator,
- #superclass : #PMRandomGenerator,
- #category : 'Math-Random'
+ #superclass : #PMPseudoRandomNumberGenerator,
+ #category : #'Math-Random'
}
-{ #category : #accessing }
+{ #category : #'stream access' }
PMLinearCongruentialRandomGenerator >> next [
"Answer a pseudo-Random floating point number between 0 and 1. Uses a quick and dirty Linear congruential generator"
@@ -24,7 +24,7 @@ PMLinearCongruentialRandomGenerator >> nextFloat [
^ seed / 120050.0
]
-{ #category : #accessing }
+{ #category : #'stream access' }
PMLinearCongruentialRandomGenerator >> peek [
"Answer a pseudo-Random floating point number between 0 and 1. Uses a simple, but fast, Linear Congruential generator."
diff --git a/src/Math-Random/PMMarsagliaKissRandom.class.st b/src/Math-Random/PMMarsagliaKissRandomGenerator.class.st
similarity index 65%
rename from src/Math-Random/PMMarsagliaKissRandom.class.st
rename to src/Math-Random/PMMarsagliaKissRandomGenerator.class.st
index 33b08b6a2..1660910c9 100644
--- a/src/Math-Random/PMMarsagliaKissRandom.class.st
+++ b/src/Math-Random/PMMarsagliaKissRandomGenerator.class.st
@@ -1,39 +1,39 @@
"
-A MarsagliaKissRandom is a pseudo-random number generator (PRNG) using Marsaglia's Keep it Simple Stupid algorithm.
+A PMMarsagliaKissRandom is a pseudo-random number generator (PRNG) using Marsaglia's Keep it Simple Stupid algorithm.
It generates Float with uniform distribution in Interval [0,1).
The result divided by 1.0 predecessor will be in [0,1].
Instance Variables
- kernelRand1: a first generator
- kernelRand2: a second generator
+ kernelRand1: a first generator
+ kernelRand2: a second generator
"
Class {
- #name : #PMMarsagliaKissRandom,
- #superclass : #PMRandomGenerator,
+ #name : #PMMarsagliaKissRandomGenerator,
+ #superclass : #PMPseudoRandomNumberGenerator,
#instVars : [
'kernelRand1',
'kernelRand2'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
-PMMarsagliaKissRandom class >> default [
+PMMarsagliaKissRandomGenerator class >> default [
^self seed: #(
123456789 362436069 521288629 316191069
987654321 458629013 582859209 438195021)
]
{ #category : #'instance creation' }
-PMMarsagliaKissRandom class >> new [
+PMMarsagliaKissRandomGenerator class >> new [
^ self seed: (PMMarsagliaKissRandomKernel new next: 8)
]
{ #category : #'stream access' }
-PMMarsagliaKissRandom >> next [
+PMMarsagliaKissRandomGenerator >> next [
"Answer a Float in interval [0.0,1.0) with uniform distribution.
Note that constant 16rFFFFF800 is computed so as to truncate the 64 bits to Float precision.
It is thus ((1 << 32 - 1 << (64 - Float precision) bitAnd: 1 << 32 - 1)) hex"
@@ -42,23 +42,23 @@ PMMarsagliaKissRandom >> next [
]
{ #category : #'stream access' }
-PMMarsagliaKissRandom >> peek [
+PMMarsagliaKissRandomGenerator >> peek [
^self copy next
]
{ #category : #copying }
-PMMarsagliaKissRandom >> postCopy [
+PMMarsagliaKissRandomGenerator >> postCopy [
kernelRand1 := kernelRand1 copy.
kernelRand2 := kernelRand2 copy
]
{ #category : #accessing }
-PMMarsagliaKissRandom >> seed [
+PMMarsagliaKissRandomGenerator >> seed [
^ kernelRand1 seed , kernelRand2 seed
]
{ #category : #accessing }
-PMMarsagliaKissRandom >> seed: aWordArray [
+PMMarsagliaKissRandomGenerator >> seed: aWordArray [
"Initialize with an Array of eight 32-bits Integer"
kernelRand1 := PMMarsagliaKissRandomKernel seed: (aWordArray first: 4).
kernelRand2 := PMMarsagliaKissRandomKernel seed: (aWordArray last: 4)
diff --git a/src/Math-Random/PMMarsagliaKissRandomKernel.class.st b/src/Math-Random/PMMarsagliaKissRandomKernel.class.st
index 03a8d54d4..2c94b1338 100644
--- a/src/Math-Random/PMMarsagliaKissRandomKernel.class.st
+++ b/src/Math-Random/PMMarsagliaKissRandomKernel.class.st
@@ -1,5 +1,5 @@
"
-A MarsagliaKissRandomKernel is a private class for generating pseudo-Random numbers.
+A PMMarsagliaKissRandomKernel is a private class for generating pseudo-Random numbers.
It generates 32-bits Integer with uniform distribution in Interval [ 0,16rFFFFFFFF].
@@ -37,7 +37,7 @@ Class {
'w',
'z'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
diff --git a/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st b/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st
index 616aa72fb..5a3906bd0 100644
--- a/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st
+++ b/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st
@@ -11,7 +11,7 @@ MersenneTwisterRandom new nextInteger.
"
Class {
#name : #PMMersenneTwisterRandomGenerator,
- #superclass : #PMRandomGenerator,
+ #superclass : #PMPseudoRandomNumberGenerator,
#instVars : [
'states',
'mti'
@@ -26,7 +26,7 @@ Class {
'TemperingMaskB',
'TemperingMaskC'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'class initialization' }
@@ -110,35 +110,37 @@ PMMersenneTwisterRandomGenerator >> nextInteger [
| tempArray y |
tempArray := Array withAll: #(0 16r9908B0DF).
mti >= DefaultLengthVector
- ifTrue: [
- mti = (DefaultLengthVector + 1)
- ifTrue: [
- self seed: 5489.
+ ifTrue: [ mti = (DefaultLengthVector + 1)
+ ifTrue: [ self seed: 5489.
self initialize ].
1 to: DefaultLengthVector - PeriodParameter do: [ :kk |
- y := ((states at: kk) bitAnd: Mt19937UpperMask) bitOr: ((states at: kk + 1) bitAnd: Mt19937LowerMask).
+ y := ((states at: kk) bitAnd: Mt19937UpperMask)
+ bitOr: ((states at: kk + 1) bitAnd: Mt19937LowerMask).
states
at: kk
put:
- (((states at: kk + PeriodParameter) bitXor: (y bitShift: 1 negated)) bitXor: (tempArray at: (y bitAnd: 16r1) + 1)) ].
- DefaultLengthVector - PeriodParameter + 1 to: DefaultLengthVector - 2 do: [ :kk |
- y := ((states at: kk) bitAnd: Mt19937UpperMask) bitOr: ((states at: kk + 1) bitAnd: Mt19937LowerMask).
+ (((states at: kk + PeriodParameter) bitXor: (y bitShift: 1 negated))
+ bitXor: (tempArray at: (y bitAnd: 1) + 1)) ].
+ DefaultLengthVector - PeriodParameter + 1 to: DefaultLengthVector - 2
+ do: [ :kk |
+ y := ((states at: kk) bitAnd: Mt19937UpperMask)
+ bitOr: ((states at: kk + 1) bitAnd: Mt19937LowerMask).
states
at: kk
put:
- (((states at: kk + PeriodParameter - DefaultLengthVector + 1) bitXor: (y bitShift: 1 negated))
- bitXor: (tempArray at: (y bitAnd: 16r1) + 1)) ].
- y := ((states at: DefaultLengthVector) bitAnd: Mt19937UpperMask) bitOr: ((states at: 1) bitAnd: Mt19937LowerMask).
+ (((states at: kk + PeriodParameter - DefaultLengthVector + 1)
+ bitXor: (y bitShift: 1 negated))
+ bitXor: (tempArray at: (y bitAnd: 1) + 1)) ].
+ y := ((states at: DefaultLengthVector) bitAnd: Mt19937UpperMask)
+ bitOr: ((states at: 1) bitAnd: Mt19937LowerMask).
states
at: DefaultLengthVector
- put: ((states at: PeriodParameter) bitXor: ((y bitShift: 1) bitXor: (tempArray at: (y bitAnd: 16r1) + 1))).
+ put:
+ ((states at: PeriodParameter)
+ bitXor: ((y bitShift: 1) bitXor: (tempArray at: (y bitAnd: 1) + 1))).
mti := 0 ].
- y := states at: mti + 1.
+ y := self temperAt: mti + 1.
mti := mti + 1.
- y := y bitXor: (y bitShift: 11 negated).
- y := y bitXor: ((y bitShift: 7 negated) bitAnd: TemperingMaskB).
- y := y bitXor: ((y bitShift: 15 negated) bitAnd: TemperingMaskC).
- y := y bitXor: (y bitShift: 18 negated).
^ y
]
@@ -149,3 +151,14 @@ PMMersenneTwisterRandomGenerator >> peek [
^ self copy next
]
+
+{ #category : #private }
+PMMersenneTwisterRandomGenerator >> temperAt: position [
+ | y |
+ y := states at: position.
+ y := y bitXor: (y bitShift: 11 negated).
+ y := y bitXor: ((y bitShift: 7 negated) bitAnd: TemperingMaskB).
+ y := y bitXor: ((y bitShift: 15 negated) bitAnd: TemperingMaskC).
+ y := y bitXor: (y bitShift: 18 negated).
+ ^ y
+]
diff --git a/src/Math-Random/PMNumberGenerator.class.st b/src/Math-Random/PMNumberGenerator.class.st
index b53285069..9352d64fe 100644
--- a/src/Math-Random/PMNumberGenerator.class.st
+++ b/src/Math-Random/PMNumberGenerator.class.st
@@ -1,5 +1,5 @@
"
-A NumberGenerator is a stream of numbers. All NumberGenerators respond to #next.
+A PMNumberGenerator is a stream of numbers. All NumberGenerators respond to #next.
As generator I use a PMRandomGenerator instance as defined by the class message defaultGeneratorClass.
My API is
@@ -17,7 +17,7 @@ Class {
#instVars : [
'randomNumberGenerator'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #factory }
diff --git a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st
index db887ccf6..429b57b8f 100644
--- a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st
+++ b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st
@@ -1,15 +1,15 @@
"
Uses Park and Miller's 'Minimum Standard' Congruential generator. See 'Numerical Recipes in C', 2nd Edition; Press, Flannery, Teukolsky and Vetterling; Cambridge University Press, 1992.
-PMRandom new next
+PMParkMillerMinimumRandomGenerator new next
"
Class {
#name : #PMParkMillerMinimumRandomGenerator,
- #superclass : #PMRandomGenerator,
- #category : 'Math-Random'
+ #superclass : #PMPseudoRandomNumberGenerator,
+ #category : #'Math-Random'
}
-{ #category : #accessing }
+{ #category : #'stream access' }
PMParkMillerMinimumRandomGenerator >> next [
"Answer a pseudo-Random floating point number between 0 and 1.
Uses Park and Miller's 'Minimum Standard' congruential generator
@@ -30,7 +30,7 @@ PMParkMillerMinimumRandomGenerator >> nextFloat [
^ seed / 16r7FFFFFFF asFloat
]
-{ #category : #accessing }
+{ #category : #'stream access' }
PMParkMillerMinimumRandomGenerator >> peek [
"Answer a pseudo-Random floating point number between 0 and 1.
Uses Park and Miller's 'Minimum Standard' congruential generator."
diff --git a/src/Math-Random/PMPoissonGenerator.class.st b/src/Math-Random/PMPoissonGenerator.class.st
index 554bf6dbe..6ab07568f 100644
--- a/src/Math-Random/PMPoissonGenerator.class.st
+++ b/src/Math-Random/PMPoissonGenerator.class.st
@@ -1,5 +1,5 @@
"
-A PoissonGeneratorsimulates a Poisson Process with parameter lambda.
+A PMPoissonGenerator simulates a Poisson Process with parameter lambda.
This class is implemented to yield an integer result, corresponding to the number of events in n intervals, with probabilility of an event in each individual interval of p. The parameter lambda is the product of n and p.
"
@@ -9,7 +9,7 @@ Class {
#instVars : [
'lambda'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #'instance creation' }
@@ -25,6 +25,12 @@ PMPoissonGenerator class >> new [
^ self lambda: 1
]
+{ #category : #accessing }
+PMPoissonGenerator >> expectedValue [
+ "Returns the expected value or mean of the distribution"
+ ^ self lambda
+]
+
{ #category : #accessing }
PMPoissonGenerator >> lambda [
^ lambda
diff --git a/src/Math-Random/PMRandomGenerator.class.st b/src/Math-Random/PMPseudoRandomNumberGenerator.class.st
similarity index 84%
rename from src/Math-Random/PMRandomGenerator.class.st
rename to src/Math-Random/PMPseudoRandomNumberGenerator.class.st
index 68c775b64..c6e1c03d2 100644
--- a/src/Math-Random/PMRandomGenerator.class.st
+++ b/src/Math-Random/PMPseudoRandomNumberGenerator.class.st
@@ -31,16 +31,16 @@ And finally, there's a taxonomy more related with the internal implementation, b
"
Class {
- #name : #PMRandomGenerator,
+ #name : #PMPseudoRandomNumberGenerator,
#superclass : #Object,
#instVars : [
'seed'
],
- #category : 'Math-Random'
+ #category : #'Math-Random'
}
{ #category : #testing }
-PMRandomGenerator class >> chiSquare: range repeating: anInteger [
+PMPseudoRandomNumberGenerator class >> chiSquare: range repeating: anInteger [
"Run a 'chi-square' test on a random number generator, over a range of integers given by range, repeating anInteger times.
Answer an Array containing the result of the chi-square test (which should be the same as the range), and the upper and lower bounds for 'good' randomness (assuming that anInteger is at least 10 * range)."
@@ -64,21 +64,21 @@ PMRandomGenerator class >> chiSquare: range repeating: anInteger [
]
{ #category : #'instance creation' }
-PMRandomGenerator class >> new [
+PMPseudoRandomNumberGenerator class >> new [
"Answer a new instance of the receiver"
^ (self seed: Time millisecondClockValue) initialize
]
{ #category : #'instance creation' }
-PMRandomGenerator class >> seed: anInteger [
+PMPseudoRandomNumberGenerator class >> seed: anInteger [
"Anwer a new Random stream with the initial seed anInteger."
^ self basicNew seed: anInteger; yourself
]
{ #category : #testing }
-PMRandomGenerator >> atEnd [
+PMPseudoRandomNumberGenerator >> atEnd [
"Answer whether the receiver is at its end - never true for a stream of Random numbers"
^ false
@@ -86,7 +86,7 @@ PMRandomGenerator >> atEnd [
]
{ #category : #accessing }
-PMRandomGenerator >> contents [
+PMPseudoRandomNumberGenerator >> contents [
"Answer all of the objects in the collection accessed by the receiver.
Implementation Notes: Random streams are infinite, so there is no implementation possible."
@@ -95,7 +95,7 @@ PMRandomGenerator >> contents [
]
{ #category : #testing }
-PMRandomGenerator >> isReadable [
+PMPseudoRandomNumberGenerator >> isReadable [
"Answer whether the receiver can be read from (i.e. it implements the gettableStream protocol)."
^ true
@@ -103,7 +103,7 @@ PMRandomGenerator >> isReadable [
]
{ #category : #testing }
-PMRandomGenerator >> isWriteable [
+PMPseudoRandomNumberGenerator >> isWriteable [
"Answer whether the receiver can be written to (i.e. it implements the puttableStream protocol)."
^ false
@@ -111,14 +111,14 @@ PMRandomGenerator >> isWriteable [
]
{ #category : #'stream access' }
-PMRandomGenerator >> next [
+PMPseudoRandomNumberGenerator >> next [
"Answer a pseudo-Random number"
^ self subclassResponsibility
]
{ #category : #'stream access' }
-PMRandomGenerator >> next: anInteger [
+PMPseudoRandomNumberGenerator >> next: anInteger [
"Answer a collection of size anInteger of pseudo-random Floats between 0 and 1. "
^ ( 1 to: anInteger ) collect: [ :i | self next ]
@@ -126,21 +126,21 @@ PMRandomGenerator >> next: anInteger [
]
{ #category : #'stream access' }
-PMRandomGenerator >> peek [
+PMPseudoRandomNumberGenerator >> peek [
"Answer a pseudo-Random number generated from the next seed, but do not advance down the stream (i.e. self peek = self peek). "
^ self subclassResponsibility
]
{ #category : #accessing }
-PMRandomGenerator >> seed [
+PMPseudoRandomNumberGenerator >> seed [
"Returns the instance var of the receiver for external manipulation"
^ seed
]
{ #category : #accessing }
-PMRandomGenerator >> seed: anObject [
+PMPseudoRandomNumberGenerator >> seed: anObject [
"Sets the instance var of the receiver with anObject. (No checking is done)"
seed := anObject
diff --git a/src/Math-RandomDistributionBased/package.st b/src/Math-RandomDistributionBased/package.st
deleted file mode 100644
index f8a2f18f4..000000000
--- a/src/Math-RandomDistributionBased/package.st
+++ /dev/null
@@ -1 +0,0 @@
-Package { #name : #'Math-RandomDistributionBased' }
diff --git a/src/Math-Series/PMContinuedFraction.class.st b/src/Math-Series/PMContinuedFraction.class.st
index c8052dcfe..a2e7f69ac 100644
--- a/src/Math-Series/PMContinuedFraction.class.st
+++ b/src/Math-Series/PMContinuedFraction.class.st
@@ -22,9 +22,7 @@ PMContinuedFraction >> evaluateIteration [
{ #category : #operation }
PMContinuedFraction >> initializeIterations [
- "Initialize the series.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/3/99 "
+ "Initialize the series."
numerator := self limitedSmallValue: termServer initialTerm.
denominator := 0.
diff --git a/src/Math-StatisticalMoments/PMFastStatisticalMoments.class.st b/src/Math-StatisticalMoments/PMFastStatisticalMoments.class.st
index 7fe3b28c3..1b1697faf 100644
--- a/src/Math-StatisticalMoments/PMFastStatisticalMoments.class.st
+++ b/src/Math-StatisticalMoments/PMFastStatisticalMoments.class.st
@@ -6,9 +6,6 @@ Class {
{ #category : #transformation }
PMFastStatisticalMoments >> accumulate: aNumber [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
-
| var |
var := 1.
1 to: moments size
@@ -20,17 +17,12 @@ PMFastStatisticalMoments >> accumulate: aNumber [
{ #category : #information }
PMFastStatisticalMoments >> average [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
-
self count = 0 ifTrue: [^nil].
^(moments at: 2) / self count
]
{ #category : #information }
PMFastStatisticalMoments >> kurtosis [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
| var x1 x2 x3 x4 kFact kConst n m4 xSquared |
n := self count.
@@ -50,8 +42,6 @@ PMFastStatisticalMoments >> kurtosis [
{ #category : #information }
PMFastStatisticalMoments >> skewness [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
| x1 x2 x3 n stdev |
n := self count.
@@ -67,16 +57,11 @@ PMFastStatisticalMoments >> skewness [
{ #category : #information }
PMFastStatisticalMoments >> unnormalizedVariance [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 1/22/00 "
-
^(moments at: 3) - ((moments at: 2) squared * self count)
]
{ #category : #information }
PMFastStatisticalMoments >> variance [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
| n |
n := self count.
diff --git a/src/Math-StatisticalMoments/PMFixedStatisticalMoments.class.st b/src/Math-StatisticalMoments/PMFixedStatisticalMoments.class.st
index f90772167..81e72b206 100644
--- a/src/Math-StatisticalMoments/PMFixedStatisticalMoments.class.st
+++ b/src/Math-StatisticalMoments/PMFixedStatisticalMoments.class.st
@@ -6,23 +6,16 @@ Class {
{ #category : #creation }
PMFixedStatisticalMoments class >> new [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
^super new: 4
]
{ #category : #creation }
PMFixedStatisticalMoments class >> new: anInteger [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
^self error: 'Illegal creation message for this class'
]
{ #category : #transformation }
PMFixedStatisticalMoments >> accumulate: aNumber [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/6/99 "
-
| correction n n1 c2 c3 |
n := moments at: 1.
n1 := n + 1.
diff --git a/src/Math-StatisticalMoments/PMHistogram.class.st b/src/Math-StatisticalMoments/PMHistogram.class.st
index d728c5dc5..49898d963 100644
--- a/src/Math-StatisticalMoments/PMHistogram.class.st
+++ b/src/Math-StatisticalMoments/PMHistogram.class.st
@@ -27,9 +27,7 @@ Class {
{ #category : #information }
PMHistogram class >> defaultCacheSize [
- "Private - Answer the default cache size.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/2/99 "
+ "Private - Answer the default cache size."
^100
]
@@ -47,9 +45,7 @@ PMHistogram class >> integerScales [
{ #category : #creation }
PMHistogram class >> new [
- "Create a standard new instance of the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 15/2/99 "
+ "Create a standard new instance of the receiver."
^super new initialize
]
@@ -194,9 +190,7 @@ PMHistogram >> count [
{ #category : #information }
PMHistogram >> countAt: aNumber [
- "Answer the count in the bin corresponding to aNumber or 0 if outside the limits.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/2/99 "
+ "Answer the count in the bin corresponding to aNumber or 0 if outside the limits."
| n |
self isCached
ifTrue: [ self flushCache].
@@ -391,17 +385,13 @@ PMHistogram >> isEmpty [
{ #category : #information }
PMHistogram >> kurtosis [
- "Answer the kurtosis of the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 16/2/99 "
+ "Answer the kurtosis of the receiver."
^self moments kurtosis
]
{ #category : #information }
PMHistogram >> lowBinLimitAt: anInteger [
- "
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 4/3/99 "
+
self isCached
ifTrue: [ self flushCache].
^( anInteger - 1) * binWidth + minimum
@@ -409,9 +399,7 @@ PMHistogram >> lowBinLimitAt: anInteger [
{ #category : #information }
PMHistogram >> maximum [
- "Answer the minimum for the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 16/2/99 "
+ "Answer the minimum for the receiver."
self isCached
ifTrue: [ self flushCache].
^contents size * binWidth + minimum
@@ -419,9 +407,7 @@ PMHistogram >> maximum [
{ #category : #information }
PMHistogram >> maximumCount [
- "Answer the maximum count of the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 17/2/99 "
+ "Answer the maximum count of the receiver."
self isCached
ifTrue: [ self flushCache].
^contents inject: ( contents isEmpty ifTrue: [ 1] ifFalse:[ contents at: 1])
@@ -430,9 +416,7 @@ PMHistogram >> maximumCount [
{ #category : #information }
PMHistogram >> minimum [
- "Answer the minimum for the receiver.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 16/2/99 "
+ "Answer the minimum for the receiver."
self isCached
ifTrue: [ self flushCache].
^minimum
@@ -447,9 +431,7 @@ self isCached
{ #category : #information }
PMHistogram >> overflow [
- "Answer the overflow of the recevier
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 16/2/99 "
+ "Answer the overflow of the receiver"
^overflow
]
@@ -518,9 +500,7 @@ PMHistogram >> setRangeFrom: aNumber1 to: aNumber2 bins: anInteger [
{ #category : #initialization }
PMHistogram >> setWidth: aNumber1 from: aNumber2 bins: anInteger [
"Defines the range of the receiver by specifying the minimum, bin width and number of bins.
- Values are adjusted to correspond to a reasonable value for the bin width and the limits.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 16/2/99 "
+ Values are adjusted to correspond to a reasonable value for the bin width and the limits."
self isCached
ifFalse: [ self error: 'Histogram limits cannot be redefined'].
minimum := aNumber2.
diff --git a/src/Math-StatisticalMoments/PMStatisticalMoments.class.st b/src/Math-StatisticalMoments/PMStatisticalMoments.class.st
index 05d25c52f..0380ab5e9 100644
--- a/src/Math-StatisticalMoments/PMStatisticalMoments.class.st
+++ b/src/Math-StatisticalMoments/PMStatisticalMoments.class.st
@@ -85,9 +85,7 @@ PMStatisticalMoments >> errorOnAverage [
]
{ #category : #testing }
-PMStatisticalMoments >> fConfidenceLevel: aStatisticalMomentsOrHistogram [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 1/22/00 "
+PMStatisticalMoments >> fConfidenceLevel: aStatisticalMomentsOrHistogram [
| fValue |
fValue := self variance/ aStatisticalMomentsOrHistogram variance.
^fValue < 1
@@ -101,9 +99,7 @@ PMStatisticalMoments >> fConfidenceLevel: aStatisticalMomentsOrHistogram [
{ #category : #initialization }
PMStatisticalMoments >> initialize: anInteger [
- "Private - ( anInteger - 1) is the degree of the highest accumulated central moment.
- (c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
+ "Private - ( anInteger - 1) is the degree of the highest accumulated central moment."
moments := Array new: anInteger.
self reset.
@@ -112,8 +108,6 @@ PMStatisticalMoments >> initialize: anInteger [
{ #category : #information }
PMStatisticalMoments >> kurtosis [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
| n n1 n23 |
n := self count.
@@ -126,16 +120,12 @@ PMStatisticalMoments >> kurtosis [
{ #category : #transformation }
PMStatisticalMoments >> reset [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
moments atAllPut: 0
]
{ #category : #information }
PMStatisticalMoments >> skewness [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
| n v |
n := self count.
@@ -146,15 +136,11 @@ PMStatisticalMoments >> skewness [
{ #category : #information }
PMStatisticalMoments >> standardDeviation [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
^self variance sqrt
]
{ #category : #testing }
PMStatisticalMoments >> tConfidenceLevel: aStatisticalMomentsOrHistogram [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 1/22/00 "
| sbar dof |
dof := self count + aStatisticalMomentsOrHistogram count - 2.
sbar := ( ( self unnormalizedVariance + aStatisticalMomentsOrHistogram unnormalizedVariance) / dof) sqrt.
@@ -165,15 +151,11 @@ PMStatisticalMoments >> tConfidenceLevel: aStatisticalMomentsOrHistogram [
{ #category : #information }
PMStatisticalMoments >> unnormalizedVariance [
- "(c) Copyrights Didier BESSET, 2000, all rights reserved.
- Initial code: 1/22/00 "
^( self centralMoment: 2) * self count
]
{ #category : #information }
PMStatisticalMoments >> variance [
- "(c) Copyrights Didier BESSET, 1999, all rights reserved.
- Initial code: 10/5/99 "
| n |
n := self count.
n < 2
diff --git a/src/Math-TSNE/ManifestMathTNSE.class.st b/src/Math-TSNE/ManifestMathTNSE.class.st
deleted file mode 100644
index 2d28c4c31..000000000
--- a/src/Math-TSNE/ManifestMathTNSE.class.st
+++ /dev/null
@@ -1,14 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #ManifestMathTNSE,
- #superclass : #PackageManifest,
- #category : 'Math-TSNE'
-}
-
-{ #category : #'meta-data' }
-ManifestMathTNSE class >> description [ ^ 'Implementation of t-Distributed Stochastic Neighbor Embedding (t-SNE) algorithm
-
-https://lvdmaaten.github.io/tsne/'
-]
diff --git a/src/Math-TSNE/PMTSNE.class.st b/src/Math-TSNE/PMTSNE.class.st
new file mode 100644
index 000000000..ddeaaea0c
--- /dev/null
+++ b/src/Math-TSNE/PMTSNE.class.st
@@ -0,0 +1,680 @@
+"
+Implementation of t-SNE (t-Distributed Stochastic Neighbor Embedding) algorithm
+
+https://lvdmaaten.github.io/tsne/
+
+t-SNE is a technique for dimensionality reduction that is particularly well suited for the visualization of high-dimensional datasets.
+"
+Class {
+ #name : #PMTSNE,
+ #superclass : #Object,
+ #instVars : [
+ 'outputDims',
+ 'initialDims',
+ 'perplexity',
+ 'x',
+ 'y',
+ 'maxIter',
+ 'sumY',
+ 'initialMomentum',
+ 'finalMomentum',
+ 'learningRate',
+ 'minGain',
+ 'job',
+ 'updateProgressEvery',
+ 'updateError',
+ 'iterations',
+ 'p',
+ 'q',
+ 'gains',
+ 'iY'
+ ],
+ #category : #'Math-TSNE'
+}
+
+{ #category : #running }
+PMTSNE class >> entropyOf: distanceVector andPRow: pVector withBeta: beta [
+ "Calculates gaussian kernel values for a distanceVector, along with perplexity
+ Inputs: distanceVector - a PMVector containing distances
+ pRow - calculated p-rows are stored here
+ beta - a Float, precision which is used to compute entropy
+ Outputs: entropy - log(Shannon's entropy) for calculated pVector
+ pVector - The conditional probability pji
+ "
+
+ | pVectorTemp sumP entropy |
+ pVectorTemp := (-1 * distanceVector * beta) exp.
+ sumP := pVectorTemp sum max: (Float epsilon).
+ entropy := sumP ln + (beta * (distanceVector * pVectorTemp) / sumP).
+ pVector copyFrom: (pVectorTemp / sumP).
+ ^ entropy
+]
+
+{ #category : #examples }
+PMTSNE class >> example1 [
+ | points |
+ points := self gridDataGeneratorOf: 10.
+ ^ (self new)
+ perplexity: 10;
+ x: points;
+ initialDims: 2;
+ start;
+ y
+]
+
+{ #category : #examples }
+PMTSNE class >> exampleGridWithVizualization [
+ | points tsne v rec xscale yscale s elements |
+ points := self gridDataGeneratorOf: 12.
+
+ tsne := (self new)
+ perplexity: 10;
+ learningRate: 50;
+ x: points.
+ tsne initializeUninitializedParameters.
+ tsne reduceXToInputDims.
+ tsne initializeYWithRandomValues.
+ tsne initializeStateVariables.
+
+ v := RSView new.
+ "We assign a color to the elements"
+ rec := Rectangle encompassing: (tsne y rows
+ collect: [:row | row first @ row second ]).
+ xscale := TSScale linear domain: { rec origin x. rec corner x }.
+ yscale := TSScale linear domain: { rec origin y. rec corner y }.
+ s := RSShapeBuilder circle
+ size: 5;
+ color: [:vec | Color
+ r: 0.08
+ g: (xscale scale: vec first )
+ b: (yscale scale: vec second) ].
+ elements := s elementsOn: points rows.
+ v camera zoomToFit: 500@500 extent: 800 asPoint.
+ "this is the animation block"
+ (v animation) duration: 5 asDuration;
+ onStepDo: [ :t |
+ tsne step.
+ elements do: [ :e | | point |
+ point := tsne y rowAt: e index.
+ e position: (point first @ point second) * 20 ].
+ ].
+ v addAll: elements.
+ v open setLabel: 'tSNE example: Points arranged in a grid'.
+
+]
+
+{ #category : #examples }
+PMTSNE class >> exampleLinkedRingWithVizualization [
+ | points tsne v counter s elements |
+ points := self linkedRingsDataGeneratorOf: 50.
+
+ "Perplexity near 10 and learningRate <= 10 gives best results"
+ tsne := (self new)
+ perplexity: 3;
+ learningRate: 10;
+ x: points.
+ tsne initializeUninitializedParameters.
+ tsne reduceXToInputDims.
+ tsne initializeYWithRandomValues.
+ tsne initializeStateVariables.
+
+ v := RSView new.
+ "Assign same color to alternate elements"
+ counter := 0.
+ s := RSShapeBuilder circle
+ size: 2;
+ color: [:vec |
+ counter := counter + 1.
+ counter % 2 = 0
+ ifTrue: [Color blue]
+ ifFalse: [Color red]].
+ elements := s elementsOn: points rows.
+ "this is the animation block"
+ (v animation) repeat
+ onStepDo: [ :t |
+ tsne step.
+ elements do: [ :e | | point |
+ point := tsne y rowAt: e index.
+ e position: (point first @ point second) * 20 ].
+ v zoomToFit.
+ (Delay forMilliseconds: 10) wait.
+ ].
+ v addAll: elements.
+ v open setLabel: 'tSNE example: Two 3D linked rings'.
+
+]
+
+{ #category : #'data sets' }
+PMTSNE class >> gridDataGeneratorOf: size [
+ "Demos from https://github.com/distillpub/post--misread-tsne/blob/master/public/assets/demo-configs.js"
+ "A square grid with equal spacing between points."
+ "Returns a PMMatrix"
+
+ | array i |
+ array := Array new: size*size.
+ i := 1.
+ 1 to: size do: [ :x | 1 to: size do: [ :y | array at: i put: {x. y.}.
+ i:=i+1] ].
+ ^ PMMatrix rows: array
+]
+
+{ #category : #'data sets' }
+PMTSNE class >> linkedRingsDataGeneratorOf: size [
+ "Returns a PMMatrix two linked rings. Alternate elements belong to same ring.x
+ Source: https://github.com/distillpub/post--misread-tsne/blob/master/public/assets/demo-datas.js"
+
+ | rotate ring1 |
+ rotate := [ :x :y :z |
+ | outputVec |
+ outputVec := PMVector new: 3.
+ outputVec at: 1 put: x.
+ outputVec at: 2 put: ((0.4 cos) * y) + ((0.4 sin) * z).
+ outputVec at: 3 put: ((0.4 cos) * z) - ((0.4 sin) * y).
+ outputVec
+ ].
+ ring1 := OrderedCollection new.
+ 1 to: size do: [ :i |
+ | angle |
+ angle := 2 * Float pi * (i - 1) / size.
+ ring1 add: (rotate value: (angle cos) value: (angle sin) value: 0).
+ ring1 add: (rotate value: 1 + (angle cos) value: 0 value: (angle sin)).
+ ].
+ ^ PMMatrix rows: ring1
+]
+
+{ #category : #'stepping and presenter' }
+PMTSNE >> computeGradient [
+ "Computes gradient of KL divergence"
+
+ | num sumNum pq dY tmp yiDiff |
+ "Calculates num and q"
+ num := self computeLowDimensionalStudentT.
+ sumNum := num sum sum max: (Float epsilon).
+ q := num collect: [:element |
+ (element / sumNum) max: (Float epsilon)
+ ].
+
+ pq := p - q.
+
+ dY := OrderedCollection new.
+ 1 to: (x dimension x) do: [ :i |
+ tmp := (pq rowAt: i) hadamardProduct: (num rowAt: i).
+ "Create a matrix of rows filled with 'tmp'"
+ tmp := (PMMatrix rows: ((1 to: outputDims) collect: [ :j | tmp])).
+ yiDiff := (PMMatrix rows: (y rowsCollect: [ :row | (y rowAt: i) - row ])) transpose.
+ dY add: (tmp hadamardProduct: yiDiff) sum
+ ].
+ dY := PMMatrix rows: dY.
+
+ ^ dY
+]
+
+{ #category : #running }
+PMTSNE >> computeLowDimensionalAffinities [
+ "Computes affinity of the reduced dimension/output"
+
+ | num sumNum q |
+ num := self computeLowDimensionalStudentT.
+ sumNum := num sum sum max: (Float epsilon).
+ q := num collect: [:element |
+ (element / sumNum) max: (Float epsilon)
+ ].
+ ^ q
+]
+
+{ #category : #running }
+PMTSNE >> computeLowDimensionalStudentT [
+ "Computes Student's T distribution with 1-degree of freedom for y"
+
+ | num tmp |
+ sumY := (y hadamardProduct: y) sum.
+ tmp := ((y* (y transpose)) * (-2)).
+ tmp := PMMatrix rows: (tmp rowsCollect: [ :each| each + sumY]).
+ tmp := PMMatrix rows: ((tmp transpose) rowsCollect: [:each| each + sumY]).
+ num := (1 + tmp) collect: [ :ele | 1.0 / ele ].
+ num := num setDiagonal: (PMVector zeros: (x dimension x)).
+ ^ num
+]
+
+{ #category : #accessing }
+PMTSNE >> computePValues [
+ "Computes joint probablity matrix P"
+ | p sumP |
+ p := self computePairwiseAffinities.
+ p := p + p transpose.
+ sumP := p sum sum.
+ p := p collect: [ :element |
+ "4 is for early exaggeration, will be removed after 100 iterations"
+ (element / sumP * 4) asFloat max: (Float epsilon).
+ ].
+ ^ p
+]
+
+{ #category : #running }
+PMTSNE >> computePairwiseAffinities [
+ "Computes a similarity matrix by making sure each Gaussian has same perplexity.
+ It identifies required precision (beta = (1/ variance**2)) for each row using a
+ binary search. The precision is selected based on input perplexity.
+ "
+
+ | p d beta logU n betaMin betaMax distanceVector pVector entropy tries entropyDiff |
+ n := x numberOfRows.
+ d := self computePairwiseDistances.
+ p := PMMatrix zerosRows: n cols: n.
+ beta := PMVector ones: n.
+ logU := self perplexity ln.
+ distanceVector := PMVector new: n - 1.
+ pVector := PMVector new: n - 1.
+
+ job title: 'Step 2/3: Computing joint probablity for point 1 of ', n asString.
+ job progress: 0.0.
+
+ 1 to: n do: [ :i |
+ "Job progress gets updated every 10 rows"
+ (i % 10 = 0) ifTrue: [
+ job title: ('' join: {'Step 2/3: Computing joint probablity for point '. i asString. ' of '. n asString}).
+ job progress: (i/n).
+ ].
+
+ "Set minimum and maximum value of precision"
+ betaMin := Float infinity negated.
+ betaMax := Float infinity.
+
+ "Ignore i-th element of the row d[i] and copy rest in distanceVector.
+ Also initialize pVector to 0"
+ 1 to: n do: [ :index |
+ (index = i) ifFalse: [
+ (index < i)
+ ifTrue: [ distanceVector at: index put: (d rowAt: i columnAt: index).
+ pVector at: index put: 0. ]
+ ifFalse: [ distanceVector at: (index - 1) put: (d rowAt: i columnAt: index).
+ pVector at: (index - 1) put: 0.].
+ ].
+ ].
+ entropy := self class entropyOf: distanceVector andPRow: pVector withBeta: (beta at: i).
+ entropyDiff := entropy - logU.
+ tries := 0.
+ [ (entropyDiff abs > 1e-5) & (tries < 50)] whileTrue: [
+ (entropyDiff > 0)
+ ifTrue: [
+ betaMin := beta at: i.
+ ((betaMax = Float infinity) | (betaMin = Float infinity negated))
+ ifTrue: [ beta at: i put: ((beta at: i) * 2) ]
+ ifFalse: [ beta at: i put: (((beta at: i) + betaMax) / 2)
+ ].
+ ]
+ ifFalse: [
+ betaMax := beta at: i.
+ ((betaMax = Float infinity) | (betaMin = Float infinity negated))
+ ifTrue: [ beta at: i put: ((beta at: i) / 2) ]
+ ifFalse: [ beta at: i put: (((beta at: i) + betaMin) / 2)
+ ].
+ ].
+ entropy := self class entropyOf: distanceVector andPRow: pVector withBeta: (beta at: i).
+ entropyDiff := entropy - logU.
+ tries := tries + 1.
+ ].
+ 1 to: n do: [ :index |
+ (index = i) ifFalse: [
+ (index < i)
+ ifTrue: [ p rowAt: i columnAt: index put: (pVector at: index) ]
+ ifFalse: [ p rowAt: i columnAt: index put: (pVector at: index - 1) ].
+ ].
+ ].
+ ].
+ ^ p
+]
+
+{ #category : #running }
+PMTSNE >> computePairwiseDistances [
+ | sumX d tmp|
+ sumX := (x hadamardProduct: x) sum.
+ tmp := (x * (x transpose)) * (-2).
+ tmp := PMMatrix rows: (tmp rowsCollect: [ :each| each + sumX ]).
+ d := PMMatrix rows: ((tmp transpose) rowsCollect: [:each| each + sumX]).
+ ^ d
+]
+
+{ #category : #accessing }
+PMTSNE >> finalMomentum [
+ ^ finalMomentum
+]
+
+{ #category : #accessing }
+PMTSNE >> finalMomentum: aFloat [
+ finalMomentum := aFloat
+]
+
+{ #category : #accessing }
+PMTSNE >> finalMomentumDefaultValue [
+ ^ 0.8
+]
+
+{ #category : #running }
+PMTSNE >> gradientDescent [
+ "Tries to minimize the cost, which is KL divergence"
+
+ job title: 'Step 3/3: Performing gradient descent'.
+ job progress: 0.0.
+ self initializeStateVariables.
+ 1 to: maxIter do: [ :i |
+ self step.
+ self postStep.
+ ].
+]
+
+{ #category : #accessing }
+PMTSNE >> initialDims [
+ ^ initialDims
+]
+
+{ #category : #accessing }
+PMTSNE >> initialDims: aFloat [
+ initialDims := aFloat
+]
+
+{ #category : #accessing }
+PMTSNE >> initialDimsDefaultValue [
+ ^ 50
+]
+
+{ #category : #accessing }
+PMTSNE >> initialMomentum [
+ ^ initialMomentum
+]
+
+{ #category : #accessing }
+PMTSNE >> initialMomentum: aFloat [
+ initialMomentum := aFloat
+]
+
+{ #category : #accessing }
+PMTSNE >> initialMomentumDefaultValue [
+ ^ 0.5
+]
+
+{ #category : #initialization }
+PMTSNE >> initialize [
+ "These parameters rarely need to be modified"
+ maxIter := self maxIterDefaultValue.
+ initialMomentum := self initialMomentumDefaultValue.
+ finalMomentum := self finalMomentumDefaultValue.
+ learningRate := self learningRateDefaultValue.
+ minGain := self minGainDefaultValue.
+ updateProgressEvery := self updateProgressEveryDefaultValue.
+ updateError := self updateErrorDefaultValue.
+ iterations := 0.
+ self initializeJob.
+
+]
+
+{ #category : #initialization }
+PMTSNE >> initializeJob [
+ "This job represents all the steps in t-SNE"
+ job := [
+ self initializeUninitializedParameters.
+ self reduceXToInputDims.
+ self initializeYWithRandomValues.
+ self gradientDescent.
+ ] asJob.
+]
+
+{ #category : #initialization }
+PMTSNE >> initializeStateVariables [
+ p := self computePValues.
+ gains := PMMatrix onesRows: x dimension x cols: outputDims.
+ iY := PMMatrix zerosRows: x dimension x cols: outputDims.
+]
+
+{ #category : #initialization }
+PMTSNE >> initializeUninitializedParameters [
+ perplexity ifNil: [ perplexity := self perplexityDefaultValue ].
+ outputDims ifNil: [ outputDims := self outputDimsDefaultValue ].
+ initialDims ifNil: [ initialDims := self initialDimsDefaultValue ]
+]
+
+{ #category : #initialization }
+PMTSNE >> initializeYWithRandomValues [
+ "Answer a new Matrix Y with the number of rows of x and number of columns ndims filled with random numbers following a normal distribution (0,1)"
+ "We should add this to PMMatrix API later"
+
+ | a b rows columns d |
+ rows := x dimension x.
+ columns := outputDims.
+ d := PMNormalDistribution new:0 sigma: 1.
+ a := (1 to: rows)
+ collect: [ :row |
+ b := PMVector new: columns.
+ 1 to: columns do: [ :column | b at: column put: d random ].
+ b ].
+ y := PMMatrix rows: a
+]
+
+{ #category : #accessing }
+PMTSNE >> iterations [
+ ^ iterations
+]
+
+{ #category : #accessing }
+PMTSNE >> learningRate [
+ ^ learningRate
+]
+
+{ #category : #accessing }
+PMTSNE >> learningRate: aNumber [
+ learningRate := aNumber
+]
+
+{ #category : #accessing }
+PMTSNE >> learningRateDefaultValue [
+ ^ 500
+]
+
+{ #category : #accessing }
+PMTSNE >> maxIter [
+ ^ maxIter
+]
+
+{ #category : #accessing }
+PMTSNE >> maxIter: aNumber [
+ maxIter := aNumber
+]
+
+{ #category : #accessing }
+PMTSNE >> maxIterDefaultValue [
+ ^ 1000
+]
+
+{ #category : #accessing }
+PMTSNE >> minGain [
+ ^ minGain
+]
+
+{ #category : #accessing }
+PMTSNE >> minGain: aFloat [
+ minGain := aFloat
+]
+
+{ #category : #accessing }
+PMTSNE >> minGainDefaultValue [
+ ^ 0.01
+]
+
+{ #category : #accessing }
+PMTSNE >> outputDims [
+ ^ outputDims
+]
+
+{ #category : #accessing }
+PMTSNE >> outputDims: anInteger [
+ outputDims := anInteger
+]
+
+{ #category : #accessing }
+PMTSNE >> outputDimsDefaultValue [
+ ^ 2
+]
+
+{ #category : #accessing }
+PMTSNE >> perplexity [
+ ^ perplexity
+]
+
+{ #category : #accessing }
+PMTSNE >> perplexity: aFloat [
+ perplexity := aFloat
+]
+
+{ #category : #accessing }
+PMTSNE >> perplexityDefaultValue [
+ ^ 30.0
+]
+
+{ #category : #'stepping and presenter' }
+PMTSNE >> postStep [
+ "Here will be all the calls for visualization and debugging methods"
+ self updateProgressWithError
+]
+
+{ #category : #running }
+PMTSNE >> reduceXToInputDims [
+ "Runs PCA on X in order to reduce its dimensionality to initialDims dimensions."
+
+ self reduceXToInputDimsUsing: PMPrincipalComponentAnalyserJacobiTransformation.
+]
+
+{ #category : #running }
+PMTSNE >> reduceXToInputDimsUsing: aClass [
+ "Runs aClass PCA on X in order to reduce its dimensionality to initialDims dimensions."
+
+ | scaler pca |
+ job title: 'Step 1/3: Reducing input dimensions.'.
+ scaler := PMStandardizationScaler new.
+ initialDims ifNil: [ initialDims := self initialDimsDefaultValue ].
+ pca := aClass new componentsNumber: (initialDims min: x dimension y).
+ x := pca fitAndTransform: (scaler fitAndTransform: x)
+]
+
+{ #category : #running }
+PMTSNE >> start [
+ job run.
+]
+
+{ #category : #'stepping and presenter' }
+PMTSNE >> step [
+ | dY momentum yMeanAccumulator |
+
+ dY := self computeGradient.
+
+ "Momentum accelerates gradient descent by dampening one direction"
+ momentum := iterations < 20
+ ifTrue: [ initialMomentum ]
+ ifFalse: [ finalMomentum ].
+
+ "Compute gain based on direction of descent"
+ 1 to: x dimension x do: [ :i |
+ 1 to: outputDims do: [ :j |
+ (dY rowAt: i columnAt: j) > 0 = ((iY rowAt: i columnAt: j) > 0)
+ ifTrue: [ gains
+ rowAt: i
+ columnAt: j
+ put: ((gains rowAt: i columnAt: j) * 0.8 max: minGain) ]
+ ifFalse: [ gains rowAt: i columnAt: j put: (gains rowAt: i columnAt: j) + 0.2 ] ] ].
+
+ "Update y according to gradient, momentum and gain"
+ iY := iY * momentum - ((dY hadamardProduct: gains) * learningRate).
+ y := y + iY.
+
+ "Center y by subtracting mean"
+ yMeanAccumulator := PMVectorAccumulator new: outputDims.
+ y rowsDo: [ :row | yMeanAccumulator accumulate: row ].
+ y := PMMatrix
+ rows: (y rowsCollect: [ :row | row - yMeanAccumulator average ]).
+
+ iterations := iterations + 1.
+ "Stop early exaggeration on 100th iteration"
+ iterations = 100
+ ifFalse: [ ^ self ].
+ p := p * (1 / 4).
+]
+
+{ #category : #'stepping and presenter' }
+PMTSNE >> step: aNumber [
+ "Performs aNumber steps"
+ aNumber timesRepeat: [ self step ]
+]
+
+{ #category : #accessing }
+PMTSNE >> updateError [
+ ^ updateError
+]
+
+{ #category : #accessing }
+PMTSNE >> updateError: aBoolean [
+ updateError := aBoolean
+]
+
+{ #category : #accessing }
+PMTSNE >> updateErrorDefaultValue [
+ ^ true
+]
+
+{ #category : #accessing }
+PMTSNE >> updateProgressEvery [
+ ^ updateProgressEvery
+]
+
+{ #category : #accessing }
+PMTSNE >> updateProgressEvery: aNumber [
+ updateProgressEvery := aNumber
+]
+
+{ #category : #accessing }
+PMTSNE >> updateProgressEveryDefaultValue [
+ ^ 10
+]
+
+{ #category : #'stepping and presenter' }
+PMTSNE >> updateProgressWithError [
+ | error |
+
+ (iterations % updateProgressEvery = 0)
+ ifFalse: [ ^ self ].
+
+ "Computing error can take more than 10% additional time.
+ Setting this to false will speedup computation."
+ updateError ifFalse: [ error := '' ]
+ ifTrue: [
+ error := PMMatrix rows: x dimension x columns: x dimension x.
+ 1 to: x dimension x do: [ :i |
+ 1 to: x dimension x do: [ :j |
+ error rowAt: i columnAt: j
+ put: (p rowAt: i columnAt: j) * ((p rowAt: i columnAt: j) / (q rowAt: i columnAt: j)) ln
+ ] ].
+ error := error sum sum ].
+
+ job title: ('' join:
+ {'Step 3/3: Performing gradient descent '. iterations. '/'. maxIter. ' error = '. error}
+ ).
+ job progress: iterations / maxIter.
+]
+
+{ #category : #accessing }
+PMTSNE >> x [
+ ^ x
+]
+
+{ #category : #accessing }
+PMTSNE >> x: aPMMatrix [
+ x := aPMMatrix
+]
+
+{ #category : #accessing }
+PMTSNE >> y [
+ ^ y
+]
+
+{ #category : #accessing }
+PMTSNE >> y: aNumber [
+ y:= aNumber
+]
diff --git a/src/Math-TSNE/TSNE.class.st b/src/Math-TSNE/TSNE.class.st
deleted file mode 100644
index d5a0e517a..000000000
--- a/src/Math-TSNE/TSNE.class.st
+++ /dev/null
@@ -1,238 +0,0 @@
-"
-Implementation of t-SNE (t-Distributed Stochastic Neighbor Embedding) algorithm
-
-https://lvdmaaten.github.io/tsne/
-
-t-SNE is a technique for dimensionality reduction that is particularly well suited for the visualization of high-dimensional datasets.
-"
-Class {
- #name : #TSNE,
- #superclass : #Object,
- #instVars : [
- 'ndims',
- 'initialdims',
- 'perplexity',
- 'x',
- 'y',
- 'maxIter',
- 'epsilon',
- 'sumY',
- 'initialMomentum',
- 'finalMomentum',
- 'eta',
- 'minGain'
- ],
- #category : 'Math-TSNE'
-}
-
-{ #category : #examples }
-TSNE class >> example1 [
- | points |
- points := self gridDataGeneratorOf: 10.
- ^ (self new)
- perplexity: 10;
- x: points;
- initialDims: 2;
- epsilon: 5;
- start;
- y
-]
-
-{ #category : #'as yet unclassified' }
-TSNE class >> gridDataGeneratorOf: size [
- "Demos from https://github.com/distillpub/post--misread-tsne/blob/master/public/assets/demo-configs.js"
- "A square grid with equal spacing between points."
- "Returns a PMMatrix"
-
- | array i |
- array := Array new: size*size.
- i := 1.
- 1 to: size do: [ :x | 1 to: size do: [ :y | array at: i put: {x. y.}.
- i:=i+1] ].
- ^ PMMatrix rows: array
-]
-
-{ #category : #accessing }
-TSNE >> computePValues [
-"
-#Compute P-values
- P = x2p(X, 1e-5, perplexity);
- P = P + Math.transpose(P);
- P = P / Math.sum(P);
- P = P * 4; # early exaggeration
- P = Math.maximum(P, 1e-12);
-"
-| p n |
-p := self x2p.
-p := p + p transpose.
-p := p / (p sum).
-p := p *4.
-p := p max: 1e-12.
-^ p
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> computePairwiseAffinities [
-"
- sum_Y = np.sum(np.square(Y), 1);
- num = 1 / (1 + Math.add(Math.add(-2 * Math.dot(Y, Y.T), sum_Y).T, sum_Y));
- num[range(n), range(n)] = 0;
- Q = num / Math.sum(num);
- Q = Math.maximum(Q, 1e-12);"
- |num tmp|
- sumY := (x dot:x) sum. "PMVector"
- tmp := ((y* (y transpose)) * (-2)) transpose.
- num := ((PMMatrix rows: (tmp rowsCollect: [ :each| each + sumY])) ).
-
-
-
-
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> computePairwiseDistances [
- | sumX d tmp|
- sumX := (x dot: x) sum.
- tmp := (x * (x transpose)) * (-2).
- tmp := PMMatrix rows: (tmp rowsCollect: [ :each| each + sumX ]).
- d := PMMatrix rows: ((tmp transpose) rowsCollect: [:each| each + sumX]).
- ^ d
-]
-
-{ #category : #running }
-TSNE >> epsilon: aFloat [
- epsilon := aFloat
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> initialDims [
- ^initialdims
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> initialDims: aFloat [
- initialdims := aFloat
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> initialDimsDefaultValue [
- ^ 50
-]
-
-{ #category : #initialization }
-TSNE >> initialize [
- maxIter := 1000.
- initialMomentum := 0.5.
- finalMomentum := 0.8.
- eta := 500.
- minGain := 0.01.
-
-]
-
-{ #category : #initialization }
-TSNE >> initializeUninitializedParameters [
- perplexity ifNil: [ perplexity := self perplexityDefaultValue ].
- ndims ifNil: [ ndims := self ndimsDefaultValue ].
- initialdims ifNil: [ initialdims := self initialDimsDefaultValue ]
-]
-
-{ #category : #initialization }
-TSNE >> initializeYWithRandomValues [
- "Answer a new Matrix Y with the number of rows of x and number of columns ndims filled with random numbers following a normal distribution (0,1)"
- "We should add this to PMMatrix API later"
-
- | a b rows columns d |
- rows := x dimension x.
- columns := ndims.
- d := PMNormalDistribution new:0 sigma: 1.
- a := (1 to: rows)
- collect: [ :row |
- b := PMVector new: columns.
- 1 to: columns do: [ :column | b at: column put: d random ].
- b ].
- y := PMMatrix rows: a
-]
-
-{ #category : #accessing }
-TSNE >> ndims [
- ^ ndims
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> ndimsDefaultValue [
- ^ 2
-]
-
-{ #category : #accessing }
-TSNE >> perplexity [
- ^ perplexity
-]
-
-{ #category : #accessing }
-TSNE >> perplexity: aFloat [
- perplexity := aFloat
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> perplexityDefaultValue [
- ^ 30.0
-]
-
-{ #category : #running }
-TSNE >> runPcaOnX [
- "Runs PCA on X in order to reduce its dimensionality to initialdims dimensions.
-
- print ""Preprocessing the data using PCA...""
- (n, d) = X.shape;
- X = X - Math.tile(Math.mean(X, 0), (n, 1));
- (l, M) = Math.linalg.eig(Math.dot(X.T, X));
- Y = Math.dot(X, M[:,0:no_dims]);
- return Y;
-"
-
- "| analyzer i |
- analyzer := PMPrincipalComponentAnalyser new: initialdims.
- i := 1.
- x dimension x
- timesRepeat: [ analyzer accumulate: (x rowAt: i).
- i := i + 1 ].
- ^ analyzer components"
-]
-
-{ #category : #accessing }
-TSNE >> start [
- self initializeUninitializedParameters.
- self runPcaOnX.
- self initializeYWithRandomValues.
- self x2p
-]
-
-{ #category : #'stepping and presenter' }
-TSNE >> step [
- self computePairwiseAffinities
-]
-
-{ #category : #'as yet unclassified' }
-TSNE >> x2p [
- | p d beta logU n betaMin betaMax|
- n := x numberOfRows.
- d := self computePairwiseDistances.
- p := PMMatrix zerosRows: n cols: n.
- beta := PMMatrix onesRows: n cols: 1.
- logU := self perplexity log.
- n timesRepeat: [
- betaMin := Float infinity.
- betaMax := Float infinity negated.
-
- ]
-]
-
-{ #category : #accessing }
-TSNE >> x: aPMMatrix [
- x := aPMMatrix
-]
-
-{ #category : #accessing }
-TSNE >> y [
- ^ y
-]
diff --git a/src/Math-TSNE/TSNETest.class.st b/src/Math-TSNE/TSNETest.class.st
deleted file mode 100644
index 803475421..000000000
--- a/src/Math-TSNE/TSNETest.class.st
+++ /dev/null
@@ -1,24 +0,0 @@
-Class {
- #name : #TSNETest,
- #superclass : #TestCase,
- #category : 'Math-TSNE'
-}
-
-{ #category : #tests }
-TSNETest >> testComputePairwiseDistances [
- | t |
- t := (TSNE
- new)
- x: (PMMatrix rows: #(#(1 2) #(3 4))).
- self assert: t computePairwiseDistances equals: (PMMatrix rows: #(#(0 8) #(8 0)))
-]
-
-{ #category : #tests }
-TSNETest >> testInitialDimsSetByDefaultWithFifty [
- | t |
- t := TSNE
- new
- x: (TSNE gridDataGeneratorOf: 5);
- start.
- self assert: t initialDims equals: 50
-]
diff --git a/src/Math-Tests-Accuracy/AccuracyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st
similarity index 82%
rename from src/Math-Tests-Accuracy/AccuracyTest.class.st
rename to src/Math-Tests-Accuracy/PMAccuracyTest.class.st
index 9d697131e..cb68ab31c 100644
--- a/src/Math-Tests-Accuracy/AccuracyTest.class.st
+++ b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st
@@ -2,36 +2,36 @@
AccuracyTest uses AccuracyTestExample
"
Class {
- #name : #AccuracyTest,
+ #name : #PMAccuracyTest,
#superclass : #TestCase,
#instVars : [
'a',
'dp'
],
- #category : 'Math-Tests-Accuracy'
+ #category : #'Math-Tests-Accuracy'
}
{ #category : #'initialize-release' }
-AccuracyTest >> initialize [
+PMAccuracyTest >> initialize [
super initialize.
- dp := AccuracyTestExample decimalPlaces
+ dp := PMAccuracyTestExample decimalPlaces
]
{ #category : #running }
-AccuracyTest >> setUp [
- a := AccuracyTestExample new.
- AccuracyTestExample decimalPlaces: 3.
+PMAccuracyTest >> setUp [
+ a := PMAccuracyTestExample new.
+ PMAccuracyTestExample decimalPlaces: 3.
]
{ #category : #running }
-AccuracyTest >> tearDown [
- AccuracyTestExample decimalPlaces: dp.
+PMAccuracyTest >> tearDown [
+ PMAccuracyTestExample decimalPlaces: dp.
]
{ #category : #tests }
-AccuracyTest >> testArgumentAt [
+PMAccuracyTest >> testArgumentAt [
self assert: (a argumentAt: 'Aaa') equals: #(#(false) #(true)).
self assert: (a argumentAt: 'Bbb') equals: #(#('a') #('AG')).
self assert: (a argumentAt: 'Ddd') isNil.
@@ -39,12 +39,7 @@ AccuracyTest >> testArgumentAt [
]
{ #category : #tests }
-AccuracyTest >> testArgumentError [
- self should: [ a testArgumentError ] raise: Error
-]
-
-{ #category : #tests }
-AccuracyTest >> testAsArray [
+PMAccuracyTest >> testAsArray [
self assert: (a asArray: 'bla') equals: #('bla').
self assert: (a asArray: #('bla')) equals: #('bla').
self
@@ -53,7 +48,7 @@ AccuracyTest >> testAsArray [
]
{ #category : #tests }
-AccuracyTest >> testCalcDeviationsInMax [
+PMAccuracyTest >> testCalcDeviationsInMax [
| r c |
c := #(#(1 2 3) #(2 3 6)).
r := {(3 / 2).
@@ -74,7 +69,7 @@ AccuracyTest >> testCalcDeviationsInMax [
]
{ #category : #tests }
-AccuracyTest >> testCalcErrorOfRealResult [
+PMAccuracyTest >> testCalcErrorOfRealResult [
self assert: (a calcErrorOf: 0.7 realResult: 0.7) equals: 0.
self assert: (a calcErrorOf: 0.7 realResult: 0.0) equals: -100.
self assert: (a calcErrorOf: 1 / 4 realResult: 1 / 2) equals: 100.
@@ -88,7 +83,7 @@ AccuracyTest >> testCalcErrorOfRealResult [
]
{ #category : #tests }
-AccuracyTest >> testDataTree [
+PMAccuracyTest >> testDataTree [
| s |
a run.
self assert: (a dataTree atPath: #('iterations')) equals: 1.
@@ -126,14 +121,14 @@ AccuracyTest >> testDataTree [
]
{ #category : #tests }
-AccuracyTest >> testDecimalPlaces [
+PMAccuracyTest >> testDecimalPlaces [
self assert: a class decimalPlaces equals: 3.
a class decimalPlaces: 2.
self assert: a class decimalPlaces equals: 2
]
{ #category : #tests }
-AccuracyTest >> testExtractFromResultsWhichOnlyOne [
+PMAccuracyTest >> testExtractFromResultsWhichOnlyOne [
self
assert: (a extractFromResults: #('bla' 'blah') which: 2 onlyOne: false)
equals: 'blah'.
@@ -145,7 +140,7 @@ AccuracyTest >> testExtractFromResultsWhichOnlyOne [
]
{ #category : #tests }
-AccuracyTest >> testExtremeCollectionmax [
+PMAccuracyTest >> testExtremeCollectionmax [
| c |
c := #(4 4 2).
self
@@ -163,7 +158,7 @@ AccuracyTest >> testExtremeCollectionmax [
]
{ #category : #tests }
-AccuracyTest >> testFormat [
+PMAccuracyTest >> testFormat [
self
assert: (a format: #(1 'rez' 1.8899))
equals: #('1.0' 'rez' '1.89').
@@ -175,7 +170,7 @@ AccuracyTest >> testFormat [
]
{ #category : #tests }
-AccuracyTest >> testFormatTypePostfix [
+PMAccuracyTest >> testFormatTypePostfix [
| r |
r := a format: #(1 'rez' 1.8899) type: 'x' postfix: '%%'.
self assert: r contents equals: 'x: 1.0%% , rez%% , 1.89%% '.
@@ -186,7 +181,7 @@ AccuracyTest >> testFormatTypePostfix [
]
{ #category : #tests }
-AccuracyTest >> testFormatTypePostfixTree [
+PMAccuracyTest >> testFormatTypePostfixTree [
| t |
t := KeyedTree new.
self
@@ -206,7 +201,7 @@ AccuracyTest >> testFormatTypePostfixTree [
]
{ #category : #tests }
-AccuracyTest >> testGetters [
+PMAccuracyTest >> testGetters [
| r |
r := a testGetterAaa.
self
@@ -220,7 +215,7 @@ AccuracyTest >> testGetters [
]
{ #category : #tests }
-AccuracyTest >> testIfSeveralterations [
+PMAccuracyTest >> testIfSeveralterations [
a iterations: 2.
self assert: (a ifSeveralterations: [ 1 ]) equals: 1.
a iterations: 1.
@@ -228,7 +223,7 @@ AccuracyTest >> testIfSeveralterations [
]
{ #category : #tests }
-AccuracyTest >> testIterations [
+PMAccuracyTest >> testIterations [
| s d |
a
iterations: 2;
@@ -247,7 +242,7 @@ AccuracyTest >> testIterations [
]
{ #category : #tests }
-AccuracyTest >> testNumberOfDifferentParametersAt [
+PMAccuracyTest >> testNumberOfDifferentParametersAt [
self assert: (a numberOfDifferentParametersAt: 'Aaa') equals: 2.
self assert: (a numberOfDifferentParametersAt: 'Ccc') equals: 2.
self assert: (a numberOfDifferentParametersAt: 'Ddd') equals: 1.
@@ -255,7 +250,7 @@ AccuracyTest >> testNumberOfDifferentParametersAt [
]
{ #category : #tests }
-AccuracyTest >> testNumberOfDifferentResultsAt [
+PMAccuracyTest >> testNumberOfDifferentResultsAt [
self assert: (a numberOfDifferentResultsAt: 'Aaa') equals: 2.
self assert: (a numberOfDifferentResultsAt: 'Bbb') equals: 2.
self assert: (a numberOfDifferentResultsAt: 'Ccc') equals: 3.
@@ -264,7 +259,7 @@ AccuracyTest >> testNumberOfDifferentResultsAt [
]
{ #category : #tests }
-AccuracyTest >> testParameterAt [
+PMAccuracyTest >> testParameterAt [
self assert: (a parameterAt: 'Aaa') equals: #(#(1 2) #(3 2.8888)).
self assert: (a parameterAt: 'Bbb') equals: #(#(1) #(3)).
self assert: (a parameterAt: 'Ddd') isNil.
@@ -272,16 +267,11 @@ AccuracyTest >> testParameterAt [
]
{ #category : #tests }
-AccuracyTest >> testParameterError [
-self should: [a testParameterError ]raise: Error
-]
-
-{ #category : #tests }
-AccuracyTest >> testPrintOn [
+PMAccuracyTest >> testPrintOn [
| s |
s := WriteStream on: String new.
a printOn: s.
- self assert: s contents equals: 'an AccuracyTestExample ()'.
+ self assert: s contents equals: 'a PMAccuracyTestExample ()'.
s reset.
a run.
a printOn: s.
@@ -289,24 +279,19 @@ AccuracyTest >> testPrintOn [
assert:
(s contents
beginsWith:
- 'an AccuracyTestExample (
-Report for: AccuracyTestExample')
+ 'a PMAccuracyTestExample (
+Report for: PMAccuracyTestExample')
]
{ #category : #tests }
-AccuracyTest >> testReport [
+PMAccuracyTest >> testReport [
self assert: a report equals: ''.
a run.
- self assert: (a report beginsWith: 'Report for: AccuracyTestExample')
-]
-
-{ #category : #tests }
-AccuracyTest >> testResultError [
-self should: [a testResultError ]raise: Error
+ self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample')
]
{ #category : #tests }
-AccuracyTest >> testResultsKeyForAtPosition [
+PMAccuracyTest >> testResultsKeyForAtPosition [
self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4).
self assert: (a resultsKeyFor: 'Bbb' AtPosition: 1) equals: #(2).
a run.
@@ -337,7 +322,7 @@ AccuracyTest >> testResultsKeyForAtPosition [
]
{ #category : #tests }
-AccuracyTest >> testRun [
+PMAccuracyTest >> testRun [
a run.
a run: 'Bbb'.
self assert: (a dataTree atPath: #('names' 'data')) equals: #('Bbb').
@@ -345,7 +330,7 @@ AccuracyTest >> testRun [
assert:
(a report
beginsWith:
- 'Report for: AccuracyTestExample
+ 'Report for: PMAccuracyTestExample
test Bbb').
a run: #('Ccc' 'Eee').
self
@@ -354,7 +339,7 @@ test Bbb').
]
{ #category : #tests }
-AccuracyTest >> testSetUp [
+PMAccuracyTest >> testSetUp [
self assert: a count equals: 0.
a performCheck: 'Fff'.
self assert: a count equals: 4 / 5.
@@ -364,7 +349,7 @@ AccuracyTest >> testSetUp [
]
{ #category : #tests }
-AccuracyTest >> testTreeTypeData [
+PMAccuracyTest >> testTreeTypeData [
| aTree |
aTree := KeyedTree new.
self assert: (a tree: aTree type: 'aa' data: 'bb') equals: aTree.
@@ -378,7 +363,7 @@ AccuracyTest >> testTreeTypeData [
]
{ #category : #tests }
-AccuracyTest >> testperformCheck [
+PMAccuracyTest >> testperformCheck [
| b |
a extractFromResults: 'bla' which: 2 onlyOne: false. "for setting numberOfResults"
self assert: (a performCheck: 'Aaa') equals: #(#(1 1)).
diff --git a/src/Math-Tests-Accuracy/AccuracyTestExample.class.st b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st
similarity index 70%
rename from src/Math-Tests-Accuracy/AccuracyTestExample.class.st
rename to src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st
index 343304f04..70c90e4a5 100644
--- a/src/Math-Tests-Accuracy/AccuracyTestExample.class.st
+++ b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st
@@ -5,52 +5,52 @@ AccuracyTestExample new run.
"
Class {
- #name : #AccuracyTestExample,
+ #name : #PMAccuracyTestExample,
#superclass : #PMAccuracy,
#instVars : [
'count'
],
- #category : 'Math-Tests-Accuracy'
+ #category : #'Math-Tests-Accuracy'
}
{ #category : #tests }
-AccuracyTestExample >> checkAaa [
+PMAccuracyTestExample >> checkAaa [
self argument first ifTrue:[^#(1 1)].
^{4 +(0.4 * Random new next) . 2}
]
{ #category : #tests }
-AccuracyTestExample >> checkBbb [
+PMAccuracyTestExample >> checkBbb [
^self argument first size +self parameter first
]
{ #category : #tests }
-AccuracyTestExample >> checkCcc [
+PMAccuracyTestExample >> checkCcc [
^self argument first +(0.01*self parameter first).
]
{ #category : #tests }
-AccuracyTestExample >> checkDdd [
+PMAccuracyTestExample >> checkDdd [
^{2 .3 }asOrderedCollection
]
{ #category : #tests }
-AccuracyTestExample >> checkEee [
+PMAccuracyTestExample >> checkEee [
^{self parameter first .3 }
]
{ #category : #tests }
-AccuracyTestExample >> checkFff [
+PMAccuracyTestExample >> checkFff [
^{0. 0. 1. 0. Float nan}
]
{ #category : #private }
-AccuracyTestExample >> count [
+PMAccuracyTestExample >> count [
^count
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initialize [
+PMAccuracyTestExample >> initialize [
"this is always necessarily the first thing:"
super initialize .
"this is only for testSetup:"
@@ -63,7 +63,7 @@ self parameter: #(#(1) #(3))
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initializeAaa [
+PMAccuracyTestExample >> initializeAaa [
"this overrides defaults in #initialize:"
self result: #(#(5 3) #(4 4)).
self argument: #(#(false) #(true)).
@@ -71,14 +71,14 @@ self parameter: #(#(1 2) #(3 2.8888))
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initializeCcc [
+PMAccuracyTestExample >> initializeCcc [
"this overrides defaults in initialize"
self result: #((1)(1)(1)).
self argument: #((1)(1.1)(0.9)).
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initializeDdd [
+PMAccuracyTestExample >> initializeDdd [
"this overrides defaults in initialize"
self result: #(1.1 2.2).
self argument: #()."necessary since otherwise the default values defined in #initialize would be used"
@@ -86,14 +86,14 @@ self parameter: #().
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initializeEee [
+PMAccuracyTestExample >> initializeEee [
"this overrides defaults in initialize"
self result: #(#(1.1 2.2) #(1 3)).
]
{ #category : #'initialize-release' }
-AccuracyTestExample >> initializeFff [
+PMAccuracyTestExample >> initializeFff [
"this overrides defaults in initialize"
self result: #(0 1 0 -2 3).
self argument: nil.
@@ -101,36 +101,21 @@ self parameter:nil.
]
{ #category : #running }
-AccuracyTestExample >> setUp [
+PMAccuracyTestExample >> setUp [
count :=count+1.
]
{ #category : #running }
-AccuracyTestExample >> tearDown [
+PMAccuracyTestExample >> tearDown [
count :=count-(1/5).
]
{ #category : #private }
-AccuracyTestExample >> testArgumentError [
-self argument: #(#(1) #(2)).
-]
-
-{ #category : #private }
-AccuracyTestExample >> testGetterAaa [
+PMAccuracyTestExample >> testGetterAaa [
^{ self parameter .self argument.self resultsAt: 'Aaa'.self numberOfDifferentParametersAt: 'Aaa'.self numberOfDifferentResultsAt:'Aaa'}
]
{ #category : #private }
-AccuracyTestExample >> testGetterBbb [
+PMAccuracyTestExample >> testGetterBbb [
^{ self parameter .self argument.self resultsAt: 'Bbb'.self numberOfDifferentParametersAt: 'Bbb'.self numberOfDifferentResultsAt:'Bbb'}
]
-
-{ #category : #private }
-AccuracyTestExample >> testParameterError [
-self parameter: #(#(1) #(2)).
-]
-
-{ #category : #private }
-AccuracyTestExample >> testResultError [
-self result:#(1).
-]
diff --git a/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st b/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st
similarity index 81%
rename from src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st
rename to src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st
index c92a8b8f4..7ad66bc09 100644
--- a/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st
+++ b/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st
@@ -2,7 +2,7 @@
Test to check FloatingPoint numbers with arbitrary precision
"
Class {
- #name : #ArbitraryPrecisionFloatTest,
+ #name : #PMArbitraryPrecisionFloatTest,
#superclass : #TestCase,
#instVars : [
'zero',
@@ -13,16 +13,16 @@ Class {
'minusTwo',
'huge'
],
- #category : 'Math-Tests-ArbitraryPrecisionFloat'
+ #category : #'Math-Tests-ArbitraryPrecisionFloat'
}
{ #category : #accessing }
-ArbitraryPrecisionFloatTest class >> defaultTimeLimit [
+PMArbitraryPrecisionFloatTest class >> defaultTimeLimit [
^ 120 seconds
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkDoublePrecision: y forFunction: func nBits: n [
+PMArbitraryPrecisionFloatTest >> checkDoublePrecision: y forFunction: func nBits: n [
"Check that doubling the precision, then rounding would lead to the same result"
| anArbitraryPrecisionFloat singlePrecisionResult |
@@ -33,17 +33,17 @@ ArbitraryPrecisionFloatTest >> checkDoublePrecision: y forFunction: func nBits:
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkDoublePrecisionSerie: serie forFunction: func [
+PMArbitraryPrecisionFloatTest >> checkDoublePrecisionSerie: serie forFunction: func [
^self checkDoublePrecisionSerie: serie forFunction: func nBits: Float precision
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkDoublePrecisionSerie: serie forFunction: func nBits: n [
+PMArbitraryPrecisionFloatTest >> checkDoublePrecisionSerie: serie forFunction: func nBits: n [
serie do: [:y | self checkDoublePrecision: y forFunction: func nBits: n]
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkDoublePrecisionSerieVsFloat: serie forFunction: func [
+PMArbitraryPrecisionFloatTest >> checkDoublePrecisionSerieVsFloat: serie forFunction: func [
^serie reject: [:y |
| farb |
farb := self checkDoublePrecision: y forFunction: func nBits: Float precision.
@@ -51,7 +51,7 @@ ArbitraryPrecisionFloatTest >> checkDoublePrecisionSerieVsFloat: serie forFuncti
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toDoublePrecisionOf: anArbitraryPrecisionFloat equals: singlePrecisionResult [
+PMArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toDoublePrecisionOf: anArbitraryPrecisionFloat equals: singlePrecisionResult [
"Check that doubling the precision, then rounding would lead to the same result"
| n doublePrecision doublePrecisionResult lowBits |
@@ -78,7 +78,7 @@ ArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toDoublePrecisi
]
{ #category : #private }
-ArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toQuadruplePrecisionOf: anArbitraryPrecisionFloat equals: singlePrecisionResult [
+PMArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toQuadruplePrecisionOf: anArbitraryPrecisionFloat equals: singlePrecisionResult [
"Check that quadrupling the precision, then rounding would lead to the same result"
| n quadruplePrecision quadruplePrecisionResult lowBits |
@@ -97,22 +97,22 @@ ArbitraryPrecisionFloatTest >> checkThatEvaluatingFunction: func toQuadruplePrec
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> hyperbolicSerie [
+PMArbitraryPrecisionFloatTest >> hyperbolicSerie [
^#(-3.0e0 -0.1e0 0.0e0 1.0e-20 1.0e-10 0.99e0 1.0e0 2.5e0 3.0e0 10.25e0) , (Array with: (3/10) asFloat with: (22/7) asFloat)
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> inverseTrigonometricSerie [
+PMArbitraryPrecisionFloatTest >> inverseTrigonometricSerie [
^((-20 to: 20) collect: [:e | (e / 20) asFloat]) , ((-6 to: 6) collect: [:e | (e / 7) asFloat])
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> largeTrigonometricSerie [
+PMArbitraryPrecisionFloatTest >> largeTrigonometricSerie [
^#(1.0e15 1.1e21 1.2e28 1.0e32 1.1e34 -1.23e51 1.345e67 1.777e151 1.211e308)
]
{ #category : #setup }
-ArbitraryPrecisionFloatTest >> setUp [
+PMArbitraryPrecisionFloatTest >> setUp [
zero := 0 asArbitraryPrecisionFloatNumBits: 53.
one := 1 asArbitraryPrecisionFloatNumBits: 53.
two := 2 asArbitraryPrecisionFloatNumBits: 53.
@@ -123,7 +123,7 @@ ArbitraryPrecisionFloatTest >> setUp [
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testArCosh [
+PMArbitraryPrecisionFloatTest >> testArCosh [
| serie |
serie := ((1 to: 10) , #(1.0001 100 1000 1.0e20)) collect: [:e | e asFloat].
@@ -131,12 +131,12 @@ ArbitraryPrecisionFloatTest >> testArCosh [
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testArCoshDomainError [
+PMArbitraryPrecisionFloatTest >> testArCoshDomainError [
self should: [(1/2 asArbitraryPrecisionFloatNumBits: 24) arCosh] raise: DomainError.
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testArSinh [
+PMArbitraryPrecisionFloatTest >> testArSinh [
| serie |
serie := ((-5 to: 10) , #(1.0e-20 1.0e-10 0.9999 1.0001 100 1000 1.0e20)) collect: [:e | e asFloat].
@@ -144,7 +144,7 @@ ArbitraryPrecisionFloatTest >> testArSinh [
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testArTanh [
+PMArbitraryPrecisionFloatTest >> testArTanh [
| serie |
serie := ((-19 to: 19) collect: [:e | (e / 20) asFloat]) , ((-6 to: 6) collect: [:e | (e / 7) asFloat]) , #(1.0e-20 1.0e-10 0.99 0.9999 0.999999).
@@ -152,50 +152,71 @@ ArbitraryPrecisionFloatTest >> testArTanh [
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testArTanhDomainError [
+PMArbitraryPrecisionFloatTest >> testArTanhDomainError [
self should: [(2 asArbitraryPrecisionFloatNumBits: 24) arTanh] raise: DomainError.
self should: [(-3 asArbitraryPrecisionFloatNumBits: 24) arTanh] raise: DomainError.
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcCos [
-
+PMArbitraryPrecisionFloatTest >> testArcCos [
+ "seconds"
+
+
| badArcCos |
- badArcCos := self checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie forFunction: #arcCos.
- badArcCos isEmpty ifFalse: [Transcript cr; show: 'bad arcCos for ' , badArcCos printString]
+ badArcCos := self
+ checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie
+ forFunction: #arcCos.
+ "badArcCos isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show: 'bad arcCos for ' , badArcCos printString ]"
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcCosDomainError [
+PMArbitraryPrecisionFloatTest >> testArcCosDomainError [
self should: [(2 asArbitraryPrecisionFloatNumBits: 24) arcCos] raise: DomainError.
self should: [(-3 asArbitraryPrecisionFloatNumBits: 24) arcCos] raise: DomainError.
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcSin [
-
+PMArbitraryPrecisionFloatTest >> testArcSin [
+ "seconds"
+
+
| badArcSin |
- badArcSin := self checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie forFunction: #arcSin.
- badArcSin isEmpty ifFalse: [Transcript cr; show: 'bad arcSin for ' , badArcSin printString]
+ badArcSin := self
+ checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie
+ forFunction: #arcSin.
+" badArcSin isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show: 'bad arcSin for ' , badArcSin printString ]"
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcSinDomainError [
+PMArbitraryPrecisionFloatTest >> testArcSinDomainError [
self should: [(2 asArbitraryPrecisionFloatNumBits: 24) arcSin] raise: DomainError.
self should: [(-3 asArbitraryPrecisionFloatNumBits: 24) arcSin] raise: DomainError.
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcTan [
-
+PMArbitraryPrecisionFloatTest >> testArcTan [
+ "seconds"
+
+
| badArcTan serie |
- serie := ((-50 to: 50) collect: [:e | (e / 10) asFloat]).
- badArcTan := self checkDoublePrecisionSerieVsFloat: serie forFunction: #arcTan.
- badArcTan isEmpty ifFalse: [Transcript cr; show: 'bad arcTan for ' , badArcTan printString]
+ serie := (-50 to: 50) collect: [ :e | (e / 10) asFloat ].
+ badArcTan := self
+ checkDoublePrecisionSerieVsFloat: serie
+ forFunction: #arcTan.
+" badArcTan isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show: 'bad arcTan for ' , badArcTan printString ]"
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testArcTan2 [
+PMArbitraryPrecisionFloatTest >> testArcTan2 [
-5 to: 5 by: 4/10 do: [:y |
| yf yd |
@@ -209,13 +230,13 @@ ArbitraryPrecisionFloatTest >> testArcTan2 [
]
{ #category : #'testing-converting' }
-ArbitraryPrecisionFloatTest >> testAsFloat [
+PMArbitraryPrecisionFloatTest >> testAsFloat [
self assert: (half asArbitraryPrecisionFloatNumBits: Float precision) asFloat = 0.5e0.
self assert: (half asArbitraryPrecisionFloatNumBits: Float precision * 2) asFloat = 0.5e0.
]
{ #category : #'testing-converting' }
-ArbitraryPrecisionFloatTest >> testAsFloatWithUnderflow [
+PMArbitraryPrecisionFloatTest >> testAsFloatWithUnderflow [
| fmin fminA |
fmin := Float fmin.
fminA := fmin asArbitraryPrecisionFloatNumBits: one numBits.
@@ -224,7 +245,7 @@ ArbitraryPrecisionFloatTest >> testAsFloatWithUnderflow [
]
{ #category : #'testing-converting' }
-ArbitraryPrecisionFloatTest >> testAsMinimalDecimalFraction [
+PMArbitraryPrecisionFloatTest >> testAsMinimalDecimalFraction [
| emax emin leadingOne significands |
significands := 0 to: 1<<10-1.
leadingOne := 1<<10.
@@ -246,7 +267,7 @@ ArbitraryPrecisionFloatTest >> testAsMinimalDecimalFraction [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingDivide [
+PMArbitraryPrecisionFloatTest >> testCoercingDivide [
(Array with: 1/2 with: 0.5e0 with: 0.5s1) do: [:heteroHalf |
self assert: one / heteroHalf = two.
self assert: (one / heteroHalf) class = one class.
@@ -264,7 +285,7 @@ ArbitraryPrecisionFloatTest >> testCoercingDivide [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingEqual [
+PMArbitraryPrecisionFloatTest >> testCoercingEqual [
self assert: half = (1/2).
self assert: (1/2) = half.
self deny: half = (1/3).
@@ -287,7 +308,7 @@ ArbitraryPrecisionFloatTest >> testCoercingEqual [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingLessThan [
+PMArbitraryPrecisionFloatTest >> testCoercingLessThan [
self deny: half < (1/2).
self assert: (1/3) < half.
self assert: minusOne < (1/2).
@@ -318,7 +339,7 @@ ArbitraryPrecisionFloatTest >> testCoercingLessThan [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingMultiply [
+PMArbitraryPrecisionFloatTest >> testCoercingMultiply [
(Array with: 1/2 with: 0.5e0 with: 0.5s1) do: [:heteroHalf |
self assert: two * heteroHalf = one.
self assert: (two * heteroHalf) class = half class.
@@ -336,7 +357,7 @@ ArbitraryPrecisionFloatTest >> testCoercingMultiply [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingSubtract [
+PMArbitraryPrecisionFloatTest >> testCoercingSubtract [
(Array with: 1/2 with: 0.5e0 with: 0.5s1) do: [:heteroHalf |
self assert: half - heteroHalf = zero.
self assert: (half - heteroHalf) class = half class.
@@ -354,7 +375,7 @@ ArbitraryPrecisionFloatTest >> testCoercingSubtract [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testCoercingSum [
+PMArbitraryPrecisionFloatTest >> testCoercingSum [
(Array with: 1/2 with: 0.5e0 with: 0.5s1) do: [:heteroHalf |
self assert: half + heteroHalf = one.
self assert: (half + heteroHalf) class = half class.
@@ -372,21 +393,30 @@ ArbitraryPrecisionFloatTest >> testCoercingSum [
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testCos [
-
+PMArbitraryPrecisionFloatTest >> testCos [
+ "seconds"
+
+
| badCos |
- badCos := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #cos.
- badCos isEmpty ifFalse: [Transcript cr; show: 'bad cos for angles (degrees) ' , (badCos collect: [:i | i radiansToDegrees rounded]) printString]
+ badCos := self
+ checkDoublePrecisionSerieVsFloat: self trigonometricSerie
+ forFunction: #cos.
+" badCos isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show:
+ 'bad cos for angles (degrees) '
+ , (badCos collect: [ :i | i radiansToDegrees rounded ]) printString ]"
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testCosh [
+PMArbitraryPrecisionFloatTest >> testCosh [
self checkDoublePrecisionSerie: self hyperbolicSerie forFunction: #cosh
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testDivide [
+PMArbitraryPrecisionFloatTest >> testDivide [
| serie |
serie := {1. 2. 3. 5. 6. 7. 9. 10. 11. 12. 19. 243. 10 raisedTo: Float precision + 1. Float precision factorial. Float pi.}.
serie do: [:num |
@@ -403,7 +433,7 @@ ArbitraryPrecisionFloatTest >> testDivide [
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testEqual [
+PMArbitraryPrecisionFloatTest >> testEqual [
self assert: zero = zero.
self assert: one = one.
self assert: one = one copy.
@@ -427,7 +457,7 @@ ArbitraryPrecisionFloatTest >> testEqual [
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testExp [
+PMArbitraryPrecisionFloatTest >> testExp [
| badExp serie |
serie := ((-20 to: 20) collect: [:e |e asFloat]).
@@ -436,7 +466,7 @@ ArbitraryPrecisionFloatTest >> testExp [
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testExpLn [
+PMArbitraryPrecisionFloatTest >> testExpLn [
|n|
self assert: (1 asArbitraryPrecisionFloatNumBits: 53) exp asFloat = 1 asFloat exp.
n := 5 exp.
@@ -449,7 +479,7 @@ ArbitraryPrecisionFloatTest >> testExpLn [
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testGreaterThan [
+PMArbitraryPrecisionFloatTest >> testGreaterThan [
self assert: zero < one.
self deny: one > two.
@@ -466,7 +496,7 @@ ArbitraryPrecisionFloatTest >> testGreaterThan [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusFloat [
+PMArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusFloat [
| floats ops ref new |
floats := #(1.0 2.0 3.0 5.0 10.0 2r1.0e52 2r1.0e53 2r1.0e54 0.5 0.25 2r1.0e-52 2r1.0e-53 2r1.0e-54 1.0e60 0.1 1.1e-30 1.0e-60) copyWith: Float pi.
ops := #(#+ #- #* #/ #= #< #> ).
@@ -482,7 +512,7 @@ ArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusFloat [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusIntegerAndFraction [
+PMArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusIntegerAndFraction [
"check that results are the same as IEEE 754 accelerated hardware
WARNING: this cannot be the case for denormalized numbers (gradual underflow)
because our exponent is unlimited"
@@ -530,7 +560,7 @@ ArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusIntegerAndFraction [
]
{ #category : #'testing-coercing' }
-ArbitraryPrecisionFloatTest >> testInfinityAndNaN [
+PMArbitraryPrecisionFloatTest >> testInfinityAndNaN [
| inf nan |
inf := Float infinity.
nan := Float nan.
@@ -562,14 +592,14 @@ ArbitraryPrecisionFloatTest >> testInfinityAndNaN [
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testIsZero [
+PMArbitraryPrecisionFloatTest >> testIsZero [
self assert: zero isZero.
self deny: one isZero.
self deny: minusTwo isZero.
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testLessThan [
+PMArbitraryPrecisionFloatTest >> testLessThan [
self assert: zero < one.
self assert: one < two.
@@ -586,7 +616,7 @@ ArbitraryPrecisionFloatTest >> testLessThan [
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testLn [
+PMArbitraryPrecisionFloatTest >> testLn [
| badLn serie |
serie := ((1 to: 100) collect: [:e |e asFloat]).
@@ -595,12 +625,12 @@ ArbitraryPrecisionFloatTest >> testLn [
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testLnDomainError [
+PMArbitraryPrecisionFloatTest >> testLnDomainError [
self should: [(-2 asArbitraryPrecisionFloatNumBits: 24) ln] raise: DomainError.
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testMultiply [
+PMArbitraryPrecisionFloatTest >> testMultiply [
self assert: zero * zero = zero.
self assert: zero * minusOne = zero.
self assert: huge * zero = zero.
@@ -617,7 +647,7 @@ ArbitraryPrecisionFloatTest >> testMultiply [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testNegated [
+PMArbitraryPrecisionFloatTest >> testNegated [
self assert: zero negated = zero.
self assert: one negated = minusOne.
self assert: minusTwo negated = two.
@@ -626,7 +656,7 @@ ArbitraryPrecisionFloatTest >> testNegated [
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testNegative [
+PMArbitraryPrecisionFloatTest >> testNegative [
self deny: zero negative.
self deny: two negative.
@@ -634,14 +664,14 @@ ArbitraryPrecisionFloatTest >> testNegative [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testPi [
+PMArbitraryPrecisionFloatTest >> testPi [
"check computation of pi"
self assert: (1 asArbitraryPrecisionFloatNumBits: 53) pi = Float pi.
]
{ #category : #'testing-compare' }
-ArbitraryPrecisionFloatTest >> testPositive [
+PMArbitraryPrecisionFloatTest >> testPositive [
self assert: zero positive.
self assert: one positive.
@@ -649,7 +679,7 @@ ArbitraryPrecisionFloatTest >> testPositive [
]
{ #category : #'testing-converting' }
-ArbitraryPrecisionFloatTest >> testPrintAndEvaluate [
+PMArbitraryPrecisionFloatTest >> testPrintAndEvaluate [
"seconds"
@@ -684,7 +714,7 @@ ArbitraryPrecisionFloatTest >> testPrintAndEvaluate [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testRaisedToNegativeInteger [
+PMArbitraryPrecisionFloatTest >> testRaisedToNegativeInteger [
| n |
n := 11.
1 to: 1<> testRaisedToNegativeInteger [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testRaisedToPositiveInteger [
+PMArbitraryPrecisionFloatTest >> testRaisedToPositiveInteger [
| n |
n := 11.
1 to: 1<> testRaisedToPositiveInteger [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testReciprocal [
+PMArbitraryPrecisionFloatTest >> testReciprocal [
| b |
b := 1 << (Float precision - 1).
1 to: 10000 do: [:i |
@@ -714,7 +744,7 @@ ArbitraryPrecisionFloatTest >> testReciprocal [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testRoundToNearestEven [
+PMArbitraryPrecisionFloatTest >> testRoundToNearestEven [
"Check that IEEE default rounding mode is honoured,
that is rounding to nearest even"
@@ -727,7 +757,7 @@ ArbitraryPrecisionFloatTest >> testRoundToNearestEven [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testRoundToNearestEvenAgainstIEEEDouble [
+PMArbitraryPrecisionFloatTest >> testRoundToNearestEvenAgainstIEEEDouble [
"Check that IEEE default rounding mode is honoured"
#(1 2 3 5 6 7) do:
@@ -739,15 +769,24 @@ ArbitraryPrecisionFloatTest >> testRoundToNearestEvenAgainstIEEEDouble [
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testSin [
-
+PMArbitraryPrecisionFloatTest >> testSin [
+ "seconds"
+
+
| badSin |
- badSin := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #sin.
- badSin isEmpty ifFalse: [Transcript cr; show: 'bad sin for angles (degrees) ' , (badSin collect: [:i | i radiansToDegrees rounded]) printString]
+ badSin := self
+ checkDoublePrecisionSerieVsFloat: self trigonometricSerie
+ forFunction: #sin.
+" badSin isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show:
+ 'bad sin for angles (degrees) '
+ , (badSin collect: [ :i | i radiansToDegrees rounded ]) printString ]"
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testSincos [
+PMArbitraryPrecisionFloatTest >> testSincos [
self trigonometricSerie do: [:aFloat |
| x sc s c |
@@ -762,13 +801,13 @@ ArbitraryPrecisionFloatTest >> testSincos [
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testSinh [
+PMArbitraryPrecisionFloatTest >> testSinh [
self checkDoublePrecisionSerie: self hyperbolicSerie forFunction: #sinh
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testSqrt [
+PMArbitraryPrecisionFloatTest >> testSqrt [
| badSqrt serie |
"knowing that (10**3) < (2**10), 100 bits are enough for representing 10**30 exactly"
@@ -780,12 +819,12 @@ ArbitraryPrecisionFloatTest >> testSqrt [
]
{ #category : #'testing-functions' }
-ArbitraryPrecisionFloatTest >> testSqrtDomainError [
+PMArbitraryPrecisionFloatTest >> testSqrtDomainError [
self should: [(-2 asArbitraryPrecisionFloatNumBits: 24) sqrt] raise: DomainError.
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testSubtract [
+PMArbitraryPrecisionFloatTest >> testSubtract [
self assert: zero - zero = zero.
self assert: zero - minusOne = one.
self assert: huge - zero = huge.
@@ -800,7 +839,7 @@ ArbitraryPrecisionFloatTest >> testSubtract [
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testSum [
+PMArbitraryPrecisionFloatTest >> testSum [
self assert: zero + zero = zero.
self assert: zero + minusOne = minusOne.
self assert: huge + zero = huge.
@@ -815,39 +854,48 @@ ArbitraryPrecisionFloatTest >> testSum [
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testTan [
-
+PMArbitraryPrecisionFloatTest >> testTan [
+ "seconds"
+
+
| badTan |
- badTan := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #tan.
- badTan isEmpty ifFalse: [Transcript cr; show: 'bad tan for angles (degrees) ' , (badTan collect: [:i | i radiansToDegrees rounded]) printString]
+ badTan := self
+ checkDoublePrecisionSerieVsFloat: self trigonometricSerie
+ forFunction: #tan.
+" badTan isEmpty
+ ifFalse: [ Transcript
+ cr;
+ show:
+ 'bad tan for angles (degrees) '
+ , (badTan collect: [ :i | i radiansToDegrees rounded ]) printString ]"
]
{ #category : #'testing-hyperbolic' }
-ArbitraryPrecisionFloatTest >> testTanh [
+PMArbitraryPrecisionFloatTest >> testTanh [
self checkDoublePrecisionSerie: self hyperbolicSerie forFunction: #tanh
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testVeryLargeCos [
+PMArbitraryPrecisionFloatTest >> testVeryLargeCos [
self checkDoublePrecisionSerie: self largeTrigonometricSerie forFunction: #cos.
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testVeryLargeSin [
+PMArbitraryPrecisionFloatTest >> testVeryLargeSin [
self checkDoublePrecisionSerie: self largeTrigonometricSerie forFunction: #sin.
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> testVeryLargeTan [
+PMArbitraryPrecisionFloatTest >> testVeryLargeTan [
self checkDoublePrecisionSerie: self largeTrigonometricSerie forFunction: #tan.
]
{ #category : #'testing-arithmetic' }
-ArbitraryPrecisionFloatTest >> testZeroOne [
+PMArbitraryPrecisionFloatTest >> testZeroOne [
self assert: (312 asArbitraryPrecisionFloatNumBits: 53) one = 1.
self assert: (312 asArbitraryPrecisionFloatNumBits: 24) zero isZero.
@@ -857,6 +905,6 @@ ArbitraryPrecisionFloatTest >> testZeroOne [
]
{ #category : #'testing-trigonometry' }
-ArbitraryPrecisionFloatTest >> trigonometricSerie [
+PMArbitraryPrecisionFloatTest >> trigonometricSerie [
^(-720 to: 720) collect: [:i | i asFloat degreesToRadians]
]
diff --git a/src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st
deleted file mode 100644
index e2dc75af6..000000000
--- a/src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st
+++ /dev/null
@@ -1,338 +0,0 @@
-Class {
- #name : #DualNumberTest,
- #superclass : #TestCase,
- #instVars : [
- 'zero',
- 'one',
- 'three',
- 'zeroc',
- 'onec'
- ],
- #category : 'Math-Tests-AutomaticDifferenciation'
-}
-
-{ #category : #running }
-DualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [
- self assert: aDualNumber equals: anotherDualNumber.
- self assert: aDualNumber eps equals: anotherDualNumber eps
-]
-
-{ #category : #running }
-DualNumberTest >> setUp [
-zero:=PMDualNumber value: 0 eps: 1.
-zeroc:=PMDualNumber value: 0 eps: 0.
-one:=PMDualNumber value: 1 eps: 1.
-onec:=PMDualNumber value: 1.
-three :=PMDualNumber value: 3.0 eps: 1.
-
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testAbs [
-self assertEquality: three negated abs and:three .
-
-]
-
-{ #category : #tests }
-DualNumberTest >> testAccessing [
- self assert: three eps equals: 1.
- self assert: three value equals: 3.
- three value: 2.
- three eps: 2.
- self assert: three eps equals: 2.
- self assert: three value equals: 2
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testAdd [
-self assertEquality: 0+onec+0 and: onec .
-self assertEquality: 1+one+onec+0 and: three .
-self assertEquality: 1+one+one+three+1 and: (PMDualNumber value: 7 eps: 3).
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testArcCos [
-|a|
-self assert: (zero arcCos equalsTo:( PMDualNumber value: Float halfPi eps: -1)).
-a:=(PMDualNumber value: -1.0 successor eps: 1)arcCos.
-self assert:(a value equalsTo: Float pi).
-self assert:(a eps< -1e6).
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testArcSin [
- | a |
- self assert: zero arcSin equals: zero.
- a := (PMDualNumber value: 1.0 predecessor eps: 1) arcSin.
- self assert: (a value equalsTo: Float halfPi).
- self assert: a eps > 1e6.
- a := (PMDualNumber value: -0.5 eps: 1) arcSin.
- self assert: a value equals: -0.5 arcSin.
- self assert: a eps equals: 1 / (1 - 0.5 squared) sqrt
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testArcTan [
-self assertEquality: zero arcTan and: zero.
-self assertEquality: one negated arcTan and:(PMDualNumber value: -1 arcTan eps: (-1/2)).
-self assert: (three arcTan eps equalsTo:0.1).
-]
-
-{ #category : #tests }
-DualNumberTest >> testConverting [
- | a |
- self assert: zeroc asInteger == 0.
- self assert: three asInteger == 3.
- self assert: onec asFloat isFloat.
- self deny: onec isFloat.
- self assert: onec asFloat equals: 1.
- a := three negated asFloat.
- self assert: a isFloat.
- self assert: a equals: -3.
- self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testCos [
-self assert: ((PMDualNumber value: Float halfPi negated eps: 1)cos equalsTo: (PMDualNumber value: 0 eps: 1) ).
-self assert: ((PMDualNumber value: Float halfPi eps: 1)cos equalsTo: (PMDualNumber value: 0 eps: -1) ).
-self assert: ((PMDualNumber value: Float halfPi eps: 0)cos equalsTo: zeroc).
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testDivide [
-self should: [ 4.0/(one-1) ] raise:ZeroDivide.
-self should: [ three/(onec-1) ] raise:ZeroDivide.
-self assertEquality: three/onec and: three.
-self assertEquality: three/three and: onec.
-self assertEquality: 1/one and: (PMDualNumber value: 1 eps: -1).
-self assertEquality: 1/three reciprocal and: three.
-self assertEquality: 2/(three reciprocal) and: three*2.
-self assertEquality: 1/three and: (PMDualNumber value: (1/3)asFloat eps: (-1/9)asFloat).
-]
-
-{ #category : #'tests-testing' }
-DualNumberTest >> testEqual [
- self assert: one equals: onec.
- self assert: zero equals: zeroc.
- self assert: one equals: 1.0.
- self assert: three equals: 3.
- self assert: one ~= zero.
- self assert: 1.1 equals: (PMDualNumber value: 1.1 eps: 2).
- self assert: 1 / 3 equals: (PMDualNumber value: 1 / 3 eps: 2 / 3).
- self assert: 1 / 3.0 ~= (PMDualNumber value: 1 / 3 eps: 2) hash
-]
-
-{ #category : #tests }
-DualNumberTest >> testEqualsTo [
-self assert: (zeroc equalsTo: zeroc).
-self deny: (zeroc equalsTo: zero).
-self assert: (zero equalsTo: zero).
-self assert: (one equalsTo: (PMDualNumber value: 1.0000000001 eps:1.0000000001) ).
-self deny: (one equalsTo: (PMDualNumber value: 1.0000000001 eps:1.0000001) ).
-self deny: (one equalsTo: (PMDualNumber value: 1.0000001 eps:1.0000000001) ).
-self deny: (one equalsTo: (PMDualNumber value: 1.0000001 eps:1.0000001) ).
-
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testExp [
- | a b |
- b := 3 exp.
- a := three exp.
- self assert: (a eps equalsTo: b).
- self assert: a value equals: b.
- self assert: one equals: zero exp
-]
-
-{ #category : #tests }
-DualNumberTest >> testHash [
- self assert: one hash equals: onec hash.
- self assert: zero hash equals: zeroc hash.
- self assert: one hash equals: 1 hash.
- self assert: three hash equals: 3 hash.
- self assert: one hash ~= zero hash.
- self assert: 1.1 hash equals: (PMDualNumber value: 1.1 eps: 2) hash.
- self
- assert: (1 / 3) hash
- equals: (PMDualNumber value: 1 / 3 eps: 2 / 3) hash.
- self assert: 1 / 3.0 hash ~= (PMDualNumber value: 1 / 3 eps: 2) hash
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testLn [
- | a |
- a := three ln.
- self assert: (a eps equalsTo: 1 / 3).
- self assert: a value equals: 3 ln.
- self assert: one ln equals: zero
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testMultiply [
-self assertEquality: 0*onec and: zeroc .
-self assertEquality: three*0 and: zeroc.
-self assertEquality: onec*three and: three .
-self assertEquality: three*one and: (PMDualNumber value: 3 eps: 4).
-self assertEquality: (three+2.0)*(1+one) and: (PMDualNumber value: 10.0 eps: 7.0).
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testNegated [
- self assert: three negated equals: -3.
- self assert: three negated eps equals: -1
-]
-
-{ #category : #'tests-testing' }
-DualNumberTest >> testOpposites [
-self assert: zeroc even.
-self deny: one even.
-self deny: zero odd.
-self assert: three odd.
-self deny: zeroc odd.
-self assert: zeroc positive.
-self deny: zero negative.
-self assert: three positive.
-self assert: onec negated negative.
-
-
-
-
-
-]
-
-{ #category : #tests }
-DualNumberTest >> testPrintOn [
-|stream|
-stream := ReadWriteStream on: ''.
-three printOn: stream.
-self assert: (stream contents includesSubstring:' 3.0') .
-self assert: (stream contents includesSubstring:' 1') .
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testRaisedTo [
-|a |
-self assertEquality: (three raisedTo: 2) and: three squared.
-self assertEquality: (three raisedTo: 0) and: onec.
-self assertEquality: ((three + one) raisedTo: 1/2) and: (PMDualNumber value: 2 eps: (1/2)).
-self assert: (((three + one) raisedTo: 3/2) equalsTo: (PMDualNumber value: 8 eps: 6)).
-self assertEquality: (zero raisedTo: 1.4)and:zeroc.
-a:=2 raisedTo: three.
-self assert: ((a value)equalsTo: 8) .
-self assert: (a eps equalsTo: (2 ln* (2 raisedTo: 3))).
-self assertEquality: (1 raisedTo: three)and:onec.
-self assertEquality: (one raisedTo: one)and:one.
-a:=three raisedTo: three.
-self assert: ((a value)equalsTo: 27) .
-self assert: (a eps equalsTo: (3 raisedTo: 3)*(3 ln +1)).
-
-
-
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testRaisedToInteger [
-self assertEquality: (three raisedToInteger: 2) and: three squared.
-self assertEquality: (three raisedToInteger: 1)and: three.
-self assertEquality: (three raisedToInteger: 0)and: onec.
-self assertEquality: (three raisedToInteger: 4)and: (PMDualNumber value: 81 eps: 108).
-self assertEquality: (zero raisedToInteger: 4)and:zeroc.
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testReciprocal [
-self should: [ zero reciprocal ] raise:ZeroDivide.
-self should: [ zeroc reciprocal ] raise:ZeroDivide.
-self assertEquality: one reciprocal and: (PMDualNumber value: 1 eps: -1).
-self assertEquality: onec reciprocal and: onec.
-self assertEquality: three reciprocal and: (PMDualNumber value: (1/3.0) eps: -1/9.0).
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testSin [
-self assert: ((PMDualNumber value: Float halfPi negated eps: 1)sin equalsTo: (PMDualNumber value: -1.0 eps: 0.0) ).
-self assert: ((PMDualNumber value: Float halfPi eps: 1)sin equalsTo: (PMDualNumber value: 1.0 eps: 0.0) ).
-self assertEquality: zero sin and:zero.
-]
-
-{ #category : #'tests-testing' }
-DualNumberTest >> testSmaller [
-self assert: one<1.1.
-self deny: one<0.
-self assert: 1>zeroc.
-self deny: -0.1>zeroc.
-self deny: three<3.
-self assert: three<=3.
-self assert: 4>=three.
-self deny: three<=2.9.
-self deny: onec<=0.9.
-self assert: oneone.
-self deny: three> testSqrt [
- | a |
- self
- assertEquality: (PMDualNumber value: 16 eps: 5) sqrt
- and: (PMDualNumber value: 4 eps: 5 / 8).
- a := zero sqrt.
- self assert: a value equals: 0.
- self assert: a eps > 1e60
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testSquared [
-self assertEquality: (PMDualNumber value: -3 eps: 5) squared and: (PMDualNumber value: 9 eps: -30).
-self assertEquality: zero squared and: zeroc.
-]
-
-{ #category : #'tests-arithmetic' }
-DualNumberTest >> testSubtract [
-self assertEquality: 2-onec-1 and: zeroc .
-self assertEquality: three-one-1 and: onec .
-self assertEquality: 1-one-1 and: one negated.
-]
-
-{ #category : #'tests-mathematical functions' }
-DualNumberTest >> testTan [
- | a b |
- a := three tan.
- self assert: a value equals: 3 tan.
- self assert: (a eps equalsTo: 3 tan squared + 1).
- b := Float halfPi - 0.000000000001.
- a := (PMDualNumber value: b eps: 1) tan.
- self assert: a value equals: b tan.
- self assert: (a eps equalsTo: b tan squared + 1)
-]
-
-{ #category : #'tests-testing' }
-DualNumberTest >> testTesting [
-self deny: 3 isDualNumber .
-self assert: one isDualNumber.
-self assert: zeroc isDualNumber.
-self deny: three isInfinite .
-self assert: (PMDualNumber value: Float infinity negated eps: 3)isInfinite .
-self deny: three isNaN .
-self deny: zeroc isNaN .
-self assert: (PMDualNumber value: Float nan eps: 1)isNaN .
-self assert: onec isNumber.
-self assert: three isNumber.
-self assert: zeroc isZero.
-self assert: zero isZero.
-self deny: onec isZero.
-self deny: one isZero.
-
-
-
-
-
-]
diff --git a/src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st b/src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st
deleted file mode 100644
index d8b176078..000000000
--- a/src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st
+++ /dev/null
@@ -1,46 +0,0 @@
-Class {
- #name : #GradientAndHessianTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-AutomaticDifferenciation'
-}
-
-{ #category : #tests }
-GradientAndHessianTest >> test [
- | f g h r |
- f := [ :i |
- | x y |
- x := i first.
- y := i second.
- (x raisedToInteger: 3) + (x squared * y) - y squared - (4 * y) ].
- g := PMGradient of: f.
- h := PMHessian of: f.
- r := #(0 0).
- self assert: (g value: #(0 -2)) equals: r.
- self
- assert:
- (g
- value:
- {1.
- (-3 / 2)})
- equals: r.
- self assert: (g value: #(-4 6)) equals: r.
- self
- assert: (h value: #(0 -2))
- equals: (PMMatrix rows: #(#(-4 0) #(0 -2))).
- self assert: h gradient equals: r
-]
-
-{ #category : #tests }
-GradientAndHessianTest >> test2 [
-|f g h r|
-f := [:i||x y|x:=i first.y:=i second.
- (x exp + y exp )ln].
-g := PMGradient of: f.
-(h := PMHessian of: f)value:#(0 0).
-r:=#(0.5 0.5).
-self assert: ((g value:#(0 0))equalsTo:r).
-self assert: (h gradient equalsTo:r).
-r:=(-1 exp + 1 exp)reciprocal.
-self assert: ((g value:#(-1 1))equalsTo:(r * #(-1 1)exp)).
-self assert: (h result equalsTo: (PMMatrix rows: #((0.25 -0.25)(-0.25 0.25)))) .
-]
diff --git a/src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st
deleted file mode 100644
index 8300477a4..000000000
--- a/src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st
+++ /dev/null
@@ -1,399 +0,0 @@
-Class {
- #name : #HyperDualNumberTest,
- #superclass : #TestCase,
- #instVars : [
- 'zero',
- 'one',
- 'three',
- 'zeroc',
- 'onec'
- ],
- #category : 'Math-Tests-AutomaticDifferenciation'
-}
-
-{ #category : #running }
-HyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [
- self assert: aDualNumber equals: anotherDualNumber.
- self assert: aDualNumber exp equals: anotherDualNumber exp.
- self assert: aDualNumber eps2 equals: anotherDualNumber eps2.
- self assert: aDualNumber eps1eps2 equals: anotherDualNumber eps1eps2
-]
-
-{ #category : #running }
-HyperDualNumberTest >> setUp [
-zero:=PMHyperDualNumber value: 0 eps: 1 eps2: 1 eps1eps2: 0.
-zeroc:=PMHyperDualNumber value: 0 .
-one:=PMHyperDualNumber value: 1 eps: 1 eps2: 1 eps1eps2: 0.
-onec:=PMHyperDualNumber value: 1.
-three :=PMHyperDualNumber value: 3 eps: 1 eps2: 1 eps1eps2: 0.
-
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testAbs [
-self assertEquality: three negated abs and:three .
-
-]
-
-{ #category : #tests }
-HyperDualNumberTest >> testAccessing [
- self assert: three eps equals: 1.
- self assert: three value equals: 3.
- self assert: three eps2 equals: 1.
- self assert: three eps1eps2 equals: 0.
- three eps1eps2: 2.
- three eps2: 2.
- self assert: three eps2 == 2.
- self assert: three eps1eps2 equals: 2
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testAdd [
-self assertEquality: 0+onec+0 and: onec .
-self assertEquality: 1+one+onec+0 and: three .
-three eps1eps2: 2.
-self assertEquality: 1+one+one+three+1 and: (PMHyperDualNumber value: 7 eps: 3 eps2:3 eps1eps2:2).
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testArcCos [
-|a|
-self assert: (zero arcCos equalsTo:( PMHyperDualNumber value: Float halfPi eps: -1 eps2: -1 eps1eps2: 0)).
-a:=(PMHyperDualNumber value: 1.0 predecessor eps: 1 eps2: 1eps1eps2:0)arcCos.
-self assert:(a value closeTo: 0).
-self assert:(a eps< -1e6).
-self assert:(a eps2< -1e6).
-self assert:(a eps1eps2< -1e6).
-
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testArcSin [
- | a |
- self assert: zero arcSin equals: zero.
- a := (PMHyperDualNumber
- value: 1.0 predecessor
- eps: 1
- eps2: 1
- eps1eps2: 0) arcSin.
- self assert: (a value equalsTo: Float halfPi).
- self assert: a eps > 1e6.
- self assert: a eps2 > 1e6.
- self assert: a eps1eps2 > 1e6
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testArcTan [
- self assert: zero arcTan equals: zero.
- self
- assertEquality: one negated arcTan
- and:
- (PMHyperDualNumber
- value: -1 arcTan
- eps: -1 / 2
- eps2: -1 / 2
- eps1eps2: 1 / 2).
- self assert: (three arcTan eps2 equalsTo: 0.1).
- self assert: (three arcTan eps1eps2 equalsTo: -3 / 50)
-]
-
-{ #category : #tests }
-HyperDualNumberTest >> testConverting [
- | a |
- self assert: zeroc asInteger == 0.
- self assert: three asInteger == 3.
- self assert: onec asFloat isFloat.
- self deny: onec isFloat.
- self assert: onec asFloat equals: 1.
- a := three negated asFloat.
- self assert: a isFloat.
- self assert: a equals: -3.
- self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testCos [
-self assert: ((PMHyperDualNumber value: Float halfPi negated eps: 1 eps2:1 eps1eps2:0)cos equalsTo: zero).
-self assert: ((PMHyperDualNumber value: Float halfPi eps: 1 eps2:1 eps1eps2:0)cos equalsTo: zero negated ).
-self assert: ((PMHyperDualNumber value: Float halfPi)cos equalsTo: zeroc).
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testDivide [
-self should: [ 4.0/(one-1) ] raise:ZeroDivide.
-self should: [ three/(onec-1) ] raise:ZeroDivide.
-self assertEquality: three/onec and: three.
-self assertEquality: three/three and: onec.
-self assertEquality: 1/one and: ( PMHyperDualNumber value: 1 eps: -1 eps2: -1 eps1eps2: 2).
-self assertEquality: 1/three reciprocal and: three.
-self assertEquality: 2/(three reciprocal) and: three*2.
-self assertEquality: 1/three and: (PMHyperDualNumber value: 1/3 eps: -1/9 eps2: -1/9 eps1eps2: 2/27).
-]
-
-{ #category : #'tests-testing' }
-HyperDualNumberTest >> testEqual [
- self assert: one equals: onec.
- self assert: zero equals: zeroc.
- self assert: one equals: 1.0.
- self assert: three equals: 3.
- self assert: one ~= zero.
- self assert: 1.1 equals: (PMHyperDualNumber value: 1.1 eps: 2).
- self
- assert: 1 / 3
- equals:
- (PMHyperDualNumber
- value: 1 / 3
- eps: 2 / 3
- eps2: 5.4
- eps1eps2: 6.4).
- self assert: 1 / 3.0 ~= (PMHyperDualNumber value: 1 / 3) hash
-]
-
-{ #category : #tests }
-HyperDualNumberTest >> testEqualsTo [
-self assert: (zeroc equalsTo: zeroc).
-self deny: (zeroc equalsTo: zero).
-self assert: (zero equalsTo: zero).
-self assert: (one equalsTo: (PMHyperDualNumber value: 1.0000000001 eps: 1.0000000001 eps2: 1.0000000001 eps1eps2: 0.0000000001)).
-self deny: (one equalsTo: (PMHyperDualNumber value: 1.0000000001 eps: 1.0000000001 eps2: 1.0000000001 eps1eps2: 0.0000001)).
-self deny: (one equalsTo: (PMHyperDualNumber value: 1.0000000001 eps: 1.0000000001 eps2: 1.0000001 eps1eps2: 0.0000000001)).
-
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testExp [
- | a b |
- b := 3 exp.
- a := three exp.
- self assert: (a eps equalsTo: b).
- self assert: (a eps2 equalsTo: b).
- self assert: (a eps1eps2 equalsTo: b).
- self assert: a value equals: b.
- self assert: one equals: zero exp
-]
-
-{ #category : #tests }
-HyperDualNumberTest >> testHash [
- self assert: one hash equals: onec hash.
- self assert: zero hash equals: zeroc hash.
- self assert: one hash equals: 1 hash.
- self assert: three hash equals: 3 hash.
- self assert: one hash ~= zero hash.
- self
- assert: 1.1 hash
- equals:
- (PMHyperDualNumber
- value: 1.1
- eps: 2
- eps2: 0.8
- eps1eps2: 0.7) hash.
- self
- assert: (1 / 3) hash
- equals:
- (PMHyperDualNumber
- value: 1 / 3
- eps: 2 / 3
- eps2: 0.8
- eps1eps2: 0.7) hash.
- self assert: 1 / 3.0 hash ~= (PMHyperDualNumber value: 1 / 3) hash
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testLn [
- | a |
- a := three ln.
- self assert: (a eps equalsTo: 1 / 3).
- self assert: (a eps2 equalsTo: 1 / 3).
- self assert: (a eps1eps2 equalsTo: -1 / 9).
- self assert: a value equals: 3 ln.
- self assert: one ln equals: zero
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testMultiply [
-self assertEquality: 0*onec and: zeroc .
-self assertEquality: three*0 and: zeroc.
-self assertEquality: onec*three and: three .
-self assertEquality: three*one and: ( PMHyperDualNumber value: 3 eps: 4 eps2: 4 eps1eps2: 2).
-self assertEquality: (three+2.0)*(1+one) and: ( PMHyperDualNumber value: 10.0 eps: 7.0 eps2: 7.0 eps1eps2: 2.0).
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testNegated [
- three eps1eps2: -4.
- self assert: three negated equals: -3.
- self assert: three negated eps equals: -1.
- self assert: three negated eps2 equals: -1.
- self assert: three negated eps1eps2 equals: 4
-]
-
-{ #category : #'tests-testing' }
-HyperDualNumberTest >> testOpposites [
-self assert: zeroc even.
-self deny: one even.
-self deny: zero odd.
-self assert: three odd.
-self deny: zeroc odd.
-self assert: zeroc positive.
-self deny: zero negative.
-self assert: three positive.
-self assert: onec negated negative.
-
-
-
-
-
-]
-
-{ #category : #tests }
-HyperDualNumberTest >> testPrintOn [
-|stream|
-stream := ReadWriteStream on: ''.
-three printOn: stream.
-self assert: (stream contents includesSubstring:' 3') .
-self assert: (stream contents includesSubstring:' 1') .
-self assert: (stream contents includesSubstring:' 0') .
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testRaisedTo [
-|a b|
-self assert: ((three raisedTo: 2) equalsTo: three squared).
-self assertEquality: (three raisedTo: 0) and: onec.
-self assert: (((three + one) raisedTo: 1/2) equalsTo: (PMHyperDualNumber value: 2 eps: 1/2 eps2:1/2 eps1eps2: -1/8)).
-self assertEquality: (zero raisedTo: 1.4)and:zeroc.
-a:=2 raisedTo: three.
-self assert: ((a value)equalsTo: 8) .
-b:=2 ln* (2 raisedTo: 3).
-self assert: (a eps equalsTo: b).
-self assert: (a eps2 equalsTo: b).
-self assert: (a eps1eps2 equalsTo: (2 ln * b)).
-self assertEquality: (1 raisedTo: three)and:onec.
-self assert: ((one raisedTo: one)equalsTo: (PMHyperDualNumber value: 1 eps: 1 eps2: 1 eps1eps2: 2)).
-a:=three raisedTo: three.
-self assert: ((a value)equalsTo: 27) .
-b:=(3 ln+1)*27.
-self assert: (a eps equalsTo: b).
-self assert: (a eps2 equalsTo: b).
-self assert: (a eps1eps2 equalsTo: b*(3 ln+1)+9).
-
-
-
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testRaisedToInteger [
-self assertEquality: (three raisedToInteger: 2) and: three squared.
-self assertEquality: (three raisedToInteger: 1) and: three.
-self assertEquality: (three raisedToInteger: 0) and: onec.
-self assertEquality: (three raisedToInteger: 4) and: ( PMHyperDualNumber value: 81 eps: 108 eps2: 108 eps1eps2: 108).
-self assertEquality: (zero raisedToInteger: 4) and: zeroc.
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testReciprocal [
-self should: [ zero reciprocal ] raise:ZeroDivide.
-self should: [ zeroc reciprocal ] raise:ZeroDivide.
-self assertEquality: one reciprocal and: ( PMHyperDualNumber value: 1 eps: -1 eps2: -1 eps1eps2: 2).
-self assertEquality: onec reciprocal and: onec.
-self assertEquality: three reciprocal and: ( PMHyperDualNumber value: (1/3) eps: (-1/9) eps2: (-1/9) eps1eps2: (2/27)).
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testSin [
-self assert: ((PMHyperDualNumber value: Float halfPi negated eps: 1 eps2: 1 eps1eps2: 0)sin equalsTo: ( PMHyperDualNumber value: -1 eps: 0 eps2: 0 eps1eps2: 1)) .
-self assert: ((PMHyperDualNumber value: Float halfPi eps: 1 eps2: 1 eps1eps2: 0)sin equalsTo: (PMHyperDualNumber value: 1 eps: 0 eps2: 0 eps1eps2: -1) ).
-self assertEquality: zero sin and: zero.
-]
-
-{ #category : #'tests-testing' }
-HyperDualNumberTest >> testSmaller [
-self assert: one<1.1.
-self deny: one<0.
-self assert: 1>zeroc.
-self deny: -0.1>zeroc.
-self deny: three<3.
-self assert: three<=3.
-self assert: 4>=three.
-self deny: three<=2.9.
-self deny: onec<=0.9.
-self assert: oneone.
-self deny: three> testSqrt [
- | a |
- self
- assertEquality:
- (PMHyperDualNumber
- value: 16
- eps: 5
- eps2: 1
- eps1eps2: 0) sqrt
- and:
- (PMHyperDualNumber
- value: 4
- eps: 5 / 8
- eps2: 1 / 8
- eps1eps2: -5 / 256).
- a := zero sqrt.
- self assert: a value equals: 0.
- self assert: a eps > 1e60.
- self assert: a eps2 > 1e60.
- self assert: a eps1eps2 < 1e60
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testSquared [
-self assert: ((PMHyperDualNumber value: -3 eps: 5eps2: 1 eps1eps2: 0) squared equalsTo: (PMHyperDualNumber value: 9 eps: -30 eps2: -6 eps1eps2: 10)).
-zeroc eps1eps2: 2.
-self assertEquality: zero squared and: zeroc.
-]
-
-{ #category : #'tests-arithmetic' }
-HyperDualNumberTest >> testSubtract [
-self assertEquality: 2-onec-1 and: zeroc .
-self assertEquality: three-one-1 and: onec .
-self assertEquality: 1-one-1 and: one negated.
-]
-
-{ #category : #'tests-mathematical functions' }
-HyperDualNumberTest >> testTan [
- | a |
- a := three tan.
- self assert: a value equals: 3 tan.
- self assert: (a eps equalsTo: 3 tan squared + 1).
- self assert: (a eps equalsTo: a eps2).
- self assert: (a eps1eps2 equalsTo: -0.2908860399427)
-]
-
-{ #category : #'tests-testing' }
-HyperDualNumberTest >> testTesting [
-self deny: 3 isDualNumber .
-self assert: one isDualNumber.
-self assert: zeroc isDualNumber.
-self deny: three isInfinite .
-self assert: (PMHyperDualNumber value: Float infinity negated eps: 3 eps2: 0 eps1eps2:0)isInfinite .
-self deny: three isNaN .
-self deny: zeroc isNaN .
-self assert: (PMHyperDualNumber value: Float nan eps: 1)isNaN .
-self assert: onec isNumber.
-self assert: three isNumber.
-self assert: zeroc isZero.
-self assert: zero isZero.
-self deny: onec isZero.
-self deny: one isZero.
-
-
-
-
-
-]
diff --git a/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st
new file mode 100644
index 000000000..3809029b6
--- /dev/null
+++ b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st
@@ -0,0 +1,379 @@
+Class {
+ #name : #PMDualNumberTest,
+ #superclass : #TestCase,
+ #instVars : [
+ 'zero',
+ 'one',
+ 'three',
+ 'zeroc',
+ 'onec'
+ ],
+ #category : #'Math-Tests-AutomaticDifferenciation'
+}
+
+{ #category : #running }
+PMDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [
+ self assert: aDualNumber equals: anotherDualNumber.
+ self assert: aDualNumber eps equals: anotherDualNumber eps
+]
+
+{ #category : #running }
+PMDualNumberTest >> setUp [
+ zero := PMDualNumber value: 0 eps: 1.
+ zeroc := PMDualNumber value: 0 eps: 0.
+ one := PMDualNumber value: 1 eps: 1.
+ onec := PMDualNumber value: 1.
+ three := PMDualNumber value: 3.0 eps: 1
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testAbs [
+ self assertEquality: three negated abs and: three
+]
+
+{ #category : #tests }
+PMDualNumberTest >> testAccessing [
+ self assert: three eps equals: 1.
+ self assert: three value equals: 3.
+ three value: 2.
+ three eps: 2.
+ self assert: three eps equals: 2.
+ self assert: three value equals: 2
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testAdd [
+ self assertEquality: 0 + onec + 0 and: onec.
+ self assertEquality: 1 + one + onec + 0 and: three.
+ self
+ assertEquality: 1 + one + one + three + 1
+ and: (PMDualNumber value: 7 eps: 3)
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testArcCos [
+ | a |
+ self
+ assert: (zero arcCos equalsTo: (PMDualNumber value: Float halfPi eps: -1)).
+ a := (PMDualNumber value: -1.0 successor eps: 1) arcCos.
+ self assert: (a value equalsTo: Float pi).
+ self assert: a eps < -1e6
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testArcSin [
+ | a |
+ self assert: zero arcSin equals: zero.
+ a := (PMDualNumber value: 1.0 predecessor eps: 1) arcSin.
+ self assert: (a value equalsTo: Float halfPi).
+ self assert: a eps > 1e6.
+ a := (PMDualNumber value: -0.5 eps: 1) arcSin.
+ self assert: a value equals: -0.5 arcSin.
+ self assert: a eps equals: 1 / (1 - 0.5 squared) sqrt
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testArcTan [
+ self assertEquality: zero arcTan and: zero.
+ self
+ assertEquality: one negated arcTan
+ and: (PMDualNumber value: -1 arcTan eps: -1 / 2).
+ self assert: (three arcTan eps equalsTo: 0.1)
+]
+
+{ #category : #test }
+PMDualNumberTest >> testConjugated [
+ | a z |
+ z := PMDualNumber value: 1.0 + 1.0 i eps: 1.0.
+ a := z absSquared.
+ self assert: a value equals: z value absSquared.
+ self
+ assert: a eps
+ equals: z eps asComplex conjugated * z value + (z value asComplex conjugated * z eps)
+]
+
+{ #category : #tests }
+PMDualNumberTest >> testConverting [
+ | a |
+ self assert: zeroc asInteger == 0.
+ self assert: three asInteger == 3.
+ self assert: onec asFloat isFloat.
+ self deny: onec isFloat.
+ self assert: onec asFloat equals: 1.
+ a := three negated asFloat.
+ self assert: a isFloat.
+ self assert: a equals: -3.
+ self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testCos [
+ self
+ assert:
+ ((PMDualNumber value: Float halfPi negated eps: 1) cos
+ equalsTo: (PMDualNumber value: 0 eps: 1)).
+ self
+ assert:
+ ((PMDualNumber value: Float halfPi eps: 1) cos
+ equalsTo: (PMDualNumber value: 0 eps: -1)).
+ self
+ assert: ((PMDualNumber value: Float halfPi eps: 0) cos equalsTo: zeroc)
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testDerivatives [
+ "f(x) = x^3
+ f'(x) = 3*x^2"
+
+ | x y |
+ x := PMDualNumber value: 2 eps: 1.
+ y := x raisedTo: 3.
+ self assert: y value equals: (2.0 raisedTo: 3).
+ self assert: y eps equals: 3.0 * (x raisedTo: 2)
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testDivide [
+ self should: [ 4.0 / (one - 1) ] raise: ZeroDivide.
+ self should: [ three / (onec - 1) ] raise: ZeroDivide.
+ self assertEquality: three / onec and: three.
+ self assertEquality: three / three and: onec.
+ self assertEquality: 1 / one and: (PMDualNumber value: 1 eps: -1).
+ self assertEquality: 1 / three reciprocal and: three.
+ self assertEquality: 2 / three reciprocal and: three * 2.
+ self
+ assertEquality: 1 / three
+ and: (PMDualNumber value: (1 / 3) asFloat eps: (-1 / 9) asFloat)
+]
+
+{ #category : #'tests-testing' }
+PMDualNumberTest >> testEqual [
+ self assert: one equals: onec.
+ self assert: zero equals: zeroc.
+ self assert: one equals: 1.0.
+ self assert: three equals: 3.
+ self assert: one ~= zero.
+ self assert: 1.1 equals: (PMDualNumber value: 1.1 eps: 2).
+ self assert: 1 / 3 equals: (PMDualNumber value: 1 / 3 eps: 2 / 3).
+ self assert: 1 / 3.0 ~= (PMDualNumber value: 1 / 3 eps: 2) hash
+]
+
+{ #category : #tests }
+PMDualNumberTest >> testEqualsTo [
+ self assert: (zeroc equalsTo: zeroc).
+ self deny: (zeroc equalsTo: zero).
+ self assert: (zero equalsTo: zero).
+ self
+ assert: (one equalsTo: (PMDualNumber value: 1.0000000001 eps: 1.0000000001)).
+ self
+ deny: (one equalsTo: (PMDualNumber value: 1.0000000001 eps: 1.0000001)).
+ self
+ deny: (one equalsTo: (PMDualNumber value: 1.0000001 eps: 1.0000000001)).
+ self
+ deny: (one equalsTo: (PMDualNumber value: 1.0000001 eps: 1.0000001))
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testExp [
+ | a b |
+ b := 3 exp.
+ a := three exp.
+ self assert: (a eps equalsTo: b).
+ self assert: a value equals: b.
+ self assert: one equals: zero exp
+]
+
+{ #category : #tests }
+PMDualNumberTest >> testHash [
+ self assert: one hash equals: onec hash.
+ self assert: zero hash equals: zeroc hash.
+ self assert: one hash equals: 1 hash.
+ self assert: three hash equals: 3 hash.
+ self assert: one hash ~= zero hash.
+ self assert: 1.1 hash equals: (PMDualNumber value: 1.1 eps: 2) hash.
+ self
+ assert: (1 / 3) hash
+ equals: (PMDualNumber value: 1 / 3 eps: 2 / 3) hash.
+ self assert: 1 / 3.0 hash ~= (PMDualNumber value: 1 / 3 eps: 2) hash
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testLn [
+ | a |
+ a := three ln.
+ self assert: (a eps equalsTo: 1 / 3).
+ self assert: a value equals: 3 ln.
+ self assert: one ln equals: zero
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testMultiply [
+ self assertEquality: 0 * onec and: zeroc.
+ self assertEquality: three * 0 and: zeroc.
+ self assertEquality: onec * three and: three.
+ self assertEquality: three * one and: (PMDualNumber value: 3 eps: 4).
+ self
+ assertEquality: (three + 2.0) * (1 + one)
+ and: (PMDualNumber value: 10.0 eps: 7.0)
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testNegated [
+ self assert: three negated equals: -3.
+ self assert: three negated eps equals: -1
+]
+
+{ #category : #'tests-testing' }
+PMDualNumberTest >> testOpposites [
+ self assert: zeroc even.
+ self deny: one even.
+ self deny: zero odd.
+ self assert: three odd.
+ self deny: zeroc odd.
+ self assert: zeroc positive.
+ self deny: zero negative.
+ self assert: three positive.
+ self assert: onec negated negative
+]
+
+{ #category : #tests }
+PMDualNumberTest >> testPrintOn [
+ | stream |
+ stream := ReadWriteStream on: ''.
+ three printOn: stream.
+ self assert: (stream contents includesSubstring: ' 3.0').
+ self assert: (stream contents includesSubstring: ' 1')
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testRaisedTo [
+ | a |
+ self assertEquality: (three raisedTo: 2) and: three squared.
+ self assertEquality: (three raisedTo: 0) and: onec.
+ self
+ assertEquality: (three + one raisedTo: 1 / 2)
+ and: (PMDualNumber value: 2 eps: 1 / 2).
+ self
+ assert:
+ ((three + one raisedTo: 3 / 2)
+ equalsTo: (PMDualNumber value: 8 eps: 6)).
+ self assertEquality: (zero raisedTo: 1.4) and: zeroc.
+ a := 2 raisedTo: three.
+ self assert: (a value equalsTo: 8).
+ self assert: (a eps equalsTo: 2 ln * (2 raisedTo: 3)).
+ self assertEquality: (1 raisedTo: three) and: onec.
+ self assertEquality: (one raisedTo: one) and: one.
+ a := three raisedTo: three.
+ self assert: (a value equalsTo: 27).
+ self assert: (a eps equalsTo: (3 raisedTo: 3) * (3 ln + 1))
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testRaisedToInteger [
+ self assertEquality: (three raisedToInteger: 2) and: three squared.
+ self assertEquality: (three raisedToInteger: 1) and: three.
+ self assertEquality: (three raisedToInteger: 0) and: onec.
+ self
+ assertEquality: (three raisedToInteger: 4)
+ and: (PMDualNumber value: 81 eps: 108).
+ self assertEquality: (zero raisedToInteger: 4) and: zeroc
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testReciprocal [
+ self should: [ zero reciprocal ] raise: ZeroDivide.
+ self should: [ zeroc reciprocal ] raise: ZeroDivide.
+ self
+ assertEquality: one reciprocal
+ and: (PMDualNumber value: 1 eps: -1).
+ self assertEquality: onec reciprocal and: onec.
+ self
+ assertEquality: three reciprocal
+ and: (PMDualNumber value: 1 / 3.0 eps: -1 / 9.0)
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testSin [
+ self
+ assert:
+ ((PMDualNumber value: Float halfPi negated eps: 1) sin
+ equalsTo: (PMDualNumber value: -1.0 eps: 0.0)).
+ self
+ assert:
+ ((PMDualNumber value: Float halfPi eps: 1) sin
+ equalsTo: (PMDualNumber value: 1.0 eps: 0.0)).
+ self assertEquality: zero sin and: zero
+]
+
+{ #category : #'tests-testing' }
+PMDualNumberTest >> testSmaller [
+ self assert: one < 1.1.
+ self deny: one < 0.
+ self assert: 1 > zeroc.
+ self deny: -0.1 > zeroc.
+ self deny: three < 3.
+ self assert: three <= 3.
+ self assert: 4 >= three.
+ self deny: three <= 2.9.
+ self deny: onec <= 0.9.
+ self assert: one < three.
+ self assert: three > one.
+ self deny: three < three
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testSqrt [
+ | a |
+ self
+ assertEquality: (PMDualNumber value: 16 eps: 5) sqrt
+ and: (PMDualNumber value: 4 eps: 5 / 8).
+ a := zero sqrt.
+ self assert: a value equals: 0.
+ self assert: a eps > 1e60
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testSquared [
+ self
+ assertEquality: (PMDualNumber value: -3 eps: 5) squared
+ and: (PMDualNumber value: 9 eps: -30).
+ self assertEquality: zero squared and: zeroc
+]
+
+{ #category : #'tests-arithmetic' }
+PMDualNumberTest >> testSubtract [
+ self assertEquality: 2 - onec - 1 and: zeroc.
+ self assertEquality: three - one - 1 and: onec.
+ self assertEquality: 1 - one - 1 and: one negated
+]
+
+{ #category : #'tests-mathematical functions' }
+PMDualNumberTest >> testTan [
+ | a b |
+ a := three tan.
+ self assert: a value equals: 3 tan.
+ self assert: (a eps equalsTo: 3 tan squared + 1).
+ b := Float halfPi - 0.000000000001.
+ a := (PMDualNumber value: b eps: 1) tan.
+ self assert: a value equals: b tan.
+ self assert: (a eps equalsTo: b tan squared + 1)
+]
+
+{ #category : #'tests-testing' }
+PMDualNumberTest >> testTesting [
+ self deny: 3 isDualNumber.
+ self assert: one isDualNumber.
+ self assert: zeroc isDualNumber.
+ self deny: three isInfinite.
+ self
+ assert: (PMDualNumber value: Float infinity negated eps: 3) isInfinite.
+ self deny: three isNaN.
+ self deny: zeroc isNaN.
+ self assert: (PMDualNumber value: Float nan eps: 1) isNaN.
+ self assert: onec isNumber.
+ self assert: three isNumber.
+ self assert: zeroc isZero.
+ self assert: zero isZero.
+ self deny: onec isZero.
+ self deny: one isZero
+]
diff --git a/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st
new file mode 100644
index 000000000..33b7ca7be
--- /dev/null
+++ b/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st
@@ -0,0 +1,50 @@
+Class {
+ #name : #PMGradientAndHessianTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-AutomaticDifferenciation'
+}
+
+{ #category : #tests }
+PMGradientAndHessianTest >> test [
+ | f g h r |
+ f := [ :i |
+ | x y |
+ x := i first.
+ y := i second.
+ (x raisedToInteger: 3) + (x squared * y) - y squared - (4 * y) ].
+ g := PMGradient of: f.
+ h := PMHessian of: f.
+ r := #(0 0).
+ self assert: (g value: #(0 -2)) equals: r.
+ self
+ assert:
+ (g
+ value:
+ {1.
+ (-3 / 2)})
+ equals: r.
+ self assert: (g value: #(-4 6)) equals: r.
+ self
+ assert: (h value: #(0 -2))
+ equals: (PMMatrix rows: #(#(-4 0) #(0 -2))).
+ self assert: h gradient equals: r
+]
+
+{ #category : #tests }
+PMGradientAndHessianTest >> test2 [
+ | f g h r |
+ f := [ :i |
+ | x y |
+ x := i first.
+ y := i second.
+ (x exp + y exp) ln ].
+ g := PMGradient of: f.
+ (h := PMHessian of: f) value: #(0 0).
+ r := #(0.5 0.5).
+ self assert: ((g value: #(0 0)) equalsTo: r).
+ self assert: (h gradient equalsTo: r).
+ r := (-1 exp + 1 exp) reciprocal.
+ self assert: ((g value: #(-1 1)) equalsTo: r * #(-1 1) exp).
+ self
+ assert: (h result equalsTo: (PMMatrix rows: #(#(0.25 -0.25) #(-0.25 0.25))))
+]
diff --git a/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st
new file mode 100644
index 000000000..087ca9158
--- /dev/null
+++ b/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st
@@ -0,0 +1,552 @@
+Class {
+ #name : #PMHyperDualNumberTest,
+ #superclass : #TestCase,
+ #instVars : [
+ 'zero',
+ 'one',
+ 'three',
+ 'zeroc',
+ 'onec'
+ ],
+ #category : #'Math-Tests-AutomaticDifferenciation'
+}
+
+{ #category : #running }
+PMHyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [
+ self assert: aDualNumber equals: anotherDualNumber.
+ self assert: aDualNumber exp equals: anotherDualNumber exp.
+ self assert: aDualNumber eps2 equals: anotherDualNumber eps2.
+ self assert: aDualNumber eps1eps2 equals: anotherDualNumber eps1eps2
+]
+
+{ #category : #running }
+PMHyperDualNumberTest >> setUp [
+super setUp.
+ zero := PMHyperDualNumber
+ value: 0
+ eps: 1
+ eps2: 1
+ eps1eps2: 0.
+ zeroc := PMHyperDualNumber value: 0.
+ one := PMHyperDualNumber
+ value: 1
+ eps: 1
+ eps2: 1
+ eps1eps2: 0.
+ onec := PMHyperDualNumber value: 1.
+ three := PMHyperDualNumber
+ value: 3
+ eps: 1
+ eps2: 1
+ eps1eps2: 0
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testAbs [
+ self assertEquality: three negated abs and: three
+]
+
+{ #category : #tests }
+PMHyperDualNumberTest >> testAccessing [
+ self assert: three eps equals: 1.
+ self assert: three value equals: 3.
+ self assert: three eps2 equals: 1.
+ self assert: three eps1eps2 equals: 0.
+ three eps1eps2: 2.
+ three eps2: 2.
+ self assert: three eps2 == 2.
+ self assert: three eps1eps2 equals: 2
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testAdd [
+ self assertEquality: 0 + onec + 0 and: onec.
+ self assertEquality: 1 + one + onec + 0 and: three.
+ three eps1eps2: 2.
+ self
+ assertEquality: 1 + one + one + three + 1
+ and:
+ (PMHyperDualNumber
+ value: 7
+ eps: 3
+ eps2: 3
+ eps1eps2: 2)
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testArcCos [
+ | a |
+ self
+ assert:
+ (zero arcCos
+ equalsTo:
+ (PMHyperDualNumber
+ value: Float halfPi
+ eps: -1
+ eps2: -1
+ eps1eps2: 0)).
+ a := (PMHyperDualNumber
+ value: 1.0 predecessor
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) arcCos.
+ self assert: (a value closeTo: 0).
+ self assert: a eps < -1e6.
+ self assert: a eps2 < -1e6.
+ self assert: a eps1eps2 < -1e6
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testArcSin [
+ | a |
+ self assert: zero arcSin equals: zero.
+ a := (PMHyperDualNumber
+ value: 1.0 predecessor
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) arcSin.
+ self assert: (a value equalsTo: Float halfPi).
+ self assert: a eps > 1e6.
+ self assert: a eps2 > 1e6.
+ self assert: a eps1eps2 > 1e6
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testArcTan [
+ self assert: zero arcTan equals: zero.
+ self
+ assertEquality: one negated arcTan
+ and:
+ (PMHyperDualNumber
+ value: -1 arcTan
+ eps: -1 / 2
+ eps2: -1 / 2
+ eps1eps2: 1 / 2).
+ self assert: (three arcTan eps2 equalsTo: 0.1).
+ self assert: (three arcTan eps1eps2 equalsTo: -3 / 50)
+]
+
+{ #category : #tests }
+PMHyperDualNumberTest >> testConverting [
+ | a |
+ self assert: zeroc asInteger == 0.
+ self assert: three asInteger == 3.
+ self assert: onec asFloat isFloat.
+ self deny: onec isFloat.
+ self assert: onec asFloat equals: 1.
+ a := three negated asFloat.
+ self assert: a isFloat.
+ self assert: a equals: -3.
+ self assert: (PMDualNumber value: -3.7 eps: 2) asInteger == -3
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testCos [
+ self
+ assert:
+ ((PMHyperDualNumber
+ value: Float halfPi negated
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) cos equalsTo: zero).
+ self
+ assert:
+ ((PMHyperDualNumber
+ value: Float halfPi
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) cos equalsTo: zero negated).
+ self
+ assert: ((PMHyperDualNumber value: Float halfPi) cos equalsTo: zeroc)
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testDivide [
+ self should: [ 4.0 / (one - 1) ] raise: ZeroDivide.
+ self should: [ three / (onec - 1) ] raise: ZeroDivide.
+ self assertEquality: three / onec and: three.
+ self assertEquality: three / three and: onec.
+ self
+ assertEquality: 1 / one
+ and:
+ (PMHyperDualNumber
+ value: 1
+ eps: -1
+ eps2: -1
+ eps1eps2: 2).
+ self assertEquality: 1 / three reciprocal and: three.
+ self assertEquality: 2 / three reciprocal and: three * 2.
+ self
+ assertEquality: 1 / three
+ and:
+ (PMHyperDualNumber
+ value: 1 / 3
+ eps: -1 / 9
+ eps2: -1 / 9
+ eps1eps2: 2 / 27)
+]
+
+{ #category : #'tests-testing' }
+PMHyperDualNumberTest >> testEqual [
+ self assert: one equals: onec.
+ self assert: zero equals: zeroc.
+ self assert: one equals: 1.0.
+ self assert: three equals: 3.
+ self assert: one ~= zero.
+ self assert: 1.1 equals: (PMHyperDualNumber value: 1.1 eps: 2).
+ self
+ assert: 1 / 3
+ equals:
+ (PMHyperDualNumber
+ value: 1 / 3
+ eps: 2 / 3
+ eps2: 5.4
+ eps1eps2: 6.4).
+ self assert: 1 / 3.0 ~= (PMHyperDualNumber value: 1 / 3) hash
+]
+
+{ #category : #tests }
+PMHyperDualNumberTest >> testEqualsTo [
+ self assert: (zeroc equalsTo: zeroc).
+ self deny: (zeroc equalsTo: zero).
+ self assert: (zero equalsTo: zero).
+ self
+ assert:
+ (one
+ equalsTo:
+ (PMHyperDualNumber
+ value: 1.0000000001
+ eps: 1.0000000001
+ eps2: 1.0000000001
+ eps1eps2: 0.0000000001)).
+ self
+ deny:
+ (one
+ equalsTo:
+ (PMHyperDualNumber
+ value: 1.0000000001
+ eps: 1.0000000001
+ eps2: 1.0000000001
+ eps1eps2: 0.0000001)).
+ self
+ deny:
+ (one
+ equalsTo:
+ (PMHyperDualNumber
+ value: 1.0000000001
+ eps: 1.0000000001
+ eps2: 1.0000001
+ eps1eps2: 0.0000000001))
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testExp [
+ | a b |
+ b := 3 exp.
+ a := three exp.
+ self assert: (a eps equalsTo: b).
+ self assert: (a eps2 equalsTo: b).
+ self assert: (a eps1eps2 equalsTo: b).
+ self assert: a value equals: b.
+ self assert: one equals: zero exp
+]
+
+{ #category : #tests }
+PMHyperDualNumberTest >> testHash [
+ self assert: one hash equals: onec hash.
+ self assert: zero hash equals: zeroc hash.
+ self assert: one hash equals: 1 hash.
+ self assert: three hash equals: 3 hash.
+ self assert: one hash ~= zero hash.
+ self
+ assert: 1.1 hash
+ equals:
+ (PMHyperDualNumber
+ value: 1.1
+ eps: 2
+ eps2: 0.8
+ eps1eps2: 0.7) hash.
+ self
+ assert: (1 / 3) hash
+ equals:
+ (PMHyperDualNumber
+ value: 1 / 3
+ eps: 2 / 3
+ eps2: 0.8
+ eps1eps2: 0.7) hash.
+ self assert: 1 / 3.0 hash ~= (PMHyperDualNumber value: 1 / 3) hash
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testLn [
+ | a |
+ a := three ln.
+ self assert: (a eps equalsTo: 1 / 3).
+ self assert: (a eps2 equalsTo: 1 / 3).
+ self assert: (a eps1eps2 equalsTo: -1 / 9).
+ self assert: a value equals: 3 ln.
+ self assert: one ln equals: zero
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testMultiply [
+ self assertEquality: 0 * onec and: zeroc.
+ self assertEquality: three * 0 and: zeroc.
+ self assertEquality: onec * three and: three.
+ self
+ assertEquality: three * one
+ and:
+ (PMHyperDualNumber
+ value: 3
+ eps: 4
+ eps2: 4
+ eps1eps2: 2).
+ self
+ assertEquality: (three + 2.0) * (1 + one)
+ and:
+ (PMHyperDualNumber
+ value: 10.0
+ eps: 7.0
+ eps2: 7.0
+ eps1eps2: 2.0)
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testNegated [
+ three eps1eps2: -4.
+ self assert: three negated equals: -3.
+ self assert: three negated eps equals: -1.
+ self assert: three negated eps2 equals: -1.
+ self assert: three negated eps1eps2 equals: 4
+]
+
+{ #category : #'tests-testing' }
+PMHyperDualNumberTest >> testOpposites [
+ self assert: zeroc even.
+ self deny: one even.
+ self deny: zero odd.
+ self assert: three odd.
+ self deny: zeroc odd.
+ self assert: zeroc positive.
+ self deny: zero negative.
+ self assert: three positive.
+ self assert: onec negated negative
+]
+
+{ #category : #tests }
+PMHyperDualNumberTest >> testPrintOn [
+ | stream |
+ stream := ReadWriteStream on: ''.
+ three printOn: stream.
+ self assert: (stream contents includesSubstring: ' 3').
+ self assert: (stream contents includesSubstring: ' 1').
+ self assert: (stream contents includesSubstring: ' 0')
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testRaisedTo [
+ | a b |
+ self assert: ((three raisedTo: 2) equalsTo: three squared).
+ self assertEquality: (three raisedTo: 0) and: onec.
+ self
+ assert:
+ ((three + one raisedTo: 1 / 2)
+ equalsTo:
+ (PMHyperDualNumber
+ value: 2
+ eps: 1 / 2
+ eps2: 1 / 2
+ eps1eps2: -1 / 8)).
+ self assertEquality: (zero raisedTo: 1.4) and: zeroc.
+ a := 2 raisedTo: three.
+ self assert: (a value equalsTo: 8).
+ b := 2 ln * (2 raisedTo: 3).
+ self assert: (a eps equalsTo: b).
+ self assert: (a eps2 equalsTo: b).
+ self assert: (a eps1eps2 equalsTo: 2 ln * b).
+ self assertEquality: (1 raisedTo: three) and: onec.
+ self
+ assert:
+ ((one raisedTo: one)
+ equalsTo:
+ (PMHyperDualNumber
+ value: 1
+ eps: 1
+ eps2: 1
+ eps1eps2: 2)).
+ a := three raisedTo: three.
+ self assert: (a value equalsTo: 27).
+ b := (3 ln + 1) * 27.
+ self assert: (a eps equalsTo: b).
+ self assert: (a eps2 equalsTo: b).
+ self assert: (a eps1eps2 equalsTo: b * (3 ln + 1) + 9)
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testRaisedToInteger [
+ self assertEquality: (three raisedToInteger: 2) and: three squared.
+ self assertEquality: (three raisedToInteger: 1) and: three.
+ self assertEquality: (three raisedToInteger: 0) and: onec.
+ self
+ assertEquality: (three raisedToInteger: 4)
+ and:
+ (PMHyperDualNumber
+ value: 81
+ eps: 108
+ eps2: 108
+ eps1eps2: 108).
+ self assertEquality: (zero raisedToInteger: 4) and: zeroc
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testReciprocal [
+ self should: [ zero reciprocal ] raise: ZeroDivide.
+ self should: [ zeroc reciprocal ] raise: ZeroDivide.
+ self
+ assertEquality: one reciprocal
+ and:
+ (PMHyperDualNumber
+ value: 1
+ eps: -1
+ eps2: -1
+ eps1eps2: 2).
+ self assertEquality: onec reciprocal and: onec.
+ self
+ assertEquality: three reciprocal
+ and:
+ (PMHyperDualNumber
+ value: 1 / 3
+ eps: -1 / 9
+ eps2: -1 / 9
+ eps1eps2: 2 / 27)
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testSin [
+ self
+ assert:
+ ((PMHyperDualNumber
+ value: Float halfPi negated
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) sin
+ equalsTo:
+ (PMHyperDualNumber
+ value: -1
+ eps: 0
+ eps2: 0
+ eps1eps2: 1)).
+ self
+ assert:
+ ((PMHyperDualNumber
+ value: Float halfPi
+ eps: 1
+ eps2: 1
+ eps1eps2: 0) sin
+ equalsTo:
+ (PMHyperDualNumber
+ value: 1
+ eps: 0
+ eps2: 0
+ eps1eps2: -1)).
+ self assertEquality: zero sin and: zero
+]
+
+{ #category : #'tests-testing' }
+PMHyperDualNumberTest >> testSmaller [
+ self assert: one < 1.1.
+ self deny: one < 0.
+ self assert: 1 > zeroc.
+ self deny: -0.1 > zeroc.
+ self deny: three < 3.
+ self assert: three <= 3.
+ self assert: 4 >= three.
+ self deny: three <= 2.9.
+ self deny: onec <= 0.9.
+ self assert: one < three.
+ self assert: three > one.
+ self deny: three < three
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testSqrt [
+ | a |
+ self
+ assertEquality:
+ (PMHyperDualNumber
+ value: 16
+ eps: 5
+ eps2: 1
+ eps1eps2: 0) sqrt
+ and:
+ (PMHyperDualNumber
+ value: 4
+ eps: 5 / 8
+ eps2: 1 / 8
+ eps1eps2: -5 / 256).
+ a := zero sqrt.
+ self assert: a value equals: 0.
+ self assert: a eps > 1e60.
+ self assert: a eps2 > 1e60.
+ self assert: a eps1eps2 < 1e60
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testSquared [
+ self
+ assert:
+ ((PMHyperDualNumber
+ value: -3
+ eps: 5
+ eps2: 1
+ eps1eps2: 0) squared
+ equalsTo:
+ (PMHyperDualNumber
+ value: 9
+ eps: -30
+ eps2: -6
+ eps1eps2: 10)).
+ zeroc eps1eps2: 2.
+ self assertEquality: zero squared and: zeroc
+]
+
+{ #category : #'tests-arithmetic' }
+PMHyperDualNumberTest >> testSubtract [
+ self assertEquality: 2 - onec - 1 and: zeroc.
+ self assertEquality: three - one - 1 and: onec.
+ self assertEquality: 1 - one - 1 and: one negated
+]
+
+{ #category : #'tests-mathematical functions' }
+PMHyperDualNumberTest >> testTan [
+ | a |
+ a := three tan.
+ self assert: a value equals: 3 tan.
+ self assert: (a eps equalsTo: 3 tan squared + 1).
+ self assert: (a eps equalsTo: a eps2).
+ self assert: (a eps1eps2 equalsTo: -0.2908860399427)
+]
+
+{ #category : #'tests-testing' }
+PMHyperDualNumberTest >> testTesting [
+ self deny: 3 isDualNumber.
+ self assert: one isDualNumber.
+ self assert: zeroc isDualNumber.
+ self deny: three isInfinite.
+ self
+ assert:
+ (PMHyperDualNumber
+ value: Float infinity negated
+ eps: 3
+ eps2: 0
+ eps1eps2: 0) isInfinite.
+ self deny: three isNaN.
+ self deny: zeroc isNaN.
+ self assert: (PMHyperDualNumber value: Float nan eps: 1) isNaN.
+ self assert: onec isNumber.
+ self assert: three isNumber.
+ self assert: zeroc isZero.
+ self assert: zero isZero.
+ self deny: onec isZero.
+ self deny: one isZero
+]
diff --git a/src/Math-Tests-Complex/PMComplexTest.class.st b/src/Math-Tests-Complex/PMComplexTest.class.st
index 6d9740bb5..4e586c2f9 100644
--- a/src/Math-Tests-Complex/PMComplexTest.class.st
+++ b/src/Math-Tests-Complex/PMComplexTest.class.st
@@ -409,14 +409,6 @@ PMComplexTest >> testOne [
self assert: one imaginary equals: 0
]
-{ #category : #tests }
-PMComplexTest >> testPrintOn [
- | c |
- c := (1 + 2 i).
- Transcript show: 'ComplexTest>>testPrintOn' ; cr; show: c ; cr.
-
-]
-
{ #category : #tests }
PMComplexTest >> testProductWithVector [
| v c |
diff --git a/src/Math-Tests-DHB-wk/PMFixpointTest.class.st b/src/Math-Tests-Core-Process/PMFixpointTest.class.st
similarity index 98%
rename from src/Math-Tests-DHB-wk/PMFixpointTest.class.st
rename to src/Math-Tests-Core-Process/PMFixpointTest.class.st
index fcad3f2bc..968315e02 100644
--- a/src/Math-Tests-DHB-wk/PMFixpointTest.class.st
+++ b/src/Math-Tests-Core-Process/PMFixpointTest.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'fp'
],
- #category : 'Math-Tests-DHB-wk'
+ #category : #'Math-Tests-Core-Process'
}
{ #category : #running }
diff --git a/src/Math-Tests-Core-Process/package.st b/src/Math-Tests-Core-Process/package.st
new file mode 100644
index 000000000..0de537ce7
--- /dev/null
+++ b/src/Math-Tests-Core-Process/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-Core-Process' }
diff --git a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st
similarity index 70%
rename from src/Math-Tests-DHB-Numerical/PMVectorTest.class.st
rename to src/Math-Tests-Core/PMVectorTest.class.st
index a1893c6ab..5ee2228ee 100644
--- a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st
+++ b/src/Math-Tests-Core/PMVectorTest.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMVectorTest,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Core'
}
{ #category : #tests }
@@ -34,11 +34,62 @@ PMVectorTest >> testAddToScalar [
self assert: actual equals: expected.
]
+{ #category : #tests }
+PMVectorTest >> testArgMax [
+ | v1 v2 |
+ v1 := #(1 5 3 2 0) asPMVector.
+ v2 := #(1 5 3 5 0) asPMVector.
+ self assert: v1 argMax equals: 2.
+ self assert: v2 argMax equals: 2
+]
+
+{ #category : #tests }
+PMVectorTest >> testArgMaxWithVectorOverReals [
+ "For vectors over a field of real numbers"
+
+ | v1 v2 |
+ v1 := #(1.3 5.001 3.1 2.0 0.2) asPMVector.
+ v2 := #(1.2 15.0000000200 3.14 15.0000000201 0.1) asPMVector.
+ self assert: v1 argMax equals: 2.
+ self assert: v2 argMax equals: 4
+]
+
{ #category : #tests }
PMVectorTest >> testAsArray [
self assert: #(1 2 3 4) asPMVector asArray equals: #(1 2 3 4)
]
+{ #category : #tests }
+PMVectorTest >> testGreaterThan [
+ | vec vecCopy |
+ vec := #(1 2 3) asPMVector.
+ vecCopy := vec deepCopy.
+ self assert: (vec > 1.5) equals: #(false true true) asPMVector.
+ "Ensure that in-place modification does not take place"
+ self assert: vec equals: vecCopy asPMVector.
+]
+
+{ #category : #tests }
+PMVectorTest >> testLessThan [
+ | vec vecCopy |
+ vec := #(1 2 3) asPMVector.
+ vecCopy := vec deepCopy.
+ self assert: (vec < 1.5) equals: #(true false false) asPMVector.
+ "Ensure that in-place modification does not take place"
+ self assert: vec equals: vecCopy asPMVector.
+]
+
+{ #category : #tests }
+PMVectorTest >> testMatrixConversionWithBothDims [
+ | vect result expected |
+ vect := #(1 0.5 0.2 3 1 -1 7 3 2 12 13 3) asPMVector .
+ result := vect reshapeWithDimensions: #(6 2).
+
+ expected := PMMatrix rows: #(#(1 0.5) #(0.2 3) #(1 -1) #(7 3) #(2 12) #(13 3)).
+
+ self assert: result equals: expected.
+]
+
{ #category : #tests }
PMVectorTest >> testScalarProduct [
| u v |
@@ -73,6 +124,36 @@ PMVectorTest >> testScalarProductIsCommutative [
self assert: (u scalarProduct: v) equals: (v scalarProduct: u)
]
+{ #category : #tests }
+PMVectorTest >> testSubFromScalar [
+ "Can we subtract PMVector from a Number?"
+
+ | num vec actual expected |
+
+ num := 4.
+ vec := #(1 2 3) asPMVector.
+
+ actual := num - vec.
+ expected := #(3 2 1) asPMVector.
+
+ self assert: actual equals: expected.
+]
+
+{ #category : #tests }
+PMVectorTest >> testSubtractScalar [
+ "Can we subtract Number from PMVector?"
+
+ | vec num actual expected |
+
+ vec := #(5 6 7) asPMVector.
+ num := 4.
+
+ actual := vec - num.
+ expected := #(1 2 3) asPMVector.
+
+ self assert: actual equals: expected.
+]
+
{ #category : #tests }
PMVectorTest >> testTensorProduct [
| a b c |
@@ -117,20 +198,6 @@ PMVectorTest >> testVectorCumulativeSum [
self assert: (w at: 3) equals: 6
]
-{ #category : #tests }
-PMVectorTest >> testVectorDotProduct [
- "Code Example 8.1"
-
- | u v w |
- u := #(1 2 3) asPMVector.
- v := #(3 4 5) asPMVector.
- w := u dot: v.
- self assert: (w size) equals: 3.
- self assert: (w at: 1) equals: 3.
- self assert: (w at: 2) equals: 8.
- self assert: (w at: 3) equals: 15
-]
-
{ #category : #tests }
PMVectorTest >> testVectorGreater [
@@ -144,6 +211,20 @@ PMVectorTest >> testVectorGreater [
]
+{ #category : #tests }
+PMVectorTest >> testVectorHadamardProduct [
+ "Code Example 8.1"
+
+ | u v w |
+ u := #(1 2 3) asPMVector.
+ v := #(3 4 5) asPMVector.
+ w := u hadamardProduct: v.
+ self assert: (w size) equals: 3.
+ self assert: (w at: 1) equals: 3.
+ self assert: (w at: 2) equals: 8.
+ self assert: (w at: 3) equals: 15
+]
+
{ #category : #tests }
PMVectorTest >> testVectorLess [
@@ -249,6 +330,17 @@ PMVectorTest >> testVectorSum [
self assert: (u sum) equals: 6.
]
+{ #category : #tests }
+PMVectorTest >> testVectorToVectorConversion [
+ | vect result expected |
+ vect := #(1 0.5 0.2 3 1 -1 7 3 2 12 13 3) asPMVector .
+ result := vect reshapeWithDimensions: #(1 12).
+
+ expected := PMMatrix rows: #(#(1 0.5 0.2 3 1 -1 7 3 2 12 13 3)).
+
+ self assert: result equals: expected.
+]
+
{ #category : #tests }
PMVectorTest >> testVectorZeros [
| v |
diff --git a/src/Math-Tests-Core/package.st b/src/Math-Tests-Core/package.st
new file mode 100644
index 000000000..8f219b1d8
--- /dev/null
+++ b/src/Math-Tests-Core/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-Core' }
diff --git a/src/Math-Tests-DHB-Numerical/package.st b/src/Math-Tests-DHB-Numerical/package.st
deleted file mode 100644
index 6e59b756c..000000000
--- a/src/Math-Tests-DHB-Numerical/package.st
+++ /dev/null
@@ -1 +0,0 @@
-Package { #name : #'Math-Tests-DHB-Numerical' }
diff --git a/src/Math-Tests-DHB-wk/package.st b/src/Math-Tests-DHB-wk/package.st
deleted file mode 100644
index f55e585c4..000000000
--- a/src/Math-Tests-DHB-wk/package.st
+++ /dev/null
@@ -1 +0,0 @@
-Package { #name : #'Math-Tests-DHB-wk' }
diff --git a/src/Math-Tests-FastFourierTransform/TestFFT.class.st b/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st
similarity index 93%
rename from src/Math-Tests-FastFourierTransform/TestFFT.class.st
rename to src/Math-Tests-FastFourierTransform/PMFFTTest.class.st
index 20ff1512f..a8b40e40d 100644
--- a/src/Math-Tests-FastFourierTransform/TestFFT.class.st
+++ b/src/Math-Tests-FastFourierTransform/PMFFTTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #TestFFT,
+ #name : #PMFFTTest,
#superclass : #TestCase,
- #category : 'Math-Tests-FastFourierTransform'
+ #category : #'Math-Tests-FastFourierTransform'
}
{ #category : #tests }
-TestFFT >> testBitReverse [
+PMFFTTest >> testBitReverse [
self should: [ 1 bitReverse: 0 ] raise: Error.
self should: [ 2 bitReverse: 1 ] raise: Error.
self assert: (0 bitReverse: 0) equals: 0.
@@ -21,7 +21,7 @@ TestFFT >> testBitReverse [
]
{ #category : #tests }
-TestFFT >> testFFT [
+PMFFTTest >> testFFT [
| data data1 f s |
data := (1 to: 256)
collect: [ :i | (Float pi * (i - 1) / (256 / 8)) cos ].
diff --git a/src/Math-Tests-FunctionFit/ErrorMinimizerTest.class.st b/src/Math-Tests-FunctionFit/ErrorMinimizerTest.class.st
deleted file mode 100644
index 998d925f3..000000000
--- a/src/Math-Tests-FunctionFit/ErrorMinimizerTest.class.st
+++ /dev/null
@@ -1,22 +0,0 @@
-"
-ErrorMinimizerTest tests indirectly also ErrorAsParameterFunction.
-"
-Class {
- #name : #ErrorMinimizerTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-FunctionFit'
-}
-
-{ #category : #tests }
-ErrorMinimizerTest >> testErrorMinimzer [
-|f col er fit|
-f:=[:x :a :b|a*x / (b+x)].
-col:=(0 to: 20)collect: [:i|i@(f cull: i cull: 2 cull: 0.4) ].
-er:=PMErrorOfParameterFunction function: f data: col.
-er errorType: #insensitive.
-er quartile: 0.9.
-fit:= PMErrorMinimizer function: er.
-fit evaluate .
-self assert: (fit maxFunction>2) .
-self assert: (fit parameters equalsTo: #(2 0.4))
-]
diff --git a/src/Math-Tests-FunctionFit/AnotherChromosomeManagerTest.class.st b/src/Math-Tests-FunctionFit/PMAnotherChromosomeManagerTest.class.st
similarity index 89%
rename from src/Math-Tests-FunctionFit/AnotherChromosomeManagerTest.class.st
rename to src/Math-Tests-FunctionFit/PMAnotherChromosomeManagerTest.class.st
index 20ea24809..9a5ed0d14 100644
--- a/src/Math-Tests-FunctionFit/AnotherChromosomeManagerTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMAnotherChromosomeManagerTest.class.st
@@ -1,14 +1,14 @@
Class {
- #name : #AnotherChromosomeManagerTest,
+ #name : #PMAnotherChromosomeManagerTest,
#superclass : #TestCase,
#instVars : [
'cm'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-AnotherChromosomeManagerTest >> setHammersleyTest: aBoolean [
+PMAnotherChromosomeManagerTest >> setHammersleyTest: aBoolean [
cm useHammersley: aBoolean.
cm randomizePopulation.
self assert: cm isFullyPopulated.
@@ -24,19 +24,19 @@ AnotherChromosomeManagerTest >> setHammersleyTest: aBoolean [
]
{ #category : #running }
-AnotherChromosomeManagerTest >> setUp [
+PMAnotherChromosomeManagerTest >> setUp [
cm:=(PMAnotherChromosomeManager origin: #(0 1) range: #( 2 3)).
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testAccessing [
+PMAnotherChromosomeManagerTest >> testAccessing [
self assert: cm range equals: #(2 3).
self assert: cm populationSize equals: 100.
self deny: cm isFullyPopulated
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testCrossOver [
+PMAnotherChromosomeManagerTest >> testCrossOver [
|a|
1 to: 20 do: [:i| a:=cm crossover: #(1 2 3) and: #(4 5 6).
1 to:2 do:[:index|
@@ -52,7 +52,7 @@ self assert: ((a occurrencesOf: #(1 2 3))<20).
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testEirCrossOver [
+PMAnotherChromosomeManagerTest >> testEirCrossOver [
|a|
a :=(1 to: 200)collect: [:i| a:=cm eirCrossover: #(1.0 3.0) and: #(5.0 1.0).
self assert: (((a at: 1)at:1) between: -1 and: 7).
@@ -79,7 +79,7 @@ self shouldnt: [a:=cm eirCrossover: #(1 -3) and: #(1 -3)] raise: Error.
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testIntegerDigits [
+PMAnotherChromosomeManagerTest >> testIntegerDigits [
self
assert: (PMAnotherChromosomeManager integerDigitsFor: 0 base: 2)
equals: #(0).
@@ -98,7 +98,7 @@ AnotherChromosomeManagerTest >> testIntegerDigits [
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testMutateProbabilistic [
+PMAnotherChromosomeManagerTest >> testMutateProbabilistic [
|a f s|
a:=(1 to: 100)collect: [:i| cm mutate: #(-4 4)].
f:=a collect: [:i|i first].
@@ -122,7 +122,7 @@ self assert: (s size between: 3 and: 20).
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testPrint [
+PMAnotherChromosomeManagerTest >> testPrint [
|aStream s|
aStream :=ReadWriteStream with:''.
cm printOn: aStream .
@@ -133,7 +133,7 @@ self assert: (s includesSubstring: '#(2 3)').
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testProcessand [
+PMAnotherChromosomeManagerTest >> testProcessand [
cm reset.
1 to: 60 do: [ :i | cm process: #(0 0) and: #(1 1) ].
self assert: (cm population select: [ :i | i = #(0 0) ]) size < 15.
@@ -144,7 +144,7 @@ AnotherChromosomeManagerTest >> testProcessand [
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testRandomizePopulation [
+PMAnotherChromosomeManagerTest >> testRandomizePopulation [
|g|
self setHammersleyTest: true.
g :=cm population first.
@@ -157,7 +157,7 @@ self deny: (cm population first =g).
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testRateSetting [
+PMAnotherChromosomeManagerTest >> testRateSetting [
self should: [cm rateOfLC: 1.3] raise: DomainError .
self should: [cm rateOfEir: -0.3] raise: DomainError .
self should: [cm rateOfMutation: 1.0000003] raise: DomainError .
@@ -175,7 +175,7 @@ self should: [cm rateOfCrossover: 0.1500001] raise: Warning .
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testlineCrossOver [
+PMAnotherChromosomeManagerTest >> testlineCrossOver [
| a |
1 to: 10 do: [ :i |
a := cm lineCrossOver: #(-2 2) and: #(-4 4).
@@ -184,7 +184,7 @@ AnotherChromosomeManagerTest >> testlineCrossOver [
]
{ #category : #tests }
-AnotherChromosomeManagerTest >> testnumberOfHamersleyPoints [
+PMAnotherChromosomeManagerTest >> testnumberOfHamersleyPoints [
| rand |
self
assert:
diff --git a/src/Math-Tests-FunctionFit/AnotherGeneticOptimizerTest.class.st b/src/Math-Tests-FunctionFit/PMAnotherGeneticOptimizerTest.class.st
similarity index 83%
rename from src/Math-Tests-FunctionFit/AnotherGeneticOptimizerTest.class.st
rename to src/Math-Tests-FunctionFit/PMAnotherGeneticOptimizerTest.class.st
index 0a6b6a627..e56a0f6c7 100644
--- a/src/Math-Tests-FunctionFit/AnotherGeneticOptimizerTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMAnotherGeneticOptimizerTest.class.st
@@ -1,14 +1,14 @@
Class {
- #name : #AnotherGeneticOptimizerTest,
+ #name : #PMAnotherGeneticOptimizerTest,
#superclass : #TestCase,
#instVars : [
'go'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-AnotherGeneticOptimizerTest >> setUp [
+PMAnotherGeneticOptimizerTest >> setUp [
|origin f|
f:=[:x| |v| v:=x asPMVector . v*v].
origin:= #(-5 -5 -5).
@@ -18,7 +18,7 @@ go chromosomeManager populationSize: 20.
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testChromosomeManager [
+PMAnotherGeneticOptimizerTest >> testChromosomeManager [
self
assert: go chromosomeManager class
equals: PMAnotherChromosomeManager.
@@ -26,7 +26,7 @@ AnotherGeneticOptimizerTest >> testChromosomeManager [
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testComputePrecision [
+PMAnotherGeneticOptimizerTest >> testComputePrecision [
|r|
go maximumIterations: 2.
go evaluate .
@@ -38,7 +38,7 @@ self assert: (r>go computePrecision ).
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testEvaluate [
+PMAnotherGeneticOptimizerTest >> testEvaluate [
go maximumIterations: 170.
go chromosomeManager populationSize: 50.
self assert: (go evaluate equalsTo: #(0 0 0) ).
@@ -46,7 +46,7 @@ self assert: (go evaluate equalsTo: #(0 0 0) ).
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testInitializeIterations [
+PMAnotherGeneticOptimizerTest >> testInitializeIterations [
self assert: (go bestPoints isEmpty ).
go initializeIterations .
self deny: (go bestPoints isEmpty ).
@@ -61,7 +61,7 @@ self assert: (go bestValueHistory isEmpty ).
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testPrint [
+PMAnotherGeneticOptimizerTest >> testPrint [
|aStream s|
aStream :=ReadWriteStream with:''.
go printOn: aStream .
@@ -72,7 +72,7 @@ self assert: (s includesSubstring: '20').
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testRangeScale [
+PMAnotherGeneticOptimizerTest >> testRangeScale [
go initializeIterations.
self assert: (go rangeScale first equalsTo: 0.1).
self assert: (go rangeScale second equalsTo: 0.19473684210526315).
@@ -83,7 +83,7 @@ self assert: (go rangeScale second equalsTo: 0.19473684210526315).
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testRangeScaleProbabilistic [
+PMAnotherGeneticOptimizerTest >> testRangeScaleProbabilistic [
| r1 r2 correct |
correct := 0.
9
@@ -103,7 +103,7 @@ AnotherGeneticOptimizerTest >> testRangeScaleProbabilistic [
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testRemoveLastProbabilistic [
+PMAnotherGeneticOptimizerTest >> testRemoveLastProbabilistic [
| r1 r2 correct |
correct := 0.
3
@@ -123,7 +123,7 @@ AnotherGeneticOptimizerTest >> testRemoveLastProbabilistic [
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testSteadyState [
+PMAnotherGeneticOptimizerTest >> testSteadyState [
|r1 r2|
"probabilistic test. not always true"
go steadyState: false.
@@ -138,7 +138,7 @@ self assert: (r1>r2 ).
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testaddPointAt [
+PMAnotherGeneticOptimizerTest >> testaddPointAt [
| b |
go chromosomeManager populationSize: 2.
go resetBestPoints.
@@ -173,7 +173,7 @@ AnotherGeneticOptimizerTest >> testaddPointAt [
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testcalcStatistics [
+PMAnotherGeneticOptimizerTest >> testcalcStatistics [
| s |
go evaluate.
self assert: go bestValueHistory isEmpty.
@@ -188,7 +188,7 @@ AnotherGeneticOptimizerTest >> testcalcStatistics [
]
{ #category : #tests }
-AnotherGeneticOptimizerTest >> testresetBestPoints [
+PMAnotherGeneticOptimizerTest >> testresetBestPoints [
go evaluate .
go resetBestPoints .
self assert: (go bestPoints isEmpty ).
diff --git a/src/Math-Tests-FunctionFit/DataHolderTest.class.st b/src/Math-Tests-FunctionFit/PMDataHolderTest.class.st
similarity index 67%
rename from src/Math-Tests-FunctionFit/DataHolderTest.class.st
rename to src/Math-Tests-FunctionFit/PMDataHolderTest.class.st
index 15bf82841..97bec4ba3 100644
--- a/src/Math-Tests-FunctionFit/DataHolderTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMDataHolderTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #DataHolderTest,
+ #name : #PMDataHolderTest,
#superclass : #TestCase,
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #tests }
-DataHolderTest >> testpointsAndErrorsDo [
+PMDataHolderTest >> testpointsAndErrorsDo [
|g|
g:=PMDataHolder new: 2 withAll: 2@3.
g pointsAndErrorsDo: [:i|( i xValue =2)ifFalse:[self error].( i yValue =3)ifFalse:[self error].( i weight=1)ifFalse:[self error]].
diff --git a/src/Math-Tests-FunctionFit/ErrorAsParameterFunctionTest.class.st b/src/Math-Tests-FunctionFit/PMErrorAsParameterFunctionTest.class.st
similarity index 73%
rename from src/Math-Tests-FunctionFit/ErrorAsParameterFunctionTest.class.st
rename to src/Math-Tests-FunctionFit/PMErrorAsParameterFunctionTest.class.st
index 39aa9f3be..abd11d367 100644
--- a/src/Math-Tests-FunctionFit/ErrorAsParameterFunctionTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMErrorAsParameterFunctionTest.class.st
@@ -1,14 +1,14 @@
Class {
- #name : #ErrorAsParameterFunctionTest,
+ #name : #PMErrorAsParameterFunctionTest,
#superclass : #TestCase,
#instVars : [
'f'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-ErrorAsParameterFunctionTest >> setUp [
+PMErrorAsParameterFunctionTest >> setUp [
|col|
f:=PMErrorOfParameterFunction new function: [:x :a :b|a*x / (b+x)].
col:=(1 to: 3)collect: [:i|i@(f function cull: i cull: 1 cull: 1) ].
@@ -17,13 +17,13 @@ f :=PMErrorAsParameterFunction new function: f.
]
{ #category : #tests }
-ErrorAsParameterFunctionTest >> testMaxFunction [
+PMErrorAsParameterFunctionTest >> testMaxFunction [
self assert: (f parameters size < f maxFunction ).
]
{ #category : #tests }
-ErrorAsParameterFunctionTest >> testPrint [
+PMErrorAsParameterFunctionTest >> testPrint [
|aStream s|
aStream :=ReadWriteStream with:''.
f printOn: aStream .
@@ -36,14 +36,14 @@ self assert: (s includesSubstring: 'maxFunction: ', f maxFunction asString).
]
{ #category : #tests }
-ErrorAsParameterFunctionTest >> testparameters [
+PMErrorAsParameterFunctionTest >> testparameters [
f parameters: #(1 1).
f changeParametersBy: #(1 1).
self assert: f parameters equals: #(2 2)
]
{ #category : #tests }
-ErrorAsParameterFunctionTest >> testvalue [
+PMErrorAsParameterFunctionTest >> testvalue [
f parameters: #(2 2).
self assert: (f value: 2) equals: 1 / 9
]
diff --git a/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st
new file mode 100644
index 000000000..cbf078a0e
--- /dev/null
+++ b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st
@@ -0,0 +1,22 @@
+"
+ErrorMinimizerTest tests indirectly also ErrorAsParameterFunction.
+"
+Class {
+ #name : #PMErrorMinimizerTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-FunctionFit'
+}
+
+{ #category : #tests }
+PMErrorMinimizerTest >> testErrorMinimizer [
+ | f col er fit |
+ f := [ :x :a :b | a * x / (b + x) ].
+ col := (0 to: 20) collect: [ :i | i @ (f cull: i cull: 2 cull: 0.4) ].
+ er := PMErrorOfParameterFunction function: f data: col.
+ er errorType: #insensitive.
+ er quartile: 0.9.
+ fit := PMErrorMinimizer function: er.
+ fit evaluate.
+ self assert: fit maxFunction > 2.
+ self assert: (fit parameters equalsTo: #(2 0.4))
+]
diff --git a/src/Math-Tests-FunctionFit/ErrorOfParameterFunctionTest.class.st b/src/Math-Tests-FunctionFit/PMErrorOfParameterFunctionTest.class.st
similarity index 83%
rename from src/Math-Tests-FunctionFit/ErrorOfParameterFunctionTest.class.st
rename to src/Math-Tests-FunctionFit/PMErrorOfParameterFunctionTest.class.st
index 569c8c116..b74ebc115 100644
--- a/src/Math-Tests-FunctionFit/ErrorOfParameterFunctionTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMErrorOfParameterFunctionTest.class.st
@@ -1,27 +1,27 @@
Class {
- #name : #ErrorOfParameterFunctionTest,
+ #name : #PMErrorOfParameterFunctionTest,
#superclass : #TestCase,
#instVars : [
'f',
'col'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-ErrorOfParameterFunctionTest >> setUp [
+PMErrorOfParameterFunctionTest >> setUp [
f:=PMErrorOfParameterFunction new function: [:x :a :b|a*x / (b+x)].
col:=(1 to: 3)collect: [:i|i@(f function cull: i cull: 1 cull: 1) ].
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testArgumentsString [
+PMErrorOfParameterFunctionTest >> testArgumentsString [
self assert: f parameterNames asOrderedCollection equals: #('a' 'b') asOrderedCollection
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testErrorCollection [
+PMErrorOfParameterFunctionTest >> testErrorCollection [
f data: col.
f errorType: #squared.
self
@@ -42,7 +42,7 @@ ErrorOfParameterFunctionTest >> testErrorCollection [
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testErrorType [
+PMErrorOfParameterFunctionTest >> testErrorType [
self assert: f errorType equals: #squared.
f errorType: #abs.
self assert: f errorType equals: #abs.
@@ -55,13 +55,13 @@ ErrorOfParameterFunctionTest >> testErrorType [
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testFunction [
+PMErrorOfParameterFunctionTest >> testFunction [
self assert: (f function cull: 1 cull: 2 cull: 3) equals: 1 / 2.
self assert: f parameterSize equals: 2
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testPrint [
+PMErrorOfParameterFunctionTest >> testPrint [
|aStream s|
aStream :=ReadWriteStream with:''.
f data:{(1@(1/2)). (2@(2/3)). (3@(3/4))} .
@@ -75,7 +75,7 @@ self assert: (s includesSubstring: 'false').
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testQuartile [
+PMErrorOfParameterFunctionTest >> testQuartile [
self assert: f quartile equals: 1 / 2.
f quartile: 1.
self assert: f quartile equals: 1.
@@ -84,7 +84,7 @@ ErrorOfParameterFunctionTest >> testQuartile [
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testRealValue [
+PMErrorOfParameterFunctionTest >> testRealValue [
f := PMErrorOfParameterFunction
function: [ :i :a | i + a ]
data:
@@ -106,14 +106,14 @@ ErrorOfParameterFunctionTest >> testRealValue [
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testdata [
+PMErrorOfParameterFunctionTest >> testdata [
self assert: f data isNil.
f data: col.
self assert: f data equals: col
]
{ #category : #tests }
-ErrorOfParameterFunctionTest >> testvalue [
+PMErrorOfParameterFunctionTest >> testvalue [
f data: col.
f errorType: #squared.
self assert: (f value: #(0 1)) equals: 181 / 144.
diff --git a/src/Math-Tests-FunctionFit/FunctionFitTest.class.st b/src/Math-Tests-FunctionFit/PMFunctionFitTest.class.st
similarity index 84%
rename from src/Math-Tests-FunctionFit/FunctionFitTest.class.st
rename to src/Math-Tests-FunctionFit/PMFunctionFitTest.class.st
index 4c3845282..da7b68aec 100644
--- a/src/Math-Tests-FunctionFit/FunctionFitTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMFunctionFitTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #FunctionFitTest,
+ #name : #PMFunctionFitTest,
#superclass : #TestCase,
#instVars : [
'f',
'd'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-FunctionFitTest >> setUp [
+PMFunctionFitTest >> setUp [
f:=[:x :a :b|a*x / (b+x)].
d:=(1 to: 20)collect: [:i|i@(f cull: i cull: 2 cull: 0.4) ].
]
{ #category : #tests }
-FunctionFitTest >> testFunctionFit [
+PMFunctionFitTest >> testFunctionFit [
| ff ar p |
ff := PMFunctionFit function: f data: d.
ar := ff parameters.
@@ -33,7 +33,7 @@ FunctionFitTest >> testFunctionFit [
]
{ #category : #tests }
-FunctionFitTest >> testPrint [
+PMFunctionFitTest >> testPrint [
|aStream ff s|
aStream :=ReadWriteStream with:''.
ff:= PMFunctionFit function: f data: d .
diff --git a/src/Math-Tests-FunctionFit/GeneralFunctionFitTest.class.st b/src/Math-Tests-FunctionFit/PMGeneralFunctionFitTest.class.st
similarity index 87%
rename from src/Math-Tests-FunctionFit/GeneralFunctionFitTest.class.st
rename to src/Math-Tests-FunctionFit/PMGeneralFunctionFitTest.class.st
index 9b86d200e..76cd27cce 100644
--- a/src/Math-Tests-FunctionFit/GeneralFunctionFitTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMGeneralFunctionFitTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #GeneralFunctionFitTest,
+ #name : #PMGeneralFunctionFitTest,
#superclass : #TestCase,
#instVars : [
'f',
'col',
'fit'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-GeneralFunctionFitTest >> setUp [
+PMGeneralFunctionFitTest >> setUp [
"Reset the seed of the random numbers (to get consistent results)"
PMMitchellMooreGenerator reset: 0.
@@ -21,7 +21,7 @@ GeneralFunctionFitTest >> setUp [
]
{ #category : #tests }
-GeneralFunctionFitTest >> testBasic [
+PMGeneralFunctionFitTest >> testBasic [
|d|
fit:=PMGeneralFunctionFit function: f data: col minimumValues: 0 maximumValues: 5 .
self assert: (fit evaluate equalsTo: #(0.1 0.4)).
@@ -36,7 +36,7 @@ self assert: (fit error> testFunction [
+PMGeneralFunctionFitTest >> testFunction [
|y|
fit:=PMGeneralFunctionFit function: f data: col minimumValues: 0 maximumValues: 5 .
y:=fit function value: 3 value: 0.1 value: 0.4.
@@ -49,7 +49,7 @@ self assert: ((fit function value:3) equalsTo: y).
]
{ #category : #tests }
-GeneralFunctionFitTest >> testManager [
+PMGeneralFunctionFitTest >> testManager [
fit := PMGeneralFunctionFit
function: f
data: col
@@ -60,7 +60,7 @@ GeneralFunctionFitTest >> testManager [
]
{ #category : #tests }
-GeneralFunctionFitTest >> testMaximumIterationsProbabilistic [
+PMGeneralFunctionFitTest >> testMaximumIterationsProbabilistic [
| r correct |
fit := PMGeneralFunctionFit
function: f
@@ -84,7 +84,7 @@ GeneralFunctionFitTest >> testMaximumIterationsProbabilistic [
]
{ #category : #tests }
-GeneralFunctionFitTest >> testPopulationSize [
+PMGeneralFunctionFitTest >> testPopulationSize [
fit := PMGeneralFunctionFit
function: f
data: col
@@ -96,7 +96,7 @@ GeneralFunctionFitTest >> testPopulationSize [
]
{ #category : #tests }
-GeneralFunctionFitTest >> testPrecision [
+PMGeneralFunctionFitTest >> testPrecision [
fit:=PMGeneralFunctionFit function: f data: col minimumValues: 0 maximumValues: 5 .
self assert:fit precision isNil.
fit evaluate .
@@ -107,7 +107,7 @@ self assert: (fit precision < 1e-6 ).
]
{ #category : #tests }
-GeneralFunctionFitTest >> testPrint [
+PMGeneralFunctionFitTest >> testPrint [
|aStream s|
fit:=PMGeneralFunctionFit function: f data: col minimumValues: 0 maximumValues: 5 .
aStream :=ReadWriteStream with:''.
@@ -125,7 +125,7 @@ self assert: (s includesSubstring: '#(0.').
]
{ #category : #tests }
-GeneralFunctionFitTest >> testRelativeError [
+PMGeneralFunctionFitTest >> testRelativeError [
|r|
f:=[ :x :a| a].
col:={1@2. 2@6}.
@@ -149,7 +149,7 @@ self assert: (r<4 ).
]
{ #category : #tests }
-GeneralFunctionFitTest >> testResetBestPoints [
+PMGeneralFunctionFitTest >> testResetBestPoints [
fit:=PMGeneralFunctionFit function: f data: col minimumValues: 0 maximumValues: 5 .
fit evaluate .
fit resetBestPoints.
@@ -157,7 +157,7 @@ self assert: (fit optimizer bestPoints isEmpty ).
]
{ #category : #tests }
-GeneralFunctionFitTest >> testTruncate [
+PMGeneralFunctionFitTest >> testTruncate [
col at: 1 put: -4 @ -0.2.
col at: 81 put: 4.000000000000004 @ 0.2.
col at: 10 put: -3.099999999999999 @ 2.
diff --git a/src/Math-Tests-FunctionFit/SimpleParameterFunctionTest.class.st b/src/Math-Tests-FunctionFit/PMSimpleParameterFunctionTest.class.st
similarity index 78%
rename from src/Math-Tests-FunctionFit/SimpleParameterFunctionTest.class.st
rename to src/Math-Tests-FunctionFit/PMSimpleParameterFunctionTest.class.st
index 524f164ef..fd2abcac7 100644
--- a/src/Math-Tests-FunctionFit/SimpleParameterFunctionTest.class.st
+++ b/src/Math-Tests-FunctionFit/PMSimpleParameterFunctionTest.class.st
@@ -1,19 +1,19 @@
Class {
- #name : #SimpleParameterFunctionTest,
+ #name : #PMSimpleParameterFunctionTest,
#superclass : #TestCase,
#instVars : [
'f'
],
- #category : 'Math-Tests-FunctionFit'
+ #category : #'Math-Tests-FunctionFit'
}
{ #category : #running }
-SimpleParameterFunctionTest >> setUp [
+PMSimpleParameterFunctionTest >> setUp [
f:=[:a :x :cc :b|x].
]
{ #category : #tests }
-SimpleParameterFunctionTest >> testChangeParametersBy [
+PMSimpleParameterFunctionTest >> testChangeParametersBy [
| s |
s := PMSimpleParameterFunction function: f parameters: #(1 1 2).
s changeParametersBy: #(3 2 1).
@@ -21,14 +21,14 @@ SimpleParameterFunctionTest >> testChangeParametersBy [
]
{ #category : #tests }
-SimpleParameterFunctionTest >> testParameterNames [
+PMSimpleParameterFunctionTest >> testParameterNames [
| s |
s := PMSimpleParameterFunction function: f.
self assert: s parameterNames asArray equals: #('x' 'cc' 'b')
]
{ #category : #tests }
-SimpleParameterFunctionTest >> testPrint [
+PMSimpleParameterFunctionTest >> testPrint [
|aStream s|
aStream :=ReadWriteStream with:''.
s:=PMSimpleParameterFunction function:f parameters: #(1 2 3).
@@ -42,7 +42,7 @@ self assert: (s includesSubstring: ' 3').
]
{ #category : #tests }
-SimpleParameterFunctionTest >> testRest [
+PMSimpleParameterFunctionTest >> testRest [
| s vg |
s := PMSimpleParameterFunction function: f.
self assert: s parameters size equals: 3.
diff --git a/src/Math-Tests-KDTree/KDTreeTest.class.st b/src/Math-Tests-KDTree/PMKDTreeTest.class.st
similarity index 88%
rename from src/Math-Tests-KDTree/KDTreeTest.class.st
rename to src/Math-Tests-KDTree/PMKDTreeTest.class.st
index faad10864..88e92915e 100644
--- a/src/Math-Tests-KDTree/KDTreeTest.class.st
+++ b/src/Math-Tests-KDTree/PMKDTreeTest.class.st
@@ -2,39 +2,37 @@
KDTreeTest makes random checks of KDTree, comparing results with results of StupidNN. is not too fast.
"
Class {
- #name : #KDTreeTest,
+ #name : #PMKDTreeTest,
#superclass : #TestCase,
#instVars : [
'rand',
'stupid',
'tree'
],
- #category : 'Math-Tests-KDTree'
+ #category : #'Math-Tests-KDTree'
}
{ #category : #running }
-KDTreeTest >> equalityTest: aResult and: bResult [
+PMKDTreeTest >> equalityTest: aResult and: bResult [
"tests whether two collections of collections are equal"
self assert: ( (aResult with: bResult collect: [:a :b|a hasEqualElements: b]) allSatisfy: [:e|e])
]
{ #category : #running }
-KDTreeTest >> initializeTreeWith: aCollection as: simpleTree [
+PMKDTreeTest >> initializeTreeWith: aCollection as: simpleTree [
"used to initialize all tests"
stupid :=PMStupidNN withAll: aCollection.
tree := simpleTree ifTrue: [ PMKDTree withAll: aCollection ] ifFalse: [PMIndexedKDTree withAll: aCollection ].
]
{ #category : #running }
-KDTreeTest >> setUp [
-rand :=Random new.
+PMKDTreeTest >> setUp [
+ rand := Random new
]
{ #category : #tests }
-KDTreeTest >> testBenchmark [
+PMKDTreeTest >> testBenchmark [
| aStream s |
- (RPackage organizer includesPackageNamed: 'Math-Benchmarks-KDTree')
- ifFalse: [ ^ self skip ].
aStream := ReadWriteStream with: ''.
(PMKDTreeBenchmark fastRun: 1 with: Array) printOn: aStream.
s := aStream contents.
@@ -46,7 +44,7 @@ KDTreeTest >> testBenchmark [
]
{ #category : #tests }
-KDTreeTest >> testIndexedKDTree1Dimension [
+PMKDTreeTest >> testIndexedKDTree1Dimension [
|m aVector aResult bResult |
m :=(rand next:200) collect: [:n| Array with: n]."1-dimensional data, just some numbers"
self initializeTreeWith: m as: false .
@@ -57,7 +55,7 @@ self initializeTreeWith: m as: false .
]
{ #category : #tests }
-KDTreeTest >> testIndexedKDTree4Dimensions [
+PMKDTreeTest >> testIndexedKDTree4Dimensions [
|m aVector aResult bResult|
m :=(1 to: 2000) collect: [:n| (rand next:4)-0.5]. "4-dimensional data"
self initializeTreeWith: m as: false .
@@ -69,7 +67,7 @@ self initializeTreeWith: m as: false .
]
{ #category : #tests }
-KDTreeTest >> testIndexedKDTreeExtremeCase [
+PMKDTreeTest >> testIndexedKDTreeExtremeCase [
| bResult |
tree := PMIndexedKDTree withAll: #(#(1)). "extreme case"
bResult := tree nnSearch: #(-1) i: 3.
@@ -78,7 +76,7 @@ KDTreeTest >> testIndexedKDTreeExtremeCase [
]
{ #category : #tests }
-KDTreeTest >> testIndexedKDTreeSimple [
+PMKDTreeTest >> testIndexedKDTreeSimple [
| r n aTree bTree |
r := rand next: 200.
aTree := PMIndexedKDTree
@@ -98,7 +96,7 @@ KDTreeTest >> testIndexedKDTreeSimple [
]
{ #category : #tests }
-KDTreeTest >> testKDTree1Dimension [
+PMKDTreeTest >> testKDTree1Dimension [
|m aVector aResult bResult|
m :=(rand next:200) collect: [:n| Array with: n]."1-dimensional data, just some numbers"
self initializeTreeWith: m as: true .
@@ -110,7 +108,7 @@ self initializeTreeWith: m as: true .
]
{ #category : #tests }
-KDTreeTest >> testKDTree1DimensionIntegers [
+PMKDTreeTest >> testKDTree1DimensionIntegers [
|m aVector aResult bResult|
m :=(1 to: 20) collect: [:index | Array with: (rand nextInt: 10)]. "only integers, obviously with multiples. test distances because the nearest neighbours are not necessarily the same"
self initializeTreeWith: m as: true .
@@ -121,7 +119,7 @@ self initializeTreeWith: m as: true .
]
{ #category : #tests }
-KDTreeTest >> testKDTree2Dimensions [
+PMKDTreeTest >> testKDTree2Dimensions [
|aVector aResult bResult|
self initializeTreeWith: ((1 to: 2000) collect: [:n| (rand next:2)]) as: true . "2-dimensional data"
100 timesRepeat: [aVector :=rand next:2.
@@ -131,7 +129,7 @@ self initializeTreeWith: ((1 to: 2000) collect: [:n| (rand next:2)]) as: true
]
{ #category : #tests }
-KDTreeTest >> testKDTree4Dimensions [
+PMKDTreeTest >> testKDTree4Dimensions [
|aVector|
self initializeTreeWith: ((1 to: 2000) collect: [:n| (rand next:4)-0.5]) as: true . "4-dimensional data"
50 timesRepeat: [aVector :=(rand next: 4)- 0.5. "2 nearest neighbours"
@@ -141,7 +139,7 @@ self initializeTreeWith: ((1 to: 2000) collect: [:n| (rand next:4)-0.5]) as: t
]
{ #category : #tests }
-KDTreeTest >> testKDTreeExtremeCase [
+PMKDTreeTest >> testKDTreeExtremeCase [
| bResult |
tree := PMKDTree withAll: #(#(1)).
bResult := tree nnSearch: #(2) i: 3.
@@ -155,7 +153,7 @@ KDTreeTest >> testKDTreeExtremeCase [
]
{ #category : #tests }
-KDTreeTest >> testPMVectorCompatibility [
+PMKDTreeTest >> testPMVectorCompatibility [
| aVector bVector r |
(Array lookupSelector: #asPMVector)
ifNil: [ ^ self skip: 'necessary PM package not loaded' ].
@@ -183,7 +181,7 @@ KDTreeTest >> testPMVectorCompatibility [
]
{ #category : #tests }
-KDTreeTest >> testPrintOn [
+PMKDTreeTest >> testPrintOn [
| aStream s |
aStream := ReadWriteStream with: ''.
(PMKDTree withAll: #(#(1) #(4))) printOn: aStream.
@@ -195,7 +193,7 @@ KDTreeTest >> testPrintOn [
]
{ #category : #tests }
-KDTreeTest >> testPrintOn2 [
+PMKDTreeTest >> testPrintOn2 [
| aStream s |
aStream := ReadWriteStream with: ''.
(PMIndexedKDTree withAll: #(#(1))) printOn: aStream.
diff --git a/src/Math-Tests-KDTree/NNStoreTest.class.st b/src/Math-Tests-KDTree/PMNNStoreTest.class.st
similarity index 91%
rename from src/Math-Tests-KDTree/NNStoreTest.class.st
rename to src/Math-Tests-KDTree/PMNNStoreTest.class.st
index 4ade30316..0aa4019ae 100644
--- a/src/Math-Tests-KDTree/NNStoreTest.class.st
+++ b/src/Math-Tests-KDTree/PMNNStoreTest.class.st
@@ -3,13 +3,13 @@ the individual tests also check and show the general way NNStore processes its d
"
Class {
- #name : #NNStoreTest,
+ #name : #PMNNStoreTest,
#superclass : #TestCase,
- #category : 'Math-Tests-KDTree'
+ #category : #'Math-Tests-KDTree'
}
{ #category : #tests }
-NNStoreTest >> testCopy [
+PMNNStoreTest >> testCopy [
"a separate copy method is necessary because of this scenario"
| a b |
@@ -23,7 +23,7 @@ NNStoreTest >> testCopy [
]
{ #category : #tests }
-NNStoreTest >> testCopyEmpty [
+PMNNStoreTest >> testCopyEmpty [
| n m |
n := PMNNStore newFrom: #(#(1 $a) #(3 1.0) #(0 '2')).
n := n copyEmpty.
@@ -44,7 +44,7 @@ NNStoreTest >> testCopyEmpty [
]
{ #category : #tests }
-NNStoreTest >> testEqual [
+PMNNStoreTest >> testEqual [
| a b |
b := #(#(1 $a) #(3 1.0) #(0 '2')).
a := PMNNStore newFrom: b.
@@ -66,7 +66,7 @@ NNStoreTest >> testEqual [
]
{ #category : #tests }
-NNStoreTest >> testExtremeCase [
+PMNNStoreTest >> testExtremeCase [
| n |
n := PMNNStore new.
n sortFor: nil. "this should indeed always be possible and shouldnt raise an error!"
@@ -83,7 +83,7 @@ NNStoreTest >> testExtremeCase [
]
{ #category : #tests }
-NNStoreTest >> testInitialize [
+PMNNStoreTest >> testInitialize [
| a b |
a := PMNNStore newFrom: #(#(4 $a) #(5 1.0) #(6 '2')).
b := (PMNNStore newFrom: #(#(4 $a) #(5 1.0) #(6 '2'))) initialize.
@@ -99,7 +99,7 @@ NNStoreTest >> testInitialize [
]
{ #category : #tests }
-NNStoreTest >> testInitialize2 [
+PMNNStoreTest >> testInitialize2 [
"a separate = method is necessary because of this scenario with resetting"
| a b c |
@@ -118,7 +118,7 @@ NNStoreTest >> testInitialize2 [
]
{ #category : #tests }
-NNStoreTest >> testInitialize3 [
+PMNNStoreTest >> testInitialize3 [
| a |
a := (PMNNStore newFrom: #(#(7 $a) #(5 1.0) #(6 '2'))) initialize.
a
@@ -129,7 +129,7 @@ NNStoreTest >> testInitialize3 [
]
{ #category : #tests }
-NNStoreTest >> testNew [
+PMNNStoreTest >> testNew [
| n |
n := PMNNStore new: 1.
self assert: n isEmpty.
@@ -141,7 +141,7 @@ NNStoreTest >> testNew [
]
{ #category : #tests }
-NNStoreTest >> testNew2 [
+PMNNStoreTest >> testNew2 [
| n |
n := PMNNStore new: 3.
n add: #(3 1).
@@ -151,7 +151,7 @@ NNStoreTest >> testNew2 [
]
{ #category : #tests }
-NNStoreTest >> testNew3 [
+PMNNStoreTest >> testNew3 [
| n |
n := PMNNStore new: 0.
self assert: n isEmpty.
@@ -162,7 +162,7 @@ NNStoreTest >> testNew3 [
]
{ #category : #tests }
-NNStoreTest >> testNewFrom [
+PMNNStoreTest >> testNewFrom [
| n |
n := PMNNStore newFrom: #(#(1 $a) #(3 1.0) #(0 '2')).
self assert: n data equals: #('2' $a 1.0).
@@ -176,7 +176,7 @@ NNStoreTest >> testNewFrom [
]
{ #category : #tests }
-NNStoreTest >> testWithAll [
+PMNNStoreTest >> testWithAll [
| n |
n := PMNNStore withAll: #(2 5 4).
self assert: n completeData equals: #(#(nil 2) #(nil 5) #(nil 4)).
diff --git a/src/Math-KernelSmoothing/PMSmoothedDensityTest.class.st b/src/Math-Tests-KernelSmoothing/PMSmoothedDensityTest.class.st
similarity index 98%
rename from src/Math-KernelSmoothing/PMSmoothedDensityTest.class.st
rename to src/Math-Tests-KernelSmoothing/PMSmoothedDensityTest.class.st
index d290c4459..38cd139bc 100644
--- a/src/Math-KernelSmoothing/PMSmoothedDensityTest.class.st
+++ b/src/Math-Tests-KernelSmoothing/PMSmoothedDensityTest.class.st
@@ -4,7 +4,7 @@ Class {
#instVars : [
'density'
],
- #category : 'Math-KernelSmoothing'
+ #category : #'Math-Tests-KernelSmoothing'
}
{ #category : #running }
diff --git a/src/Math-Tests-KernelSmoothing/package.st b/src/Math-Tests-KernelSmoothing/package.st
new file mode 100644
index 000000000..988d1f910
--- /dev/null
+++ b/src/Math-Tests-KernelSmoothing/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-KernelSmoothing' }
diff --git a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st
similarity index 59%
rename from src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st
rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st
index 8b39780c2..245ef271b 100644
--- a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st
+++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st
@@ -1,21 +1,15 @@
Class {
- #name : #KolmogorovSmirnov1sampleTest,
+ #name : #PMKolmogorovSmirnov1SampleTest,
#superclass : #TestCase,
#instVars : [
'nd',
'ks'
],
- #category : 'Math-Tests-KolmogorovSmirnov'
+ #category : #'Math-Tests-KolmogorovSmirnov'
}
-{ #category : #initialization }
-KolmogorovSmirnov1sampleTest >> initialize [
- nd := PMNormalDistribution new.
- ks := PMKolmogorovSmirnov1Sample new
-]
-
{ #category : #running }
-KolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [
+PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [
| n |
ks populationDistribution: aDistribution.
n := 0.
@@ -26,8 +20,15 @@ KolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [
^ n
]
+{ #category : #running }
+PMKolmogorovSmirnov1SampleTest >> setUp [
+ super setUp .
+ nd := PMNormalDistribution new.
+ ks := PMKolmogorovSmirnov1Sample new
+]
+
{ #category : #tests }
-KolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [
+PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [
"is a probabilistic test that occasionally fails, but it should happen rarely"
| d |
@@ -36,15 +37,21 @@ KolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [
]
{ #category : #tests }
-KolmogorovSmirnov1sampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [
- nd := PMNormalDistribution new. "--> Normal distribution( 0, 1)"
- ks := PMKolmogorovSmirnov1Sample compareData: ((1 to: 100) collect: [ :i | nd random ]) withDistribution: nd. "-->
- a KolmogorovSmirnov(dataSize: 100 cdf: distributionValue of Normal distribution( 0, 1))"
- self assert: (ks rejectEqualityHypothesisWithAlpha: 0.05) equals: false
+PMKolmogorovSmirnov1SampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [
+ | sample |
+ "The data below are taken from http://www.maths.qmul.ac.uk/~bb/CTS_Chapter3_Students.pdf"
+ sample := #(-1.2 0.2 -0.6 0.8 -1.0).
+ ks := PMKolmogorovSmirnov1Sample
+ compareData: sample
+ withDistribution: nd.
+
+ self
+ assert: (ks rejectEqualityHypothesisWithAlpha: 0.05)
+ equals: false
]
{ #category : #tests }
-KolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [
+PMKolmogorovSmirnov1SampleTest >> testWrongAverageProbabilistic [
"is a probabilistic test that occasionally fails, but it should happen not too often"
| d |
@@ -53,7 +60,7 @@ KolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [
]
{ #category : #tests }
-KolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [
+PMKolmogorovSmirnov1SampleTest >> testWrongDistributionProbabilistic [
"is a probabilistic test that occasionally fails, but it should happen rarely"
| d |
@@ -66,7 +73,7 @@ KolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [
]
{ #category : #tests }
-KolmogorovSmirnov1sampleTest >> testWrongStandardDeviationProbabilistic [
+PMKolmogorovSmirnov1SampleTest >> testWrongStandardDeviationProbabilistic [
"is a probabilistic test that occasionally fails, but it should happen rarely"
| d |
diff --git a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov2sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st
similarity index 70%
rename from src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov2sampleTest.class.st
rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st
index 32042e6eb..81e1bff62 100644
--- a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov2sampleTest.class.st
+++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st
@@ -1,33 +1,36 @@
Class {
- #name : #KolmogorovSmirnov2sampleTest,
+ #name : #PMKolmogorovSmirnov2SampleTest,
#superclass : #TestCase,
#instVars : [
'k'
],
- #category : 'Math-Tests-KolmogorovSmirnov'
+ #category : #'Math-Tests-KolmogorovSmirnov'
}
-{ #category : #initialization }
-KolmogorovSmirnov2sampleTest >> initialize [
+{ #category : #running }
+PMKolmogorovSmirnov2SampleTest >> setUp [
+ super setUp .
k := PMKolmogorovSmirnov2Sample new
]
{ #category : #tests }
-KolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [
- | nd ks |
- nd := PMNormalDistribution new.
+PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [
+ "The data below are taken from http://www.stats.ox.ac.uk/~massa/Lecture%2013.pdf
+ According to that paper Dn = 0.6 and Dcrit = 0.645 so the null hypothesis is retained.
+ "
+
+ | ks |
ks := PMKolmogorovSmirnov2Sample
- compareData: ((1 to: 100) collect: [ :i | nd random ])
- withData: ((1 to: 100) collect: [ :i | nd random ]).
- ks ksStatistic.
- ks pValue asFloat.
+ compareData: #(1.2 1.4 1.9 3.7 4.4 4.8 9.7 17.3 21.1 28.4)
+ withData: #(5.6 6.5 6.6 6.9 9.2 10.4 10.6 19.3).
+
self
assert: (ks rejectEqualityHypothesisWithAlpha: 0.05)
- equals: false
+ equals: true
]
{ #category : #tests }
-KolmogorovSmirnov2sampleTest >> testSecondSmallSample [
+PMKolmogorovSmirnov2SampleTest >> testSecondSmallSample [
"sample from Kim, P. J. & Jennrich, R. I.
Tables of the exact sampling distribution of the two-sample Kolmogorov–Smirnov criterion
in Selected Tables in Mathematical Statistics Volume I (1973)"
@@ -49,7 +52,7 @@ KolmogorovSmirnov2sampleTest >> testSecondSmallSample [
]
{ #category : #tests }
-KolmogorovSmirnov2sampleTest >> testSmallSample [
+PMKolmogorovSmirnov2SampleTest >> testSmallSample [
"sample from http://www.math.montana.edu/~jobo/st431/ho2b.pdf"
| d1 d2 |
@@ -64,7 +67,7 @@ KolmogorovSmirnov2sampleTest >> testSmallSample [
]
{ #category : #tests }
-KolmogorovSmirnov2sampleTest >> testkdStatistic [
+PMKolmogorovSmirnov2SampleTest >> testkdStatistic [
"extreme case"
| d1 |
diff --git a/src/Math-Tests-KolmogorovSmirnov/KolmogorovsDistributionTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovsDistributionTest.class.st
similarity index 89%
rename from src/Math-Tests-KolmogorovSmirnov/KolmogorovsDistributionTest.class.st
rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovsDistributionTest.class.st
index 038c82c50..bf20c719e 100644
--- a/src/Math-Tests-KolmogorovSmirnov/KolmogorovsDistributionTest.class.st
+++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovsDistributionTest.class.st
@@ -2,13 +2,13 @@
data are taken from: http://www.ism.ac.jp/editsec/aism/pdf/054_3_0577.pdf
"
Class {
- #name : #KolmogorovsDistributionTest,
+ #name : #PMKolmogorovsDistributionTest,
#superclass : #TestCase,
- #category : 'Math-Tests-KolmogorovSmirnov'
+ #category : #'Math-Tests-KolmogorovSmirnov'
}
{ #category : #tests }
-KolmogorovsDistributionTest >> testBig [
+PMKolmogorovsDistributionTest >> testBig [
| kd |
kd := PMKolmogorovsDistribution exampleSize: 1000.
self assert: (kd average round: 4) equals: (0.02730 round: 4).
@@ -22,7 +22,7 @@ KolmogorovsDistributionTest >> testBig [
]
{ #category : #tests }
-KolmogorovsDistributionTest >> testMedium [
+PMKolmogorovsDistributionTest >> testMedium [
| kd |
kd := PMKolmogorovsDistribution exampleSize: 100.
self assert: (kd average round: 3) equals: (0.08519 round: 3).
@@ -38,7 +38,7 @@ KolmogorovsDistributionTest >> testMedium [
]
{ #category : #tests }
-KolmogorovsDistributionTest >> testSmall [
+PMKolmogorovsDistributionTest >> testSmall [
| kd |
kd := PMKolmogorovsDistribution exampleSize: 10.
self assert: (kd average round: 2) equals: (0.25916 round: 2).
diff --git a/src/Math-Tests-Matrix/PMAdditionalTest.class.st b/src/Math-Tests-Matrix/PMAdditionalTest.class.st
index 9e8d1e286..eea0c4266 100644
--- a/src/Math-Tests-Matrix/PMAdditionalTest.class.st
+++ b/src/Math-Tests-Matrix/PMAdditionalTest.class.st
@@ -34,7 +34,7 @@ PMAdditionalTest >> testMatrixInversionSmall [
{ #category : #tests }
PMAdditionalTest >> testMatrixSquared [
- "this tests squared and is not in Math-Tests-DHB-Numerical since it uses random matrices"
+ "this tests squared and is not in Math-Tests-Numerical since it uses random matrices"
| a |
10
diff --git a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st
new file mode 100644
index 000000000..e7398f98d
--- /dev/null
+++ b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st
@@ -0,0 +1,32 @@
+Class {
+ #name : #PMJacobiTransformationTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Matrix'
+}
+
+{ #category : #tests }
+PMJacobiTransformationTest >> testEigenvalueOfIdentityMatrixIsOne [
+ "The eigenvalue of I is 1"
+
+ | jacobiTransformation identityMatrix expected |
+ identityMatrix := PMMatrix rows: #(#(1 0) #(0 1)).
+
+ jacobiTransformation := PMJacobiTransformation matrix: identityMatrix.
+
+ expected := #(1 1).
+ self assert: jacobiTransformation evaluate equals: expected
+]
+
+{ #category : #tests }
+PMJacobiTransformationTest >> testEigenvectorsOfIdentityMatrixAreTheUnitVectors [
+ "The eigenvectors of I are (1 0) and (0 1), the unit basis vectors"
+
+ | identityMatrix jacobiTransform matrixOfEigenvectors expected |
+ identityMatrix := PMMatrix rows: #(#(1 0) #(0 1)).
+ jacobiTransform := PMJacobiTransformation matrix: identityMatrix.
+
+ matrixOfEigenvectors := jacobiTransform transform.
+
+ expected := PMSymmetricMatrix identity: 2.
+ self assert: matrixOfEigenvectors equals: expected.
+]
diff --git a/src/Math-Tests-Matrix/PMManifestMathTestMatrix.class.st b/src/Math-Tests-Matrix/PMManifestMathTestMatrix.class.st
deleted file mode 100644
index b3b47cb6e..000000000
--- a/src/Math-Tests-Matrix/PMManifestMathTestMatrix.class.st
+++ /dev/null
@@ -1,8 +0,0 @@
-"
-I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
-"
-Class {
- #name : #PMManifestMathTestMatrix,
- #superclass : #PackageManifest,
- #category : 'Math-Tests-Matrix'
-}
diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st
index 35c864902..32a26fd66 100644
--- a/src/Math-Tests-Matrix/PMMatrixTest.class.st
+++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st
@@ -4,6 +4,50 @@ Class {
#category : 'Math-Tests-Matrix'
}
+{ #category : #tests }
+PMMatrixTest >> testArgMaxOnColumns [
+ | m1 m2 |
+ m1 := PMMatrix rows: #(#(0 1 2) #(3 4 5)).
+ m2 := PMMatrix rows: #(#(-1 0 -1) #(-2 0 0)).
+ self assert: m1 argMaxOnColumns equals: #(2 2 2) asPMVector.
+ self assert: m2 argMaxOnColumns equals: #(1 1 2) asPMVector
+]
+
+{ #category : #tests }
+PMMatrixTest >> testArgMaxOnRows [
+ | m1 m2 |
+ m1 := PMMatrix rows: #(#(0 1 2) #(3 4 5)).
+ m2 := PMMatrix rows: #(#(-1 0 -1) #(-2 0 0)).
+ self assert: m1 argMaxOnRows equals: #(3 3) asPMVector.
+ self assert: m2 argMaxOnRows equals: #(2 2) asPMVector.
+]
+
+{ #category : #tests }
+PMMatrixTest >> testAtAllPut [
+
+ | a |
+ a := PMMatrix new: 3.
+ a atAllPut: 4.
+ self assert: a equals: (PMMatrix rows: #(#(4 4 4) #(4 4 4) #(4 4 4))).
+
+]
+
+{ #category : #tests }
+PMMatrixTest >> testAtColumnPutRepeat [
+
+ | a |
+ a := PMMatrix new: 3.
+ a
+ atColumn: 1 put: 1 repeat: 3;
+ atColumn: 2 put: 2 repeat: 3;
+ atColumn: 3 put: 3 repeat: 3.
+ self assert: a equals: (PMMatrix rows: #(#(1 2 3) #(1 2 3) #(1 2 3))).
+ a := PMMatrix new: 3.
+ a
+ atColumn: 1 put: 1 repeat: 2.
+ self assert: a equals: (PMMatrix rows: #(#(1 nil nil) #(1 nil nil) #(nil nil nil))).
+]
+
{ #category : #'linear algebra' }
PMMatrixTest >> testAtRowPutAtColumnPut [
| a |
@@ -71,7 +115,21 @@ PMMatrixTest >> testEigenvaluesLargest [
self assert: ((roots at: 2) - eigenvalue) abs < 1.0e-08
]
-{ #category : #'linear algebra' }
+{ #category : #tests }
+PMMatrixTest >> testFlattenColumns [
+ | m |
+ m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)).
+ self assert: m flattenColumns equals: #(1 4 7 2 5 8 3 6 9) asPMVector
+]
+
+{ #category : #tests }
+PMMatrixTest >> testFlattenRows [
+ | m |
+ m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)).
+ self assert: m flattenRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector
+]
+
+{ #category : #tests }
PMMatrixTest >> testLUPDecomposition [
"Code Example 8.10"
@@ -109,7 +167,7 @@ PMMatrixTest >> testLinearEquations [
self assert: (sol2 at: 3) equals: 2
]
-{ #category : #'linear algebra' }
+{ #category : #tests }
PMMatrixTest >> testLinearEquationsSingle [
| s sol |
s := PMLinearEquationSystem
@@ -177,6 +235,13 @@ PMMatrixTest >> testMatrixCloseToPrecision [
self deny: (a closeTo: b precision: 0.2)
]
+{ #category : #comparing }
+PMMatrixTest >> testMatrixCos [
+ | a |
+ a := PMMatrix rows: {{Float pi. Float pi.}. {0. 0.}}.
+ self assert: a cos equals: (PMMatrix rows:#((-1 -1) (1 1)))
+]
+
{ #category : #'linear algebra' }
PMMatrixTest >> testMatrixCumulativeSum [
| a b |
@@ -287,6 +352,22 @@ PMMatrixTest >> testMatrixGreater [
self assert: ((b rowAt: 2) at: 3) equals: true
]
+{ #category : #'linear algebra' }
+PMMatrixTest >> testMatrixHadamardProduct [
+ | a b c |
+ a := PMMatrix rows: #(#(1 0 1) #(-1 -2 3)).
+ b := PMMatrix rows: #(#(1 2 3) #(-2 1 7)).
+ c := a hadamardProduct: b.
+ self assert: c numberOfRows equals: 2.
+ self assert: c numberOfColumns equals: 3.
+ self assert: ((c rowAt: 1) at: 1) equals: 1.
+ self assert: ((c rowAt: 1) at: 2) equals: 0.
+ self assert: ((c rowAt: 1) at: 3) equals: 3.
+ self assert: ((c rowAt: 2) at: 1) equals: 2.
+ self assert: ((c rowAt: 2) at: 2) equals: -2.
+ self assert: ((c rowAt: 2) at: 3) equals: 21
+]
+
{ #category : #comparing }
PMMatrixTest >> testMatrixHash [
| a b c |
@@ -357,21 +438,17 @@ PMMatrixTest >> testMatrixMultiply [
]
{ #category : #'linear algebra' }
-PMMatrixTest >> testMatrixMultiplyElementwise [
- "Code Example 8.1"
+PMMatrixTest >> testMatrixPrincipalDiagonal [
+ | a |
+ a := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)).
+ self assert: a principalDiagonal equals: #(1 5 9) asPMVector.
+]
- | a b c |
- a := PMMatrix rows: #(#(1 0 1) #(-1 -2 3)).
- b := PMMatrix rows: #(#(1 2 3) #(-2 1 7)).
- c := a dot:b.
- self assert: c numberOfRows equals: 2.
- self assert: c numberOfColumns equals: 3.
- self assert: ((c rowAt: 1) at: 1) equals: 1.
- self assert: ((c rowAt: 1) at: 2) equals: 0.
- self assert: ((c rowAt: 1) at: 3) equals: 3.
- self assert: ((c rowAt: 2) at: 1) equals: 2.
- self assert: ((c rowAt: 2) at: 2) equals: -2.
- self assert: ((c rowAt: 2) at: 3) equals: 21
+{ #category : #comparing }
+PMMatrixTest >> testMatrixSign [
+ | a |
+ a := PMMatrix rows: #(#(-2 2 0) #(2 0 -2)).
+ self assert: a sign equals: (PMMatrix rows: #((-1 1 0) (1 0 -1)))
]
{ #category : #'linear algebra' }
@@ -428,8 +505,26 @@ PMMatrixTest >> testPrintOn [
| m stream |
stream := String new writeStream.
m := PMMatrix new.
- "this raised an error:"
- self shouldnt: [m printOn: stream] raise: Error
+ m printOn: stream
+]
+
+{ #category : #comparing }
+PMMatrixTest >> testRowsColumns [
+ | a |
+
+ a := PMMatrix rows: 3 columns: 4.
+ self assert: a dimension equals: 3 @ 4.
+]
+
+{ #category : #tests }
+PMMatrixTest >> testRowsColumnsElement [
+
+ | a |
+
+ a := PMMatrix rows: 3 columns: 4 element: 1.
+ self assert: a dimension equals: 3 @ 4.
+ self assert: a equals: (PMMatrix rows: #(#(1 1 1 1) #(1 1 1 1) #(1 1 1 1)))
+
]
{ #category : #tests }
@@ -577,6 +672,13 @@ PMMatrixTest >> testSymmetricMatrixAdd3 [
self assert: ((c rowAt: 3) at: 1) equals: 31
]
+{ #category : #tests }
+PMMatrixTest >> testVectorConversion [
+ | m |
+ m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)).
+ self assert: m asVector equals: #(1 2 3 4 5 6 7 8 9) asPMVector
+]
+
{ #category : #'linear algebra' }
PMMatrixTest >> testVectorMatrixOperation [
"Code Example 8.1"
@@ -616,8 +718,4 @@ PMMatrixTest >> testZerosMatrix [
self assert: ((a rowAt: 2) at: 1) equals: 0.
self assert: ((a rowAt: 2) at: 2) equals: 0.
self assert: ((a rowAt: 2) at: 3) equals: 0
-
-
-
-
]
diff --git a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st
index 1ab8fd6c6..d3f6d1b79 100644
--- a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st
+++ b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st
@@ -142,8 +142,8 @@ PMSingularValueDecompositionTest >> loadExample4 [
{ #category : #initialization }
PMSingularValueDecompositionTest >> setUp [
-
- self loadExample1.
+ super setUp.
+ self loadExample1
"self loadExample2."
"self loadExample3."
"self loadExample4."
diff --git a/src/Math-Number-Extensions/NumberExtensionsTest.class.st b/src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st
similarity index 70%
rename from src/Math-Number-Extensions/NumberExtensionsTest.class.st
rename to src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st
index 09bd235dc..029ddc183 100644
--- a/src/Math-Number-Extensions/NumberExtensionsTest.class.st
+++ b/src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st
@@ -1,18 +1,18 @@
Class {
- #name : #NumberExtensionsTest,
+ #name : #PMNumberExtensionsTest,
#superclass : #TestCase,
- #category : #'Math-Number-Extensions'
+ #category : #'Math-Tests-Number-Extensions'
}
{ #category : #tests }
-NumberExtensionsTest >> testArTanh [
+PMNumberExtensionsTest >> testArTanh [
self assert: 0 arTanh = 0.0 arTanh.
self assert: 1 arTanh isFloat.
self assert: 1 arTanh equals: 1.0 arTanh
]
{ #category : #tests }
-NumberExtensionsTest >> testSinc [
+PMNumberExtensionsTest >> testSinc [
"test cardinal sine"
self assert: 0 sinc equals: 1.
diff --git a/src/Math-Tests-Number-Extensions/package.st b/src/Math-Tests-Number-Extensions/package.st
new file mode 100644
index 000000000..dd008a793
--- /dev/null
+++ b/src/Math-Tests-Number-Extensions/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-Number-Extensions' }
diff --git a/src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st b/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st
similarity index 96%
rename from src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st
rename to src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st
index a9595ab8a..11c4af19f 100644
--- a/src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st
+++ b/src/Math-Tests-Numerical/PMCovarianceAccumulatorTest.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMCovarianceAccumulatorTest,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #tests }
diff --git a/src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st b/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st
similarity index 98%
rename from src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st
rename to src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st
index dab8ca8b8..4ed382603 100644
--- a/src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st
+++ b/src/Math-Tests-Numerical/PMDecimalFloatingNumberTest.class.st
@@ -4,7 +4,7 @@ A DhbDecimalFloatingNumberTest is a test class for testing the behavior of DhbDe
Class {
#name : #PMDecimalFloatingNumberTest,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #tests }
diff --git a/src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st b/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st
similarity index 93%
rename from src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st
rename to src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st
index 9cdaeaf15..46022f2ad 100644
--- a/src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st
+++ b/src/Math-Tests-Numerical/PMExponentialDistributionTest.class.st
@@ -4,7 +4,7 @@ A DhbExponentialDistributionTest is a test class for testing the behavior of Dhb
Class {
#name : #PMExponentialDistributionTest,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #tests }
diff --git a/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st b/src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st
similarity index 90%
rename from src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st
rename to src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st
index 5c857e4e9..c6f885e87 100644
--- a/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st
+++ b/src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMFloatingPointMachineTestCase,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #precision }
@@ -75,16 +75,6 @@ PMFloatingPointMachineTestCase >> testMachinePrecisionSmallestNumberNotZero [
self assert: mach smallestNumber > 0.0
]
-{ #category : #precision }
-PMFloatingPointMachineTestCase >> testShowParameters [
- "included for coverage, test has no effect"
-
- self
- assert:
- (PMFloatingPointMachine new showParameters
- isKindOf: PMFloatingPointMachine)
-]
-
{ #category : #precision }
PMFloatingPointMachineTestCase >> testUniqueInstance [
| mach1 mach2 mach3 |
diff --git a/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st b/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st
similarity index 96%
rename from src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st
rename to src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st
index 22305a00a..9cb5b3700 100644
--- a/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st
+++ b/src/Math-Tests-Numerical/PMGeneticOptimizerBugsTest.class.st
@@ -6,7 +6,7 @@ Class {
'function',
'optimizer'
],
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #running }
diff --git a/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st
similarity index 83%
rename from src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st
rename to src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st
index 9ab2c8343..79ba75a55 100644
--- a/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st
+++ b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st
@@ -4,12 +4,12 @@ Class {
#instVars : [
'h'
],
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #comment }
PMHistogramTestsAndBugs >> readMe [
-"DhbHistogram is insofar a bit problematic as for most methods it first needs the cache to be flushed by hand, but DhbHistogram is used by some other dhb objects that tend to forget to do this. hence i had to add some minimum amount of flushCache routines, so that everything works properly which is tested here (and things didnt slowdown, i made some routines a tiny bit faster). since the cache gets flushed automatically when the cache is full and the default cachesize is 100 and with 100 datapoints there is no noticable speed difference with using a cache, i would guess that the author had set the default size so low that the routines would work in most cases (but - well - just in most cases). anyway i did not change the default cache size. a real bug was corrected and tested in testCountsBetween, testAdjustDimensionUpTo and also in testDhbHistogrammedDistribution ."
+"PMHistogram is insofar a bit problematic as for most methods it first needs the cache to be flushed by hand, but PMHistogram is used by some other PM objects that tend to forget to do this. hence i had to add some minimum amount of flushCache routines, so that everything works properly which is tested here (and things didnt slowdown, i made some routines a tiny bit faster). since the cache gets flushed automatically when the cache is full and the default cachesize is 100 and with 100 datapoints there is no noticable speed difference with using a cache, i would guess that the author had set the default size so low that the routines would work in most cases (but - well - just in most cases). anyway i did not change the default cache size. a real bug was corrected and tested in testCountsBetween, testAdjustDimensionUpTo and also in testPMHistogrammedDistribution ."
]
{ #category : #running }
diff --git a/src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st b/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st
similarity index 97%
rename from src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st
rename to src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st
index b7cef4718..9749fe67a 100644
--- a/src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st
+++ b/src/Math-Tests-Numerical/PMNumberExtensionsTestCase.class.st
@@ -4,7 +4,7 @@ A DhbNumberExtensionsTestCase is a suite of tests for extension methods to Numbe
Class {
#name : #PMNumberExtensionsTestCase,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #'function evaluation' }
diff --git a/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st b/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st
similarity index 99%
rename from src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st
rename to src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st
index fb5f84316..7288957b4 100644
--- a/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st
+++ b/src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMNumericalMethodsTestCase,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #privateMethods }
diff --git a/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st b/src/Math-Tests-Numerical/PMStatisticsBugs.class.st
similarity index 99%
rename from src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st
rename to src/Math-Tests-Numerical/PMStatisticsBugs.class.st
index afbbcd991..f5990521f 100644
--- a/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st
+++ b/src/Math-Tests-Numerical/PMStatisticsBugs.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMStatisticsBugs,
#superclass : #TestCase,
- #category : 'Math-Tests-DHB-Numerical'
+ #category : #'Math-Tests-Numerical'
}
{ #category : #tests }
diff --git a/src/Math-Tests-Numerical/package.st b/src/Math-Tests-Numerical/package.st
new file mode 100644
index 000000000..3fbffeaa6
--- /dev/null
+++ b/src/Math-Tests-Numerical/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-Numerical' }
diff --git a/src/Math-Tests-ODE/EulerSolverTest.class.st b/src/Math-Tests-ODE/EulerSolverTest.class.st
deleted file mode 100644
index 5997d8c43..000000000
--- a/src/Math-Tests-ODE/EulerSolverTest.class.st
+++ /dev/null
@@ -1,97 +0,0 @@
-"
-An ODESolverTest is a test class for testing the behavior of ODESolver
-"
-Class {
- #name : #EulerSolverTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-ODE'
-}
-
-{ #category : #'tests-solving' }
-EulerSolverTest >> testSimpleSystem2 [
- | solver stepper system dt |
- dt := 1.5.
- system := ExplicitSystem
- block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := HeunStepper onSystem: system.
- solver := ExplicitSolver new
- stepper: stepper;
- system: system;
- dt: dt.
- self
- assert:
- ((solver
- solve: system
- startState: 5
- startTime: 0
- endTime: 1.5) closeTo: 4.30204).
- self
- should:
- ((solver
- solve: system
- startState: 0
- startTime: 1
- endTime: 2.5) closeTo: 0.5158)
-]
-
-{ #category : #'tests-solving' }
-EulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [
- | solver stepper system dt finalState |
- dt := 0.2.
- system := ExplicitSystem block: [ :x :t | (t * x) exp ].
- stepper := ExplicitStepper onSystem: system.
- stepper stepSize: dt.
- solver := ExplicitSolver new
- system: system;
- stepper: stepper.
- finalState := solver
- solve: solver system
- startState: 0
- startTime: 0
- endTime: 1
- stepSize: dt.
- self assert: finalState isFloat.
-
- "Debgging information"
- Transcript
- show: self class name;
- cr;
- show: system block printString;
- cr;
- show: 'from x(0) = 0 to x(1) = ';
- show: finalState;
- cr;
- show: 'with stepSize = ' , solver dt printString;
- cr
-]
-
-{ #category : #'tests-solving' }
-EulerSolverTest >> testSolveX0T0T1 [
- | solver stepper system dt finalState |
- dt := 0.1.
- system := ExplicitSystem block: [ :x :t | (t * x) exp ].
- stepper := ExplicitStepper onSystem: system.
- stepper stepSize: dt.
- solver := ExplicitSolver new
- system: system;
- stepper: stepper;
- dt: dt.
- finalState := solver
- solve: solver system
- startState: 0
- startTime: 0
- endTime: 1.
- self assert: finalState isFloat.
-
- "Debgging information"
- Transcript
- show: self class name;
- cr;
- show: system block printString;
- cr;
- show: 'from x(0) = 0 to x(1) = ';
- show: finalState;
- cr;
- show: 'with stepSize = ' , solver dt printString;
- cr
-]
diff --git a/src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st b/src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st
deleted file mode 100644
index 865f6210a..000000000
--- a/src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st
+++ /dev/null
@@ -1,16 +0,0 @@
-Class {
- #name : #ImplicitMidpointSolverTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-ODE'
-}
-
-{ #category : #'tests-solving' }
-ImplicitMidpointSolverTest >> testSimpleSystem2 [
- | solver stepper system dt |
- dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := (ImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
- self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 4.9733).
- self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8242).
-]
diff --git a/src/Math-Tests-ODE/AB2SolverTest.class.st b/src/Math-Tests-ODE/PMAB2SolverTest.class.st
similarity index 57%
rename from src/Math-Tests-ODE/AB2SolverTest.class.st
rename to src/Math-Tests-ODE/PMAB2SolverTest.class.st
index 444301007..972ba657b 100644
--- a/src/Math-Tests-ODE/AB2SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMAB2SolverTest.class.st
@@ -1,58 +1,58 @@
Class {
- #name : #AB2SolverTest,
+ #name : #PMAB2SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-AB2SolverTest >> testSimpleSystem2 [
+PMAB2SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new stepper: stepper; system: system; dt: dt.
+ system := PMExplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new stepper: stepper; system: system; dt: dt.
self assert: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 1.1237).
self assert: ((solver solve: system startState: 0 startTime: 1 endTime: 4) closeTo: -0.2451).
]
{ #category : #'tests-solving' }
-AB2SolverTest >> testSimpleSystem3 [
+PMAB2SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [:x :t | 2 * t * x].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new stepper: stepper; system: system; dt: dt.
+ system := PMExplicitSystem block: [:x :t | 2 * t * x].
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new stepper: stepper; system: system; dt: dt.
self assert: ((solver solve: system startState: 1 startTime: 0 endTime: 1 ) closeTo: 2.1875).
self assert: ((solver solve: system startState: 1.25 startTime: 0.5 endTime: 2 ) closeTo: 17.4512).
]
{ #category : #'tests-solving' }
-AB2SolverTest >> testSimpleSystem4 [
+PMAB2SolverTest >> testSimpleSystem4 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [:x :t | 2 * (36 * (( t ln ) ** 2) + (6 * (t ln)) +7 ) /
+ system := PMExplicitSystem block: [:x :t | 2 * (36 * (( t ln ) ** 2) + (6 * (t ln)) +7 ) /
((t ** 3) * (1- (6 * (t ln))) ** 2)].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new stepper: stepper; system: system; dt: dt.
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new stepper: stepper; system: system; dt: dt.
self assert: ((solver solve: system startState: 2 startTime: 1 endTime: 4.5 ) closeTo: 22.3431).
]
{ #category : #'tests-solving' }
-AB2SolverTest >> testVectorSystem [
+PMAB2SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [:x :t |
+ system := PMExplicitSystem block: [:x :t |
| v |
v := PMVector new: 2.
v at: 1 put: t sin.
v at: 2 put: t cos.
v].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new stepper: stepper; system: system; dt: dt.
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new stepper: stepper; system: system; dt: dt.
self assert: (((solver solve: system startState: #(-1 0) startTime: 0 endTime: Float pi ) at: 1) closeTo: 1).
self assert: (((solver solve: system startState: #(-1 0) startTime: 0 endTime: Float pi / 2 ) at: 2 ) closeTo: 1).
]
diff --git a/src/Math-Tests-ODE/AB2StepperTest.class.st b/src/Math-Tests-ODE/PMAB2StepperTest.class.st
similarity index 68%
rename from src/Math-Tests-ODE/AB2StepperTest.class.st
rename to src/Math-Tests-ODE/PMAB2StepperTest.class.st
index c4ae41762..2e9053056 100644
--- a/src/Math-Tests-ODE/AB2StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMAB2StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #AB2StepperTest,
+ #name : #PMAB2StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-AB2StepperTest >> testOrderIsTwo [
- self assert: AB2Stepper order equals: 2
+PMAB2StepperTest >> testOrderIsTwo [
+ self assert: PMAB2Stepper order equals: 2
]
{ #category : #'tests-stepping' }
-AB2StepperTest >> testSimpleSystem [
+PMAB2StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,13 +29,13 @@ AB2StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-AB2StepperTest >> testSimpleSystem2 [
+PMAB2StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -56,12 +56,12 @@ AB2StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-AB2StepperTest >> testSimpleSystem3 [
+PMAB2StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AB2Stepper onSystem: system.
- solver := AB2Solver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAB2Stepper onSystem: system.
+ solver := PMAB2Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AB3SolverTest.class.st b/src/Math-Tests-ODE/PMAB3SolverTest.class.st
similarity index 72%
rename from src/Math-Tests-ODE/AB3SolverTest.class.st
rename to src/Math-Tests-ODE/PMAB3SolverTest.class.st
index 900943eac..02c96ab29 100644
--- a/src/Math-Tests-ODE/AB3SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMAB3SolverTest.class.st
@@ -1,17 +1,17 @@
Class {
- #name : #AB3SolverTest,
+ #name : #PMAB3SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-AB3SolverTest >> testSimpleSystem2 [
+PMAB3SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -32,12 +32,12 @@ AB3SolverTest >> testSimpleSystem2 [
]
{ #category : #'tests-solving' }
-AB3SolverTest >> testSimpleSystem3 [
+PMAB3SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -58,14 +58,14 @@ AB3SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-AB3SolverTest >> testSimpleSystem4 [
+PMAB3SolverTest >> testSimpleSystem4 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block:
[ :x :t | (2 negated * (t ** 4) * (x ** 2) + 1 - (x * (t ** 2))) / (t ** 3) ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -79,18 +79,18 @@ AB3SolverTest >> testSimpleSystem4 [
]
{ #category : #'tests-solving' }
-AB3SolverTest >> testVectorSystem [
+PMAB3SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.001.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AB3StepperTest.class.st b/src/Math-Tests-ODE/PMAB3StepperTest.class.st
similarity index 66%
rename from src/Math-Tests-ODE/AB3StepperTest.class.st
rename to src/Math-Tests-ODE/PMAB3StepperTest.class.st
index d219e946b..ae66d20cd 100644
--- a/src/Math-Tests-ODE/AB3StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMAB3StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #AB3StepperTest,
+ #name : #PMAB3StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-AB3StepperTest >> testOrderIsThree [
- self assert: AB3Stepper order equals: 3
+PMAB3StepperTest >> testOrderIsThree [
+ self assert: PMAB3Stepper order equals: 3
]
{ #category : #'tests-stepping' }
-AB3StepperTest >> testSimpleSystem [
+PMAB3StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,13 +29,13 @@ AB3StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-AB3StepperTest >> testSimpleSystem2 [
+PMAB3StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -56,12 +56,12 @@ AB3StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-AB3StepperTest >> testSimpleSystem3 [
+PMAB3StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AB3Stepper onSystem: system.
- solver := AB3Solver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAB3Stepper onSystem: system.
+ solver := PMAB3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AB4SolverTest.class.st b/src/Math-Tests-ODE/PMAB4SolverTest.class.st
similarity index 76%
rename from src/Math-Tests-ODE/AB4SolverTest.class.st
rename to src/Math-Tests-ODE/PMAB4SolverTest.class.st
index 210b8d7a7..b360760f9 100644
--- a/src/Math-Tests-ODE/AB4SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMAB4SolverTest.class.st
@@ -1,17 +1,17 @@
Class {
- #name : #AB4SolverTest,
+ #name : #PMAB4SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-AB4SolverTest >> testSimpleSystem2 [
+PMAB4SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -32,12 +32,12 @@ AB4SolverTest >> testSimpleSystem2 [
]
{ #category : #'tests-solving' }
-AB4SolverTest >> testSimpleSystem3 [
+PMAB4SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -79,18 +79,18 @@ AB4SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-AB4SolverTest >> testVectorSystem [
+PMAB4SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.001.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AB4StepperTest.class.st b/src/Math-Tests-ODE/PMAB4StepperTest.class.st
similarity index 66%
rename from src/Math-Tests-ODE/AB4StepperTest.class.st
rename to src/Math-Tests-ODE/PMAB4StepperTest.class.st
index 367fdf6c7..f766fcd79 100644
--- a/src/Math-Tests-ODE/AB4StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMAB4StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #AB4StepperTest,
+ #name : #PMAB4StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-AB4StepperTest >> testOrderIsFour [
- self assert: AB4Stepper order equals: 4
+PMAB4StepperTest >> testOrderIsFour [
+ self assert: PMAB4Stepper order equals: 4
]
{ #category : #'tests-stepping' }
-AB4StepperTest >> testSimpleSystem [
+PMAB4StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,13 +29,13 @@ AB4StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-AB4StepperTest >> testSimpleSystem2 [
+PMAB4StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -56,12 +56,12 @@ AB4StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-AB4StepperTest >> testSimpleSystem3 [
+PMAB4StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AB4Stepper onSystem: system.
- solver := AB4Solver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAB4Stepper onSystem: system.
+ solver := PMAB4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AM3SolverTest.class.st b/src/Math-Tests-ODE/PMAM3SolverTest.class.st
similarity index 70%
rename from src/Math-Tests-ODE/AM3SolverTest.class.st
rename to src/Math-Tests-ODE/PMAM3SolverTest.class.st
index 7c9edaa6e..3b8f7d4d8 100644
--- a/src/Math-Tests-ODE/AM3SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMAM3SolverTest.class.st
@@ -1,28 +1,28 @@
Class {
- #name : #AM3SolverTest,
+ #name : #PMAM3SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-AM3SolverTest >> testSimpleSystem2 [
+PMAM3SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := AM3Stepper onSystem: system.
- solver := (AM3Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMAM3Stepper onSystem: system.
+ solver := (PMAM3Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.8978).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577).
]
{ #category : #'tests-solving' }
-AM3SolverTest >> testSimpleSystem3 [
+PMAM3SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AM3Stepper onSystem: system.
- solver := AM3Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAM3Stepper onSystem: system.
+ solver := PMAM3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,18 +57,18 @@ AM3SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-AM3SolverTest >> testVectorSystem [
+PMAM3SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := AM3Stepper onSystem: system.
- solver := AM3Solver new
+ stepper := PMAM3Stepper onSystem: system.
+ solver := PMAM3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AM3StepperTest.class.st b/src/Math-Tests-ODE/PMAM3StepperTest.class.st
similarity index 69%
rename from src/Math-Tests-ODE/AM3StepperTest.class.st
rename to src/Math-Tests-ODE/PMAM3StepperTest.class.st
index 49b58fcf8..e01071de6 100644
--- a/src/Math-Tests-ODE/AM3StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMAM3StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #AM3StepperTest,
+ #name : #PMAM3StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-AM3StepperTest >> testOrderIsThree [
- self assert: AM3Stepper order equals: 3
+PMAM3StepperTest >> testOrderIsThree [
+ self assert: PMAM3Stepper order equals: 3
]
{ #category : #'tests-stepping' }
-AM3StepperTest >> testSimpleSystem [
+PMAM3StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := AM3Stepper onSystem: system.
- solver := AM3Solver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMAM3Stepper onSystem: system.
+ solver := PMAM3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,12 +29,12 @@ AM3StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-AM3StepperTest >> testSimpleSystem2 [
+PMAM3StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := AM3Stepper onSystem: system.
- solver := (AM3Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMAM3Stepper onSystem: system.
+ solver := (PMAM3Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.8977).
@@ -42,12 +42,12 @@ AM3StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-AM3StepperTest >> testSimpleSystem3 [
+PMAM3StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AM3Stepper onSystem: system.
- solver := AM3Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAM3Stepper onSystem: system.
+ solver := PMAM3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -82,18 +82,18 @@ AM3StepperTest >> testSimpleSystem3 [
]
{ #category : #'tests-stepping' }
-AM3StepperTest >> testVectorSystem [
+PMAM3StepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := AM3Stepper onSystem: system.
- solver := AM3Solver new
+ stepper := PMAM3Stepper onSystem: system.
+ solver := PMAM3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AM4SolverTest.class.st b/src/Math-Tests-ODE/PMAM4SolverTest.class.st
similarity index 70%
rename from src/Math-Tests-ODE/AM4SolverTest.class.st
rename to src/Math-Tests-ODE/PMAM4SolverTest.class.st
index 22caf7824..4c09c9bfc 100644
--- a/src/Math-Tests-ODE/AM4SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMAM4SolverTest.class.st
@@ -1,28 +1,28 @@
Class {
- #name : #AM4SolverTest,
+ #name : #PMAM4SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-AM4SolverTest >> testSimpleSystem2 [
+PMAM4SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := AM4Stepper onSystem: system.
- solver := (AM4Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMAM4Stepper onSystem: system.
+ solver := (PMAM4Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.6231).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8577).
]
{ #category : #'tests-solving' }
-AM4SolverTest >> testSimpleSystem3 [
+PMAM4SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AM4Stepper onSystem: system.
- solver := AM4Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAM4Stepper onSystem: system.
+ solver := PMAM4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,18 +57,18 @@ AM4SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-AM4SolverTest >> testVectorSystem [
+PMAM4SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := AM4Stepper onSystem: system.
- solver := AM4Solver new
+ stepper := PMAM4Stepper onSystem: system.
+ solver := PMAM4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/AM4StepperTest.class.st b/src/Math-Tests-ODE/PMAM4StepperTest.class.st
similarity index 64%
rename from src/Math-Tests-ODE/AM4StepperTest.class.st
rename to src/Math-Tests-ODE/PMAM4StepperTest.class.st
index df2aacf50..8e53d4073 100644
--- a/src/Math-Tests-ODE/AM4StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMAM4StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #AM4StepperTest,
+ #name : #PMAM4StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-AM4StepperTest >> testOrderIsFour [
- self assert: AM4Stepper order equals: 4
+PMAM4StepperTest >> testOrderIsFour [
+ self assert: PMAM4Stepper order equals: 4
]
{ #category : #'tests-stepping' }
-AM4StepperTest >> testSimpleSystem [
+PMAM4StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := AM4Stepper onSystem: system.
- solver := AM4Solver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMAM4Stepper onSystem: system.
+ solver := PMAM4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,12 +29,12 @@ AM4StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-AM4StepperTest >> testSimpleSystem2 [
+PMAM4StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := AM4Stepper onSystem: system.
- solver := (AM4Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMAM4Stepper onSystem: system.
+ solver := (PMAM4Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 4.5912).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.9614).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 2.6231).
@@ -42,12 +42,12 @@ AM4StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-AM4StepperTest >> testSimpleSystem3 [
+PMAM4StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := AM4Stepper onSystem: system.
- solver := AM4Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMAM4Stepper onSystem: system.
+ solver := PMAM4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BDF2SolverTest.class.st b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st
similarity index 51%
rename from src/Math-Tests-ODE/BDF2SolverTest.class.st
rename to src/Math-Tests-ODE/PMBDF2SolverTest.class.st
index d51b4a6d4..5ff9aa6bc 100644
--- a/src/Math-Tests-ODE/BDF2SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st
@@ -1,28 +1,28 @@
Class {
- #name : #BDF2SolverTest,
+ #name : #PMBDF2SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-BDF2SolverTest >> testSimpleSystem2 [
+PMBDF2SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF2Stepper onSystem: system.
- solver := (BDF2Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := (PMBDF2Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306).
]
{ #category : #'tests-solving' }
-BDF2SolverTest >> testSimpleSystem3 [
+PMBDF2SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF2Stepper onSystem: system.
- solver := BDF2Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := PMBDF2Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,13 +57,13 @@ BDF2SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-BDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [
+PMBDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [
| solver stepper system dt finalState |
dt := 0.2.
- system := ImplicitSystem block: [ :x :t | (t * x) exp ].
- stepper := ImplicitStepper onSystem: system.
+ system := PMImplicitSystem block: [ :x :t | (t * x) exp ].
+ stepper := PMImplicitStepper onSystem: system.
stepper stepSize: dt.
- solver := BDF2Solver new
+ solver := PMBDF2Solver new
system: system;
stepper: stepper.
finalState := solver
@@ -72,29 +72,17 @@ BDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [
startTime: 0
endTime: 1
stepSize: dt.
- self assert: finalState isFloat.
-
- "Debgging information"
- Transcript
- show: self class name;
- cr;
- show: system block printString;
- cr;
- show: 'from x(0) = 0 to x(1) = ';
- show: finalState;
- cr;
- show: 'with stepSize = ' , solver dt printString;
- cr
+ self assert: finalState isFloat
]
{ #category : #'tests-solving' }
-BDF2SolverTest >> testSolveX0T0T1 [
+PMBDF2SolverTest >> testSolveX0T0T1 [
| solver stepper system dt finalState |
dt := 0.1.
- system := ImplicitSystem block: [ :x :t | (t * x) exp ].
- stepper := ImplicitStepper onSystem: system.
+ system := PMImplicitSystem block: [ :x :t | (t * x) exp ].
+ stepper := PMImplicitStepper onSystem: system.
stepper stepSize: dt.
- solver := BDF2Solver new
+ solver := PMBDF2Solver new
system: system;
stepper: stepper;
dt: dt.
@@ -103,17 +91,5 @@ BDF2SolverTest >> testSolveX0T0T1 [
startState: 0
startTime: 0
endTime: 1.
- self assert: finalState isFloat.
-
- "Debgging information"
- Transcript
- show: self class name;
- cr;
- show: system block printString;
- cr;
- show: 'from x(0) = 0 to x(1) = ';
- show: finalState;
- cr;
- show: 'with stepSize = ' , solver dt printString;
- cr
+ self assert: finalState isFloat
]
diff --git a/src/Math-Tests-ODE/BDF2StepperTest.class.st b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st
similarity index 68%
rename from src/Math-Tests-ODE/BDF2StepperTest.class.st
rename to src/Math-Tests-ODE/PMBDF2StepperTest.class.st
index 3c7cb6b9f..3025f1063 100644
--- a/src/Math-Tests-ODE/BDF2StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #BDF2StepperTest,
+ #name : #PMBDF2StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-BDF2StepperTest >> testOrderIsTwo [
- self assert: BDF2Stepper order equals: 2
+PMBDF2StepperTest >> testOrderIsTwo [
+ self assert: PMBDF2Stepper order equals: 2
]
{ #category : #'tests-stepping' }
-BDF2StepperTest >> testSimpleSystem [
+PMBDF2StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := BDF2Stepper onSystem: system.
- solver := BDF2Solver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := PMBDF2Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,12 +29,12 @@ BDF2StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-BDF2StepperTest >> testSimpleSystem2 [
+PMBDF2StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF2Stepper onSystem: system.
- solver := (BDF2Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := (PMBDF2Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985).
@@ -43,12 +43,12 @@ BDF2StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-BDF2StepperTest >> testSimpleSystem3 [
+PMBDF2StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF2Stepper onSystem: system.
- solver := BDF2Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := PMBDF2Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -83,18 +83,18 @@ BDF2StepperTest >> testSimpleSystem3 [
]
{ #category : #'tests-stepping' }
-BDF2StepperTest >> testVectorSystem [
+PMBDF2StepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.0001.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := BDF2Stepper onSystem: system.
- solver := BDF2Solver new
+ stepper := PMBDF2Stepper onSystem: system.
+ solver := PMBDF2Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BDF3SolverTest.class.st b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st
similarity index 70%
rename from src/Math-Tests-ODE/BDF3SolverTest.class.st
rename to src/Math-Tests-ODE/PMBDF3SolverTest.class.st
index 0fb65a690..f8a0ac823 100644
--- a/src/Math-Tests-ODE/BDF3SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st
@@ -1,28 +1,28 @@
Class {
- #name : #BDF3SolverTest,
+ #name : #PMBDF3SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-BDF3SolverTest >> testSimpleSystem2 [
+PMBDF3SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF3Stepper onSystem: system.
- solver := (BDF3Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := (PMBDF3Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.54985).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306).
]
{ #category : #'tests-solving' }
-BDF3SolverTest >> testSimpleSystem3 [
+PMBDF3SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF3Stepper onSystem: system.
- solver := BDF3Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := PMBDF3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,18 +57,18 @@ BDF3SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-BDF3SolverTest >> testVectorSystem [
+PMBDF3SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := BDF3Stepper onSystem: system.
- solver := BDF3Solver new
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := PMBDF3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BDF3StepperTest.class.st b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st
similarity index 64%
rename from src/Math-Tests-ODE/BDF3StepperTest.class.st
rename to src/Math-Tests-ODE/PMBDF3StepperTest.class.st
index f45237145..2e6d075db 100644
--- a/src/Math-Tests-ODE/BDF3StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #BDF3StepperTest,
+ #name : #PMBDF3StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-BDF3StepperTest >> testOrderIsThree [
- self assert: BDF3Stepper order equals: 3
+PMBDF3StepperTest >> testOrderIsThree [
+ self assert: PMBDF3Stepper order equals: 3
]
{ #category : #'tests-stepping' }
-BDF3StepperTest >> testSimpleSystem [
+PMBDF3StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := BDF3Stepper onSystem: system.
- solver := BDF3Solver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := PMBDF3Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,12 +29,12 @@ BDF3StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-BDF3StepperTest >> testSimpleSystem2 [
+PMBDF3StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF3Stepper onSystem: system.
- solver := (BDF3Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := (PMBDF3Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 1.10147).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10409).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3.0) closeTo: 0.54985).
@@ -42,12 +42,12 @@ BDF3StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-BDF3StepperTest >> testSimpleSystem3 [
+PMBDF3StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF3Stepper onSystem: system.
- solver := BDF3Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF3Stepper onSystem: system.
+ solver := PMBDF3Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BDF4SolverTest.class.st b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st
similarity index 73%
rename from src/Math-Tests-ODE/BDF4SolverTest.class.st
rename to src/Math-Tests-ODE/PMBDF4SolverTest.class.st
index 387855cf9..19a735170 100644
--- a/src/Math-Tests-ODE/BDF4SolverTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #BDF4SolverTest,
+ #name : #PMBDF4SolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-BDF4SolverTest >> testSimpleSystem2 [
+PMBDF4SolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF4Stepper onSystem: system.
- solver := (BDF4Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := (PMBDF4Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 2.5637).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.4395).
@@ -18,12 +18,12 @@ BDF4SolverTest >> testSimpleSystem2 [
]
{ #category : #'tests-solving' }
-BDF4SolverTest >> testSimpleSystem3 [
+PMBDF4SolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF4Stepper onSystem: system.
- solver := BDF4Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := PMBDF4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -65,18 +65,18 @@ BDF4SolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-BDF4SolverTest >> testVectorSystem [
+PMBDF4SolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := BDF4Stepper onSystem: system.
- solver := BDF4Solver new
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := PMBDF4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BDF4StepperTest.class.st b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st
similarity index 70%
rename from src/Math-Tests-ODE/BDF4StepperTest.class.st
rename to src/Math-Tests-ODE/PMBDF4StepperTest.class.st
index c842c7efc..a3cfb94da 100644
--- a/src/Math-Tests-ODE/BDF4StepperTest.class.st
+++ b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #BDF4StepperTest,
+ #name : #PMBDF4StepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-BDF4StepperTest >> testOrderIsFour [
- self assert: BDF4Stepper order equals: 4
+PMBDF4StepperTest >> testOrderIsFour [
+ self assert: PMBDF4Stepper order equals: 4
]
{ #category : #'tests-stepping' }
-BDF4StepperTest >> testSimpleSystem [
+PMBDF4StepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := BDF4Stepper onSystem: system.
- solver := BDF4Solver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := PMBDF4Solver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,12 +29,12 @@ BDF4StepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-BDF4StepperTest >> testSimpleSystem2 [
+PMBDF4StepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := BDF4Stepper onSystem: system.
- solver := (BDF4Solver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := (PMBDF4Solver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 4.03597).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.7) closeTo: 3.6812).
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 2.0) closeTo: 3.5316).
@@ -43,12 +43,12 @@ BDF4StepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-BDF4StepperTest >> testSimpleSystem3 [
+PMBDF4StepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := BDF4Stepper onSystem: system.
- solver := BDF4Solver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMBDF4Stepper onSystem: system.
+ solver := PMBDF4Solver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st
similarity index 61%
rename from src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st
rename to src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st
index 92dfec4a6..f399e0874 100644
--- a/src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st
+++ b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #BeckwardEulerSolverTest,
+ #name : #PMBeckwardEulerSolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-BeckwardEulerSolverTest >> testSimpleSystem [
+PMBeckwardEulerSolverTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := ImplicitStepper onSystem: system.
- solver := ImplicitSolver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMImplicitStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -24,29 +24,29 @@ BeckwardEulerSolverTest >> testSimpleSystem [
]
{ #category : #'tests-solving' }
-BeckwardEulerSolverTest >> testSimpleSystem2 [
+PMBeckwardEulerSolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := ImplicitStepper onSystem: system.
- solver := (ImplicitSolver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMImplicitStepper onSystem: system.
+ solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 0.16567).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306).
]
{ #category : #'tests-solving' }
-BeckwardEulerSolverTest >> testVectorSystem [
+PMBeckwardEulerSolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := ImplicitStepper onSystem: system.
- solver := ImplicitSolver new
+ stepper := PMImplicitStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st
similarity index 64%
rename from src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st
rename to src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st
index 3528fe026..f15d31a35 100644
--- a/src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #BeckwardEulerStepperTest,
+ #name : #PMBeckwardEulerStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-BeckwardEulerStepperTest >> testDoStepTime [
+PMBeckwardEulerStepperTest >> testDoStepTime [
"this is identical to testDoStepTimeStepSize except dt is stored."
| stepper sys dt |
- sys := ImplicitSystem block: [ :x :t | x * t ].
- stepper := ImplicitStepper onSystem: sys.
+ sys := PMImplicitSystem block: [ :x :t | x * t ].
+ stepper := PMImplicitStepper onSystem: sys.
dt := 0.1.
stepper stepSize: dt.
self assert: stepper stepSize equals: dt.
@@ -26,10 +26,10 @@ BeckwardEulerStepperTest >> testDoStepTime [
]
{ #category : #'tests-stepping' }
-BeckwardEulerStepperTest >> testDoStepTimeStepSize [
+PMBeckwardEulerStepperTest >> testDoStepTimeStepSize [
| stepper sys dt |
- sys := ImplicitSystem block: [ :x :t | x * t ].
- stepper := ImplicitStepper onSystem: sys.
+ sys := PMImplicitSystem block: [ :x :t | x * t ].
+ stepper := PMImplicitStepper onSystem: sys.
dt := 0.1.
self assert: (stepper doStep: 0 time: 10 stepSize: dt) equals: 0.101.
self assert: (stepper doStep: 10 time: 0 stepSize: dt) equals: 10.101.
@@ -38,23 +38,23 @@ BeckwardEulerStepperTest >> testDoStepTimeStepSize [
]
{ #category : #'tests-stepping' }
-BeckwardEulerStepperTest >> testSimpleSystem2 [
+PMBeckwardEulerStepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := ImplicitStepper onSystem: system.
- solver := (ImplicitSolver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMImplicitStepper onSystem: system.
+ solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 2.10408).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: -0.5306).
]
{ #category : #'tests-stepping' }
-BeckwardEulerStepperTest >> testSimpleSystem3 [
+PMBeckwardEulerStepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := ImplicitStepper onSystem: system.
- solver := ImplicitSolver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMImplicitStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/PMEulerSolverTest.class.st b/src/Math-Tests-ODE/PMEulerSolverTest.class.st
new file mode 100644
index 000000000..92cb286a0
--- /dev/null
+++ b/src/Math-Tests-ODE/PMEulerSolverTest.class.st
@@ -0,0 +1,73 @@
+"
+An ODESolverTest is a test class for testing the behavior of ODESolver
+"
+Class {
+ #name : #PMEulerSolverTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-ODE'
+}
+
+{ #category : #'tests-solving' }
+PMEulerSolverTest >> testSimpleSystem2 [
+ | solver stepper system dt |
+ dt := 1.5.
+ system := PMExplicitSystem
+ block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
+ stepper := PMHeunStepper onSystem: system.
+ solver := PMExplicitSolver new
+ stepper: stepper;
+ system: system;
+ dt: dt.
+ self
+ assert:
+ ((solver
+ solve: system
+ startState: 5
+ startTime: 0
+ endTime: 1.5) closeTo: 4.30204).
+ self
+ should:
+ ((solver
+ solve: system
+ startState: 0
+ startTime: 1
+ endTime: 2.5) closeTo: 0.5158)
+]
+
+{ #category : #'tests-solving' }
+PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [
+ | solver stepper system dt finalState |
+ dt := 0.2.
+ system := PMExplicitSystem block: [ :x :t | (t * x) exp ].
+ stepper := PMExplicitStepper onSystem: system.
+ stepper stepSize: dt.
+ solver := PMExplicitSolver new
+ system: system;
+ stepper: stepper.
+ finalState := solver
+ solve: solver system
+ startState: 0
+ startTime: 0
+ endTime: 1
+ stepSize: dt.
+ self assert: finalState isFloat
+]
+
+{ #category : #'tests-solving' }
+PMEulerSolverTest >> testSolveX0T0T1 [
+ | solver stepper system dt finalState |
+ dt := 0.1.
+ system := PMExplicitSystem block: [ :x :t | (t * x) exp ].
+ stepper := PMExplicitStepper onSystem: system.
+ stepper stepSize: dt.
+ solver := PMExplicitSolver new
+ system: system;
+ stepper: stepper;
+ dt: dt.
+ finalState := solver
+ solve: solver system
+ startState: 0
+ startTime: 0
+ endTime: 1.
+ self assert: finalState isFloat
+]
diff --git a/src/Math-Tests-ODE/EulerStepperTest.class.st b/src/Math-Tests-ODE/PMEulerStepperTest.class.st
similarity index 73%
rename from src/Math-Tests-ODE/EulerStepperTest.class.st
rename to src/Math-Tests-ODE/PMEulerStepperTest.class.st
index 5acf749f1..cda9ab668 100644
--- a/src/Math-Tests-ODE/EulerStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMEulerStepperTest.class.st
@@ -2,18 +2,18 @@
An ExplicitStepperTest is a test class for testing the behavior of ExplicitStepper
"
Class {
- #name : #EulerStepperTest,
+ #name : #PMEulerStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-EulerStepperTest >> testDoStepTime [
+PMEulerStepperTest >> testDoStepTime [
"this is identical to testDoStepTimeStepSize except dt is stored."
| stepper sys dt |
- sys := ExplicitSystem block: [ :x :t | x * t ].
- stepper := ExplicitStepper onSystem: sys.
+ sys := PMExplicitSystem block: [ :x :t | x * t ].
+ stepper := PMExplicitStepper onSystem: sys.
dt := 0.1.
stepper stepSize: dt.
self assert: stepper stepSize equals: dt.
@@ -27,10 +27,10 @@ EulerStepperTest >> testDoStepTime [
]
{ #category : #'tests-stepping' }
-EulerStepperTest >> testDoStepTimeStepSize [
+PMEulerStepperTest >> testDoStepTimeStepSize [
| stepper sys dt |
- sys := ExplicitSystem block: [ :x :t | x * t ].
- stepper := ExplicitStepper onSystem: sys.
+ sys := PMExplicitSystem block: [ :x :t | x * t ].
+ stepper := PMExplicitStepper onSystem: sys.
dt := 0.1.
self assert: (stepper doStep: 0 time: 10 stepSize: dt) equals: 0.
self assert: (stepper doStep: 10 time: 0 stepSize: dt) equals: 10.
@@ -39,26 +39,26 @@ EulerStepperTest >> testDoStepTimeStepSize [
]
{ #category : #'tests-stepping' }
-EulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [
+PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [
| order |
- order := ExplicitStepper new order.
+ order := PMExplicitStepper new order.
self assert: order notNil.
self assert: order equals: 1
]
{ #category : #'tests-stepping' }
-EulerStepperTest >> testVectorSystem [
+PMEulerStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.001.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := ExplicitStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMExplicitStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/HeunStepperTest.class.st b/src/Math-Tests-ODE/PMHeunStepperTest.class.st
similarity index 66%
rename from src/Math-Tests-ODE/HeunStepperTest.class.st
rename to src/Math-Tests-ODE/PMHeunStepperTest.class.st
index ca001422f..74777b16b 100644
--- a/src/Math-Tests-ODE/HeunStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMHeunStepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #HeunStepperTest,
+ #name : #PMHeunStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #tests }
-HeunStepperTest >> testOrderIsTwo [
- self assert: HeunStepper order equals: 2
+PMHeunStepperTest >> testOrderIsTwo [
+ self assert: PMHeunStepper order equals: 2
]
{ #category : #tests }
-HeunStepperTest >> testSimpleSystem [
+PMHeunStepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := HeunStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMHeunStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,13 +29,13 @@ HeunStepperTest >> testSimpleSystem [
]
{ #category : #tests }
-HeunStepperTest >> testSimpleSystem2 [
+PMHeunStepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := HeunStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMHeunStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -56,12 +56,12 @@ HeunStepperTest >> testSimpleSystem2 [
]
{ #category : #tests }
-HeunStepperTest >> testSimpleSystem3 [
+PMHeunStepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := HeunStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMHeunStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -82,18 +82,18 @@ HeunStepperTest >> testSimpleSystem3 [
]
{ #category : #tests }
-HeunStepperTest >> testVectorSystem [
+PMHeunStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := HeunStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMHeunStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st
new file mode 100644
index 000000000..5322796d8
--- /dev/null
+++ b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st
@@ -0,0 +1,16 @@
+Class {
+ #name : #PMImplicitMidpointSolverTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-ODE'
+}
+
+{ #category : #'tests-solving' }
+PMImplicitMidpointSolverTest >> testSimpleSystem2 [
+ | solver stepper system dt |
+ dt := 1.5.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := (PMImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
+ self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 4.9733).
+ self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8242).
+]
diff --git a/src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st
similarity index 56%
rename from src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st
rename to src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st
index f41419c32..6c51b73a0 100644
--- a/src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #ImplicitMidpointStepperTest,
+ #name : #PMImplicitMidpointStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-ImplicitMidpointStepperTest >> testOrderIsTwo [
- self assert: ImplicitMidpointStepper order equals: 2
+PMImplicitMidpointStepperTest >> testOrderIsTwo [
+ self assert: PMImplicitMidpointStepper order equals: 2
]
{ #category : #'tests-stepping' }
-ImplicitMidpointStepperTest >> testSimpleSystem [
+PMImplicitMidpointStepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem block: [ :x :t | t sin ].
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := ImplicitMidpointSolver new
+ system := PMImplicitSystem block: [ :x :t | t sin ].
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := PMImplicitMidpointSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,23 +29,23 @@ ImplicitMidpointStepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-ImplicitMidpointStepperTest >> testSimpleSystem2 [
+PMImplicitMidpointStepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := (ImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := (PMImplicitMidpointSolver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 1.5) closeTo: 5.9805).
self should: ((solver solve: system startState: 0 startTime: 1 endTime: 2.5) closeTo: 0.8242).
]
{ #category : #'tests-stepping' }
-ImplicitMidpointStepperTest >> testSimpleSystem3 [
+PMImplicitMidpointStepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := ImplicitMidpointSolver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := PMImplicitMidpointSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -59,18 +59,18 @@ ImplicitMidpointStepperTest >> testSimpleSystem3 [
]
{ #category : #'tests-stepping' }
-ImplicitMidpointStepperTest >> testVectorSystem [
+PMImplicitMidpointStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := ImplicitMidpointStepper onSystem: system.
- solver := ImplicitMidpointSolver new
+ stepper := PMImplicitMidpointStepper onSystem: system.
+ solver := PMImplicitMidpointSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/MidpointSolverTest.class.st b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st
similarity index 72%
rename from src/Math-Tests-ODE/MidpointSolverTest.class.st
rename to src/Math-Tests-ODE/PMMidpointSolverTest.class.st
index bd7b431a3..cf22ef05f 100644
--- a/src/Math-Tests-ODE/MidpointSolverTest.class.st
+++ b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #MidpointSolverTest,
+ #name : #PMMidpointSolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-MidpointSolverTest >> testSimpleSystem [
+PMMidpointSolverTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -24,12 +24,12 @@ MidpointSolverTest >> testSimpleSystem [
]
{ #category : #'tests-solving' }
-MidpointSolverTest >> testSimpleSystem1 [
+PMMidpointSolverTest >> testSimpleSystem1 [
| solver stepper system dt |
dt := 0.025.
- system := ExplicitSystem block: [ :x :t | t tan + 1 ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t tan + 1 ].
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,13 +57,13 @@ MidpointSolverTest >> testSimpleSystem1 [
]
{ #category : #'tests-solving' }
-MidpointSolverTest >> testSimpleSystem2 [
+PMMidpointSolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -91,12 +91,12 @@ MidpointSolverTest >> testSimpleSystem2 [
]
{ #category : #'tests-solving' }
-MidpointSolverTest >> testSimpleSystem3 [
+PMMidpointSolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -131,18 +131,18 @@ MidpointSolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-MidpointSolverTest >> testVectorSystem [
+PMMidpointSolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/MidpointStepperTest.class.st b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st
similarity index 67%
rename from src/Math-Tests-ODE/MidpointStepperTest.class.st
rename to src/Math-Tests-ODE/PMMidpointStepperTest.class.st
index f925a23be..271a113e9 100644
--- a/src/Math-Tests-ODE/MidpointStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st
@@ -1,21 +1,21 @@
Class {
- #name : #MidpointStepperTest,
+ #name : #PMMidpointStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testOrderIsTwo [
- self assert: MidpointStepper order equals: 2
+PMMidpointStepperTest >> testOrderIsTwo [
+ self assert: PMMidpointStepper order equals: 2
]
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testSimpleSystem [
+PMMidpointStepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -29,13 +29,13 @@ MidpointStepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testSimpleSystem2 [
+PMMidpointStepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -56,12 +56,12 @@ MidpointStepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testSimpleSystem3 [
+PMMidpointStepperTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -89,13 +89,13 @@ MidpointStepperTest >> testSimpleSystem3 [
]
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testSimpleSystem4 [
+PMMidpointStepperTest >> testSimpleSystem4 [
| solver stepper system dt |
dt := 0.0001.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -109,18 +109,18 @@ MidpointStepperTest >> testSimpleSystem4 [
]
{ #category : #'tests-stepping' }
-MidpointStepperTest >> testVectorSystem [
+PMMidpointStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := MidpointStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMMidpointStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/ODESystemTest.class.st b/src/Math-Tests-ODE/PMODESystemTest.class.st
similarity index 80%
rename from src/Math-Tests-ODE/ODESystemTest.class.st
rename to src/Math-Tests-ODE/PMODESystemTest.class.st
index 2a08e42ab..3075495b8 100644
--- a/src/Math-Tests-ODE/ODESystemTest.class.st
+++ b/src/Math-Tests-ODE/PMODESystemTest.class.st
@@ -2,22 +2,22 @@
An ODESystemTest is a test class for testing the behavior of ODESystem
"
Class {
- #name : #ODESystemTest,
+ #name : #PMODESystemTest,
#superclass : #TestCase,
#instVars : [
'sys'
],
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #initialization }
-ODESystemTest >> setUp [
+PMODESystemTest >> setUp [
"create a dummy system"
- sys := ODESystem new
+ sys := PMODESystem new
]
{ #category : #tests }
-ODESystemTest >> testBlock [
+PMODESystemTest >> testBlock [
| aBlock |
aBlock := [ :x :t | t ].
sys block: aBlock.
@@ -25,7 +25,7 @@ ODESystemTest >> testBlock [
]
{ #category : #tests }
-ODESystemTest >> testVectorBlock [
+PMODESystemTest >> testVectorBlock [
"this illustrates using a block that operates on a collection"
| aBlock |
@@ -35,7 +35,7 @@ ODESystemTest >> testVectorBlock [
]
{ #category : #tests }
-ODESystemTest >> testVectorXT [
+PMODESystemTest >> testVectorXT [
"a simple example of using a collection as state"
| aBlock |
@@ -46,7 +46,7 @@ ODESystemTest >> testVectorXT [
]
{ #category : #tests }
-ODESystemTest >> testXT [
+PMODESystemTest >> testXT [
| aBlock |
aBlock := [ :x :t | t ].
sys block: aBlock.
diff --git a/src/Math-Tests-ODE/RungeKuttaSolverTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st
similarity index 71%
rename from src/Math-Tests-ODE/RungeKuttaSolverTest.class.st
rename to src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st
index 880da0416..cc310e1ba 100644
--- a/src/Math-Tests-ODE/RungeKuttaSolverTest.class.st
+++ b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #RungeKuttaSolverTest,
+ #name : #PMRungeKuttaSolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-RungeKuttaSolverTest >> testSimpleSystem [
+PMRungeKuttaSolverTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -24,12 +24,12 @@ RungeKuttaSolverTest >> testSimpleSystem [
]
{ #category : #'tests-solving' }
-RungeKuttaSolverTest >> testSimpleSystem1 [
+PMRungeKuttaSolverTest >> testSimpleSystem1 [
| solver stepper system dt |
dt := 0.025.
- system := ExplicitSystem block: [ :x :t | t tan + 1 ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t tan + 1 ].
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,13 +57,13 @@ RungeKuttaSolverTest >> testSimpleSystem1 [
]
{ #category : #'tests-solving' }
-RungeKuttaSolverTest >> testSimpleSystem2 [
+PMRungeKuttaSolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -91,12 +91,12 @@ RungeKuttaSolverTest >> testSimpleSystem2 [
]
{ #category : #'tests-solving' }
-RungeKuttaSolverTest >> testSimpleSystem3 [
+PMRungeKuttaSolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ExplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -131,18 +131,18 @@ RungeKuttaSolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-RungeKuttaSolverTest >> testVectorSystem [
+PMRungeKuttaSolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/RungeKuttaStepperTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st
similarity index 66%
rename from src/Math-Tests-ODE/RungeKuttaStepperTest.class.st
rename to src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st
index 84eb1dec8..d88ddf34e 100644
--- a/src/Math-Tests-ODE/RungeKuttaStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st
@@ -1,14 +1,14 @@
Class {
- #name : #RungeKuttaStepperTest,
+ #name : #PMRungeKuttaStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testDoStepTimeStepSize1 [
+PMRungeKuttaStepperTest >> testDoStepTimeStepSize1 [
| stepper sys dt |
- sys := ExplicitSystem block: [ :x :t | x * t ].
- stepper := RungeKuttaStepper onSystem: sys.
+ sys := PMExplicitSystem block: [ :x :t | x * t ].
+ stepper := PMRungeKuttaStepper onSystem: sys.
dt := 0.1.
self assert: ((stepper doStep: 0 time: 10 stepSize: dt) closeTo: 0.0).
self
@@ -20,11 +20,11 @@ RungeKuttaStepperTest >> testDoStepTimeStepSize1 [
]
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testDoStepTimeStepSize2 [
+PMRungeKuttaStepperTest >> testDoStepTimeStepSize2 [
| stepper sys dt |
- sys := ExplicitSystem
+ sys := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := RungeKuttaStepper onSystem: sys.
+ stepper := PMRungeKuttaStepper onSystem: sys.
dt := 0.1.
self
assert: ((stepper doStep: 1 time: 1 stepSize: dt) closeTo: 1.0638).
@@ -33,17 +33,17 @@ RungeKuttaStepperTest >> testDoStepTimeStepSize2 [
]
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testOrderIsFour [
- self assert: RungeKuttaStepper order equals: 4
+PMRungeKuttaStepperTest >> testOrderIsFour [
+ self assert: PMRungeKuttaStepper order equals: 4
]
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testSimpleSystem [
+PMRungeKuttaStepperTest >> testSimpleSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem block: [ :x :t | t sin ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ system := PMExplicitSystem block: [ :x :t | t sin ].
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,13 +57,13 @@ RungeKuttaStepperTest >> testSimpleSystem [
]
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testSimpleSystem2 [
+PMRungeKuttaStepperTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -84,18 +84,18 @@ RungeKuttaStepperTest >> testSimpleSystem2 [
]
{ #category : #'tests-stepping' }
-RungeKuttaStepperTest >> testVectorSystem [
+PMRungeKuttaStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ExplicitSystem
+ system := PMExplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := RungeKuttaStepper onSystem: system.
- solver := ExplicitSolver new
+ stepper := PMRungeKuttaStepper onSystem: system.
+ solver := PMExplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/PMStepperTest.class.st b/src/Math-Tests-ODE/PMStepperTest.class.st
new file mode 100644
index 000000000..7d494ca31
--- /dev/null
+++ b/src/Math-Tests-ODE/PMStepperTest.class.st
@@ -0,0 +1,29 @@
+"
+A StepperTest is a test class for testing the behavior of Stepper
+"
+Class {
+ #name : #PMStepperTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-ODE'
+}
+
+{ #category : #tests }
+PMStepperTest >> testOrderIsNilForBaseClass [
+ self assert: PMStepper order isNil
+]
+
+{ #category : #tests }
+PMStepperTest >> testOrderIsNilForInstanceOfBaseClass [
+ self assert: PMStepper new order isNil
+]
+
+{ #category : #tests }
+PMStepperTest >> testSystem [
+ | stepper sys |
+ sys := PMExplicitSystem new.
+ sys block: [ :x :t | t ].
+ stepper := PMStepper onSystem: sys.
+ self assert: stepper system equals: sys.
+ sys := PMExplicitSystem new.
+ self shouldnt: [ stepper system = sys ]
+]
diff --git a/src/Math-Tests-ODE/TrapezoidSolverTest.class.st b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st
similarity index 68%
rename from src/Math-Tests-ODE/TrapezoidSolverTest.class.st
rename to src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st
index c4ecc7b88..de9e1ed56 100644
--- a/src/Math-Tests-ODE/TrapezoidSolverTest.class.st
+++ b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st
@@ -1,28 +1,28 @@
Class {
- #name : #TrapezoidSolverTest,
+ #name : #PMTrapezoidSolverTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-solving' }
-TrapezoidSolverTest >> testSimpleSystem2 [
+PMTrapezoidSolverTest >> testSimpleSystem2 [
| solver stepper system dt |
dt := 1.5.
- system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
- stepper := TrapezoidStepper onSystem: system.
- solver := (ImplicitSolver new) stepper: stepper; system: system; dt: dt.
+ system := PMImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)].
+ stepper := PMTrapezoidStepper onSystem: system.
+ solver := (PMImplicitSolver new) stepper: stepper; system: system; dt: dt.
self should: ((solver solve: system startState: 5 startTime: 0 endTime: 3) closeTo: 3.1299).
self should: ((solver solve: system startState: 0.1 startTime: 1 endTime: 2.5) closeTo: 0.9103)
]
{ #category : #'tests-solving' }
-TrapezoidSolverTest >> testSimpleSystem3 [
+PMTrapezoidSolverTest >> testSimpleSystem3 [
| solver stepper system dt |
dt := 0.5.
- system := ImplicitSystem block: [ :x :t | 2 * t * x ].
- stepper := TrapezoidStepper onSystem: system.
- solver := ImplicitSolver new
+ system := PMImplicitSystem block: [ :x :t | 2 * t * x ].
+ stepper := PMTrapezoidStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
@@ -57,18 +57,18 @@ TrapezoidSolverTest >> testSimpleSystem3 [
]
{ #category : #'tests-solving' }
-TrapezoidSolverTest >> testVectorSystem [
+PMTrapezoidSolverTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := TrapezoidStepper onSystem: system.
- solver := ImplicitSolver new
+ stepper := PMTrapezoidStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/TrapezoidStepperTest.class.st b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st
similarity index 71%
rename from src/Math-Tests-ODE/TrapezoidStepperTest.class.st
rename to src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st
index 80e703266..0c78ebd33 100644
--- a/src/Math-Tests-ODE/TrapezoidStepperTest.class.st
+++ b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st
@@ -1,16 +1,16 @@
Class {
- #name : #TrapezoidStepperTest,
+ #name : #PMTrapezoidStepperTest,
#superclass : #TestCase,
- #category : 'Math-Tests-ODE'
+ #category : #'Math-Tests-ODE'
}
{ #category : #'tests-stepping' }
-TrapezoidStepperTest >> testDoStepTime [
+PMTrapezoidStepperTest >> testDoStepTime [
"this is identical to testDoStepTimeStepSize except dt is stored."
| stepper sys dt |
- sys := ImplicitSystem block: [ :x :t | x * t ].
- stepper := TrapezoidStepper onSystem: sys.
+ sys := PMImplicitSystem block: [ :x :t | x * t ].
+ stepper := PMTrapezoidStepper onSystem: sys.
dt := 0.1.
stepper stepSize: dt.
self assert: stepper stepSize equals: dt.
@@ -25,10 +25,10 @@ TrapezoidStepperTest >> testDoStepTime [
]
{ #category : #'tests-stepping' }
-TrapezoidStepperTest >> testDoStepTimeStepSize1 [
+PMTrapezoidStepperTest >> testDoStepTimeStepSize1 [
| stepper sys dt |
- sys := ImplicitSystem block: [ :x :t | x * t ].
- stepper := TrapezoidStepper onSystem: sys.
+ sys := PMImplicitSystem block: [ :x :t | x * t ].
+ stepper := PMTrapezoidStepper onSystem: sys.
dt := 0.1.
self assert: ((stepper doStep: 0 time: 10 stepSize: dt) closeTo: 0.0).
self
@@ -40,11 +40,11 @@ TrapezoidStepperTest >> testDoStepTimeStepSize1 [
]
{ #category : #'tests-stepping' }
-TrapezoidStepperTest >> testDoStepTimeStepSize2 [
+PMTrapezoidStepperTest >> testDoStepTimeStepSize2 [
| stepper sys dt |
- sys := ImplicitSystem
+ sys := PMImplicitSystem
block: [ :x :t | 3 * t negated exp - (0.4 * x) ].
- stepper := TrapezoidStepper onSystem: sys.
+ stepper := PMTrapezoidStepper onSystem: sys.
dt := 0.1.
self
assert: ((stepper doStep: 1 time: 1 stepSize: dt) closeTo: 1.0638).
@@ -53,23 +53,23 @@ TrapezoidStepperTest >> testDoStepTimeStepSize2 [
]
{ #category : #'tests-stepping' }
-TrapezoidStepperTest >> testOrderIsTwo [
- self assert: TrapezoidStepper order equals: 2
+PMTrapezoidStepperTest >> testOrderIsTwo [
+ self assert: PMTrapezoidStepper order equals: 2
]
{ #category : #'tests-stepping' }
-TrapezoidStepperTest >> testVectorSystem [
+PMTrapezoidStepperTest >> testVectorSystem [
| solver stepper system dt |
dt := 0.01.
- system := ImplicitSystem
+ system := PMImplicitSystem
block: [ :x :t |
| c |
c := PMVector new: 2.
c at: 1 put: t sin.
c at: 2 put: t cos.
c ].
- stepper := TrapezoidStepper onSystem: system.
- solver := ImplicitSolver new
+ stepper := PMTrapezoidStepper onSystem: system.
+ solver := PMImplicitSolver new
stepper: stepper;
system: system;
dt: dt.
diff --git a/src/Math-Tests-ODE/StepperTest.class.st b/src/Math-Tests-ODE/StepperTest.class.st
deleted file mode 100644
index fd26770e6..000000000
--- a/src/Math-Tests-ODE/StepperTest.class.st
+++ /dev/null
@@ -1,29 +0,0 @@
-"
-A StepperTest is a test class for testing the behavior of Stepper
-"
-Class {
- #name : #StepperTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-ODE'
-}
-
-{ #category : #tests }
-StepperTest >> testOrderIsNilForBaseClass [
- self assert: Stepper order isNil
-]
-
-{ #category : #tests }
-StepperTest >> testOrderIsNilForInstanceOfBaseClass [
- self assert: Stepper new order isNil
-]
-
-{ #category : #tests }
-StepperTest >> testSystem [
- | stepper sys |
- sys := ExplicitSystem new.
- sys block: [ :x :t | t ].
- stepper := Stepper onSystem: sys.
- self assert: stepper system equals: sys.
- sys := ExplicitSystem new.
- self shouldnt: [ stepper system = sys ]
-]
diff --git a/src/Math-Permutation/PMPermutationTest.class.st b/src/Math-Tests-Permutation/PMPermutationTest.class.st
similarity index 99%
rename from src/Math-Permutation/PMPermutationTest.class.st
rename to src/Math-Tests-Permutation/PMPermutationTest.class.st
index 95b42f8c9..8cc584cc0 100644
--- a/src/Math-Permutation/PMPermutationTest.class.st
+++ b/src/Math-Tests-Permutation/PMPermutationTest.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMPermutationTest,
#superclass : #TestCase,
- #category : #'Math-Permutation'
+ #category : #'Math-Tests-Permutation'
}
{ #category : #'class tests' }
diff --git a/src/Math-Tests-Permutation/package.st b/src/Math-Tests-Permutation/package.st
new file mode 100644
index 000000000..32ef2d0b6
--- /dev/null
+++ b/src/Math-Tests-Permutation/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-Permutation' }
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st
new file mode 100644
index 000000000..33ed4e4df
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st
@@ -0,0 +1,14 @@
+"
+This test checks that the Jacobi transform based PCA meets the acceptance requirements defined in PMPrincipalComponentAnalysisTest
+"
+Class {
+ #name : #PMPCAJacobiTransformationTest,
+ #superclass : #PMPrincipalComponentAnalyserTest,
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #running }
+PMPCAJacobiTransformationTest >> setUp [
+ pca := PMPrincipalComponentAnalyserJacobiTransformation new
+ componentsNumber: 2
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st
new file mode 100644
index 000000000..23ae687eb
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st
@@ -0,0 +1,25 @@
+"
+This test checks that the SVD transform based PCA meets the acceptance requirements defined in PMPrincipalComponentAnalysisTest
+"
+Class {
+ #name : #PMPCASingularValueDecompositionTest,
+ #superclass : #PMPrincipalComponentAnalyserTest,
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #running }
+PMPCASingularValueDecompositionTest >> setUp [
+ pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2
+]
+
+{ #category : #'scikit-learn-example' }
+PMPCASingularValueDecompositionTest >> testPCAwithPCAandJacobiTransformationReturnSame [
+ | m pca1 pca2 |
+ m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)).
+ pca1 := PMPrincipalComponentAnalyserSVD new componentsNumber: 2.
+ pca1 fit: m.
+ pca2 := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2.
+ pca2 fit: m.
+
+ self assert: pca1 transformMatrix abs closeTo: pca2 transformMatrix abs
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st
new file mode 100644
index 000000000..48cea390c
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st
@@ -0,0 +1,64 @@
+"
+The tests in this class compare the output from PolyMath with:
+1) an example from Scikit-Learn's documentation; and
+2) the PCA Tutorial by Lindsay Smith (see http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf). The input data used
+are the mean-centred data in section 3.1, step 2.
+"
+Class {
+ #name : #PMPrincipalComponentAnalyserTest,
+ #superclass : #TestCase,
+ #instVars : [
+ 'pca'
+ ],
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #testing }
+PMPrincipalComponentAnalyserTest class >> isAbstract [
+ ^ self name = #PMPrincipalComponentAnalyserTest
+]
+
+{ #category : #'scikit-learn-example' }
+PMPrincipalComponentAnalyserTest >> testTransformMatrix [
+ | m expected |
+ m := PMMatrix
+ rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)).
+
+ pca fit: m.
+
+ expected := (PMMatrix
+ rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs.
+ self assert: pca transformMatrix abs closeTo: expected
+]
+
+{ #category : #'lindsay-smith-pca-tutorial' }
+PMPrincipalComponentAnalyserTest >> testTransformWithMeanCentredMeasurements [
+ | meanCentredData transformedData expected |
+ meanCentredData := PMMatrix rows: #(
+ #(0.69 0.49)
+ #(-1.31 -1.21)
+ #(0.39 0.99)
+ #(0.09 0.29)
+ #(1.29 1.09)
+ #(0.49 0.79)
+ #(0.19 -0.31)
+ #(-0.81 -0.81)
+ #(-0.31 -0.31)
+ #(-0.71 -1.01)
+ ).
+
+ transformedData := pca fitAndTransform: meanCentredData.
+
+ expected := PMMatrix rows: #(
+ #(-0.827970186 -0.175115307)
+ #(1.77758033 0.142857227)
+ #(-0.992197494 0.384374989)
+ #(-0.274210416 0.130417207)
+ #(-1.67580142 -0.209498461)
+ #(-0.912949103 0.175282444)
+ #(0.0991094375 -0.349824698)
+ #(1.14457216 0.0464172582)
+ #(0.438046137 0.0177646297)
+ #(1.22382056 -0.162675287)).
+ self assert: (transformedData abs) closeTo: expected abs.
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st
new file mode 100644
index 000000000..270a42603
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st
@@ -0,0 +1,103 @@
+"
+This is the test class that exercises scikit-learn Eigenvector Flip Algorithm
+
+"
+Class {
+ #name : #PMSciKitLearnSVDFlipAlgorithmTest,
+ #superclass : #TestCase,
+ #instVars : [
+ 'u',
+ 'v',
+ 'flipAlgorithm'
+ ],
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #initialization }
+PMSciKitLearnSVDFlipAlgorithmTest >> setUp [
+" We compute a matrix of signs for U with which
+ we perform a 'dot product' with the original
+ matrix V
+ (by 'dot product' we mean send the dot: message)
+ Example here is taken from Scikit Learn
+
+ U = [[-0.21956688 0.53396977]
+ [-0.35264795 -0.45713538]
+ [-0.57221483 0.07683439]
+ [ 0.21956688 -0.53396977]
+ [ 0.35264795 0.45713538]
+ [ 0.57221483 -0.07683439]]
+
+ V = [[ 0.83849224 0.54491354]
+ [ 0.54491354 -0.83849224]]
+ "
+
+
+ u := PMMatrix rows: #(
+ #(-0.21956688 0.53396977)
+ #(-0.35264795 -0.45713538)
+ #(-0.57221483 0.07683439)
+ #( 0.21956688 -0.53396977)
+ #( 0.35264795 0.45713538)
+ #( 0.57221483 -0.07683439)).
+ v := PMMatrix rows: #(
+ #(0.83849224 0.54491354)
+ #(0.54491354 -0.83849224)).
+
+ flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v.
+]
+
+{ #category : #'scikit-learn-example' }
+PMSciKitLearnSVDFlipAlgorithmTest >> testComputeSignsFromU [
+ "The purpose is to compare the output from fligEigenVectorsSign in
+ PolyMath with scikit-learn
+ "
+
+ | expected signs |
+
+ signs := flipAlgorithm computeSignsFromU.
+
+ expected := #(-1 1) asPMVector.
+ self assert: signs equals: expected
+]
+
+{ #category : #'scikit-learn-example' }
+PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForU [
+ | expected |
+ expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)).
+
+ self assert: (flipAlgorithm signMatrixForU) equals: expected
+
+]
+
+{ #category : #'scikit-learn-example' }
+PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForV [
+ | expected |
+ expected := PMMatrix rows: #(#(-1 -1) #(1 1)).
+
+ self assert: (flipAlgorithm signMatrixForV) equals: expected
+]
+
+{ #category : #'scikit-learn-example' }
+PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [
+ | expected |
+ expected := PMMatrix rows: #(
+ #(0.21956688 0.53396977)
+ #(0.35264795 -0.45713538)
+ #(0.57221483 0.07683439)
+ #(-0.21956688 -0.53396977)
+ #(-0.35264795 0.45713538)
+ #(-0.57221483 -0.07683439)).
+
+ self assert: (flipAlgorithm uFlipped) equals: expected
+
+
+]
+
+{ #category : #'scikit-learn-example' }
+PMSciKitLearnSVDFlipAlgorithmTest >> testVFlipped [
+ | expected |
+ expected := PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224)).
+
+ self assert: flipAlgorithm vFlipped equals: expected
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st
new file mode 100644
index 000000000..4baa8ec90
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st
@@ -0,0 +1,85 @@
+"
+These tests use the example from:
+https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2007/076422.pdf
+
+X = [ 4 22 3 5]
+ [ 1 5 1 1]
+ [11 69 10 14]
+ [11 69 10 14]
+
+The expected output is the computation carried out by Scikit-Learn's SVD flip algorithm.
+"
+Class {
+ #name : #PMScikitLearnSVDFlipAlgorithmSandiaTest,
+ #superclass : #TestCase,
+ #instVars : [
+ 'u',
+ 'v',
+ 'flipAlgorithm'
+ ],
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #initialization }
+PMScikitLearnSVDFlipAlgorithmSandiaTest >> setUp [
+ u:= PMMatrix rows: #(
+ #(-3.37888092e-01 7.97390517e-01 -5.00000000e-01 -7.29361893e-17)
+ #(-6.39157626e-01 -5.84360787e-01 -5.00000000e-01 -6.37482349e-17)
+ #(4.88522859e-01 -1.06514865e-01 -5.00000000e-01 -7.07106781e-01)
+ #(4.88522859e-01 -1.06514865e-01 -5.00000000e-01 7.07106781e-01)
+ ).
+
+ v := PMMatrix rows: #(
+ #(0.1480984 0.96040168 0.13728871 0.19195647)
+ #(0.43936626 -0.13130934 -0.54106008 0.70496038)
+ #(-0.42589859 0.24444267 -0.8129595 -0.31297767)
+ #(-0.77693921 -0.02518437 0.16583923 0.60681839)
+ ).
+
+ flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v.
+]
+
+{ #category : #'sandia-example' }
+PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForU [
+ | expected |
+
+ expected := PMMatrix
+ rows:
+ #(#(-1 1 -1 -1) #(-1 1 -1 -1) #(-1 1 -1 -1) #(-1 1 -1 -1)).
+
+ self assert: flipAlgorithm signMatrixForU equals: expected
+]
+
+{ #category : #'sandia-example' }
+PMScikitLearnSVDFlipAlgorithmSandiaTest >> testSignMatrixForV [
+ | expected |
+ expected := PMMatrix
+ rows:
+ #(#(-1 -1 -1 -1) #(1 1 1 1) #(-1 -1 -1 -1) #(-1 -1 -1 -1)).
+
+ self assert: flipAlgorithm signMatrixForV equals: expected
+]
+
+{ #category : #'sandia-example' }
+PMScikitLearnSVDFlipAlgorithmSandiaTest >> testUFlipped [
+ | expected |
+ expected := PMMatrix rows: #(
+ #(3.37888092e-01 7.97390517e-01 5.00000000e-01 7.29361893e-17)
+ #(6.39157626e-01 -5.84360787e-01 5.00000000e-01 6.37482349e-17)
+ #(-4.88522859e-01 -1.06514865e-01 5.00000000e-01 7.07106781e-01)
+ #(-4.88522859e-01 -1.06514865e-01 5.00000000e-01 -7.07106781e-01)).
+
+ self assert: flipAlgorithm uFlipped equals: expected
+]
+
+{ #category : #'sandia-example' }
+PMScikitLearnSVDFlipAlgorithmSandiaTest >> testVFlipped [
+ | expected |
+ expected := PMMatrix rows: #(
+ #(-0.1480984 -0.96040168 -0.13728871 -0.19195647)
+ #(0.43936626 -0.13130934 -0.54106008 0.70496038)
+ #(0.42589859 -0.24444267 0.8129595 0.31297767)
+ #(0.77693921 0.02518437 -0.16583923 -0.60681839)).
+
+ self assert: flipAlgorithm vFlipped equals: expected
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st
new file mode 100644
index 000000000..03c4a34fa
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st
@@ -0,0 +1,70 @@
+Class {
+ #name : #PMStandardizationScalerTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-PrincipalComponentAnalysis'
+}
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testMean [
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)).
+ t := PMStandardizationScaler new.
+ t fit: aMatrix.
+ self assert: t mean asArray closeTo: #(0.5 0.5)
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testScale [
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)).
+ t := PMStandardizationScaler new.
+ t fit: aMatrix.
+ self assert: t scale asArray closeTo: #(0.5 0.5)
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testTransform [
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #(#(0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)).
+ t := PMStandardizationScaler new.
+ self assert: (t fitAndTransform: aMatrix) equals: (PMMatrix rows: #(#(-1.0 -1.0) #(-1.0 -1.0) #(1.0 1.0) #(1.0 1.0)))
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testTransformAnotherMatrix [
+ | aMatrix t anotherMatrix |
+ aMatrix := PMMatrix rows: #(#(0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)).
+ anotherMatrix := PMMatrix rows: #(#(2 2)).
+ t := PMStandardizationScaler new.
+ t fit: aMatrix.
+ self assert: (t transform: anotherMatrix) equals: (PMMatrix rows: #(#(3 3)))
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testTransformConstantFeature [
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #(#(8.0 0.0) #(8.0 0.0) #(8.0 1.0) #(8.0 1.0)).
+ t := PMStandardizationScaler new.
+ self assert: (t fitAndTransform: aMatrix) equals: (PMMatrix rows: #(#(0.0 -1.0) #(0.0 -1.0) #(0.0 1.0) #(0.0 1.0)))
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testVariance [
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)).
+ t := PMStandardizationScaler new.
+ t fit: aMatrix.
+ self assert: t variance asArray closeTo: #(0.25 0.25)
+]
+
+{ #category : #tests }
+PMStandardizationScalerTest >> testZeroScale [
+ "Tests if PMStandardizationScaler handles case when scale is 0, by changing it to 1.
+ Happens when one feature is constant eg: 8.0 in this test."
+
+ | aMatrix t |
+ aMatrix := PMMatrix rows: #((8.0 0.0) #(8.0 0.0) #(8.0 1.0) #(8.0 1.0)).
+ t := PMStandardizationScaler new.
+ t fit: aMatrix.
+ self assert: t scale asArray closeTo: #(1.0 0.5)
+]
diff --git a/src/Math-Tests-PrincipalComponentAnalysis/package.st b/src/Math-Tests-PrincipalComponentAnalysis/package.st
new file mode 100644
index 000000000..134e310a1
--- /dev/null
+++ b/src/Math-Tests-PrincipalComponentAnalysis/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-PrincipalComponentAnalysis' }
diff --git a/src/Math-Tests-Quantile/QuantileTest.class.st b/src/Math-Tests-Quantile/PMQuantileTest.class.st
similarity index 92%
rename from src/Math-Tests-Quantile/QuantileTest.class.st
rename to src/Math-Tests-Quantile/PMQuantileTest.class.st
index ffd061dc5..5f396e795 100644
--- a/src/Math-Tests-Quantile/QuantileTest.class.st
+++ b/src/Math-Tests-Quantile/PMQuantileTest.class.st
@@ -2,7 +2,7 @@
QuantileTest tests mainly '#quantile: method:' by calculating quartiles with every method on SortedCollections of size 4, 5, 6 and 11.
"
Class {
- #name : #QuantileTest,
+ #name : #PMQuantileTest,
#superclass : #TestCase,
#instVars : [
'a',
@@ -11,21 +11,21 @@ Class {
'c',
'd'
],
- #category : 'Math-Tests-Quantile'
+ #category : #'Math-Tests-Quantile'
}
{ #category : #running }
-QuantileTest >> resultCollect: aSortedColl method: aMethod [
+PMQuantileTest >> resultCollect: aSortedColl method: aMethod [
^ q collect: [ :x | aSortedColl quantile: x method: aMethod ]
]
{ #category : #running }
-QuantileTest >> resultCollect: aSortedColl withProbs: aMethod [
+PMQuantileTest >> resultCollect: aSortedColl withProbs: aMethod [
^ q collect: [ :x | aSortedColl quantile: x withProbs: aMethod ]
]
{ #category : #running }
-QuantileTest >> setUp [
+PMQuantileTest >> setUp [
a := #(1 3 2 4) asSortedCollection.
c := #(1 3 2 4 5) asSortedCollection.
d := #(1 3 2 4 5 6) asSortedCollection.
@@ -38,7 +38,7 @@ QuantileTest >> setUp [
]
{ #category : #tests }
-QuantileTest >> testError [
+PMQuantileTest >> testError [
self
should: [ a quantile: 0.5 withProbs: #(1 -1 0) ]
raise: Error
@@ -48,7 +48,7 @@ QuantileTest >> testError [
]
{ #category : #tests }
-QuantileTest >> testExtremeCase [
+PMQuantileTest >> testExtremeCase [
self assert: #(2) asSortedCollection interQuartileRange equals: 0.
self assert: #(2 2) asSortedCollection interQuartileRange equals: 0.
self
@@ -67,7 +67,7 @@ QuantileTest >> testExtremeCase [
]
{ #category : #tests }
-QuantileTest >> testQuantileA [
+PMQuantileTest >> testQuantileA [
self
assert: (self resultCollect: a method: #modeBased)
equals:
@@ -122,7 +122,7 @@ QuantileTest >> testQuantileA [
]
{ #category : #tests }
-QuantileTest >> testQuantileB [
+PMQuantileTest >> testQuantileB [
"tests #(2 4 5 7 8 9 10 12 15 16 18)"
self
@@ -179,7 +179,7 @@ QuantileTest >> testQuantileB [
]
{ #category : #tests }
-QuantileTest >> testQuantileC [
+PMQuantileTest >> testQuantileC [
"tests #(1 3 2 4 5)"
| r |
@@ -246,7 +246,7 @@ QuantileTest >> testQuantileC [
]
{ #category : #tests }
-QuantileTest >> testQuantileD [
+PMQuantileTest >> testQuantileD [
"tests #(1 3 2 4 5 6)"
self
diff --git a/src/Math-Tests-Quaternion/QuaternionTest.class.st b/src/Math-Tests-Quaternion/PMQuaternionTest.class.st
similarity index 84%
rename from src/Math-Tests-Quaternion/QuaternionTest.class.st
rename to src/Math-Tests-Quaternion/PMQuaternionTest.class.st
index 56bff2304..63aa99551 100644
--- a/src/Math-Tests-Quaternion/QuaternionTest.class.st
+++ b/src/Math-Tests-Quaternion/PMQuaternionTest.class.st
@@ -2,7 +2,7 @@
This class is for unit testing the Quaternion.
"
Class {
- #name : #QuaternionTest,
+ #name : #PMQuaternionTest,
#superclass : #TestCase,
#instVars : [
'q1234',
@@ -10,11 +10,11 @@ Class {
'q12',
'q123'
],
- #category : 'Math-Tests-Quaternion'
+ #category : #'Math-Tests-Quaternion'
}
{ #category : #running }
-QuaternionTest >> setUp [
+PMQuaternionTest >> setUp [
q1234 := 1 i: 2 j: 3 k: 4.
q1 := 1 asQuaternion.
q12 := (1 + 2 i) asQuaternion .
@@ -22,7 +22,7 @@ QuaternionTest >> setUp [
]
{ #category : #running }
-QuaternionTest >> testAbs [
+PMQuaternionTest >> testAbs [
self assert: (1 i: 1 j: 1 k: 1) abs equals: 2.
self
should: [ (1.0e200 i: 1.0e200 j: 1.0e200 k: 1.0e200) abs = 2.0e200 ]
@@ -38,7 +38,7 @@ QuaternionTest >> testAbs [
]
{ #category : #running }
-QuaternionTest >> testAddPolynomial [
+PMQuaternionTest >> testAddPolynomial [
| poly |
poly := PMPolynomial coefficients: #(1 1 1).
self assert: (poly + q12 at: 0) equals: (2 + 2 i) asQuaternion.
@@ -46,7 +46,7 @@ QuaternionTest >> testAddPolynomial [
]
{ #category : #running }
-QuaternionTest >> testAngle [
+PMQuaternionTest >> testAngle [
self assert: q1 angle equals: 0.
self assert: (q12 - q1) angle equals: Float pi.
self assert: (q123 - q12) angle equals: Float pi.
@@ -54,13 +54,13 @@ QuaternionTest >> testAngle [
]
{ #category : #running }
-QuaternionTest >> testAsQuaternion [
+PMQuaternionTest >> testAsQuaternion [
self assert: 1 asQuaternion equals: q1 asQuaternion.
self assert: q1234 asQuaternion equals: q1234
]
{ #category : #running }
-QuaternionTest >> testCos [
+PMQuaternionTest >> testCos [
| eps |
eps := 1.0e-6.
self assert: (q1234 cos - ((q1234 real cos * q1234 unreal cos) - (q1234 real sin * q1234 unreal sin))) abs < eps.
@@ -68,14 +68,14 @@ QuaternionTest >> testCos [
]
{ #category : #running }
-QuaternionTest >> testCosh [
+PMQuaternionTest >> testCosh [
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) cosh - (1 + 2 j k) cosh) abs < eps
]
{ #category : #running }
-QuaternionTest >> testDividePolynomial [
+PMQuaternionTest >> testDividePolynomial [
| poly |
poly := PMPolynomial coefficients: #(1 1 1).
self assert: (poly / q12 at: 0) equals: q12 reciprocal.
@@ -85,7 +85,7 @@ QuaternionTest >> testDividePolynomial [
]
{ #category : #running }
-QuaternionTest >> testEquality [
+PMQuaternionTest >> testEquality [
self assert: q1234 equals: q1234 copy.
self assert: 1 + 2 i equals: 1 + 2 j k.
self assert: 1 + 2 j k equals: 1 + 2 i.
@@ -97,7 +97,7 @@ QuaternionTest >> testEquality [
]
{ #category : #running }
-QuaternionTest >> testExp [
+PMQuaternionTest >> testExp [
| eps |
eps := 1.0e-6.
self assert: (q1234 exp - (q1234 real exp * q1234 unreal exp)) abs < eps.
@@ -105,7 +105,7 @@ QuaternionTest >> testExp [
]
{ #category : #running }
-QuaternionTest >> testFloatClass [
+PMQuaternionTest >> testFloatClass [
"not much to do here?"
self assert: (1.5 isKindOf: (1.5 * q1234) floatClass).
@@ -113,7 +113,7 @@ QuaternionTest >> testFloatClass [
]
{ #category : #running }
-QuaternionTest >> testFractionDoubleDispatch [
+PMQuaternionTest >> testFractionDoubleDispatch [
"needed for coverage of adaptToFraction:andSend:"
| frac |
@@ -124,28 +124,28 @@ QuaternionTest >> testFractionDoubleDispatch [
]
{ #category : #running }
-QuaternionTest >> testFunctions [
+PMQuaternionTest >> testFunctions [
| eps |
eps := 1.0e-6.
self assert: (q1234 ln exp - q1234) abs < eps
]
{ #category : #running }
-QuaternionTest >> testHash [
+PMQuaternionTest >> testHash [
self assert: q1234 hash equals: q1234 copy hash.
self assert: (1 + 2 i) hash equals: (1 + 2 j k) hash.
self assert: 1 k k hash equals: -1 hash
]
{ #category : #running }
-QuaternionTest >> testLn [
+PMQuaternionTest >> testLn [
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) ln - (1 + 2 j k) ln) abs < eps
]
{ #category : #running }
-QuaternionTest >> testLog [
+PMQuaternionTest >> testLog [
"this ensures that log and ln have the expected relationship"
| qln qlg10ln |
@@ -160,20 +160,20 @@ QuaternionTest >> testLog [
]
{ #category : #running }
-QuaternionTest >> testOne [
- self assert: Quaternion one unreal isZero.
- self assert: Quaternion one real equals: 1
+PMQuaternionTest >> testOne [
+ self assert: PMQuaternion one unreal isZero.
+ self assert: PMQuaternion one real equals: 1
]
{ #category : #running }
-QuaternionTest >> testPrintOn [
+PMQuaternionTest >> testPrintOn [
| s |
s := q1234 printString.
self assert: s equals: '(1 i: 2 j: 3 k: 4)'
]
{ #category : #running }
-QuaternionTest >> testProduct [
+PMQuaternionTest >> testProduct [
self assert: q1234 * 5 equals: (5 i: 10 j: 15 k: 20).
self assert: 5 * q1234 equals: (5 i: 10 j: 15 k: 20).
self assert: 1 i * 1 i equals: -1.
@@ -205,7 +205,7 @@ QuaternionTest >> testProduct [
]
{ #category : #running }
-QuaternionTest >> testProductWithVector [
+PMQuaternionTest >> testProductWithVector [
| vec |
vec := PMVector new: 2.
vec at: 1 put: 1.
@@ -218,16 +218,16 @@ QuaternionTest >> testProductWithVector [
]
{ #category : #running }
-QuaternionTest >> testRaisedTo [
+PMQuaternionTest >> testRaisedTo [
| eps |
eps := 1.0e-6.
self assert: ((q1234 raisedTo: 3) - (q1234 ln * 3) exp) abs < eps.
]
{ #category : #running }
-QuaternionTest >> testRandomIsLessThanOne [
+PMQuaternionTest >> testRandomIsLessThanOne [
| r |
- r := Quaternion random.
+ r := PMQuaternion random.
self assert: r abs >= 0.0.
self assert: r abs <= 1.0.
self assert: r isQuaternion.
@@ -239,7 +239,7 @@ QuaternionTest >> testRandomIsLessThanOne [
]
{ #category : #running }
-QuaternionTest >> testReduce [
+PMQuaternionTest >> testReduce [
self assert: q1234 reduce equals: q1234.
self assert: q1 reduce equals: 1.
self assert: q1 reduce isInteger.
@@ -249,7 +249,7 @@ QuaternionTest >> testReduce [
]
{ #category : #running }
-QuaternionTest >> testSin [
+PMQuaternionTest >> testSin [
| eps |
eps := 1.0e-6.
self assert: (q1234 sin - ((q1234 real sin * q1234 unreal cos) + (q1234 real cos * q1234 unreal sin))) abs < eps.
@@ -257,14 +257,14 @@ QuaternionTest >> testSin [
]
{ #category : #running }
-QuaternionTest >> testSinh [
+PMQuaternionTest >> testSinh [
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) sinh - (1 + 2 j k) sinh) abs < eps
]
{ #category : #running }
-QuaternionTest >> testSubtractPolynomial [
+PMQuaternionTest >> testSubtractPolynomial [
| poly |
poly := PMPolynomial coefficients: #(1 1 1).
self assert: (poly - q12 at: 0) equals: (0 - 2 i) asQuaternion.
@@ -272,7 +272,7 @@ QuaternionTest >> testSubtractPolynomial [
]
{ #category : #running }
-QuaternionTest >> testSum [
+PMQuaternionTest >> testSum [
self assert: 1 + 2 i + 3 j + 4 k equals: q1234.
self assert: 1 + 2 i + (3 + 4 i) j equals: q1234.
self assert: q1234 + 5 equals: (6 i: 2 j: 3 k: 4).
@@ -286,21 +286,21 @@ QuaternionTest >> testSum [
]
{ #category : #running }
-QuaternionTest >> testTan [
+PMQuaternionTest >> testTan [
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) tan - (1 + 2 j k) tan) abs < eps
]
{ #category : #running }
-QuaternionTest >> testTanh [
+PMQuaternionTest >> testTanh [
| eps |
eps := 1.0e-6.
self assert: ((1 + 2 i) tanh - (1 + 2 j k) tanh) abs < eps
]
{ #category : #running }
-QuaternionTest >> testTimesPolynomial [
+PMQuaternionTest >> testTimesPolynomial [
| poly |
poly := PMPolynomial coefficients: #(1 1 1).
self assert: (poly * q12 at: 0) equals: q12.
@@ -308,7 +308,7 @@ QuaternionTest >> testTimesPolynomial [
]
{ #category : #running }
-QuaternionTest >> testUnreal [
+PMQuaternionTest >> testUnreal [
self assert: q1234 unreal real equals: 0.
self
assert: q1234 unreal squared
@@ -316,7 +316,7 @@ QuaternionTest >> testUnreal [
]
{ #category : #running }
-QuaternionTest >> testZero [
- self assert: Quaternion zero isZero.
- self assert: Quaternion zero abs isZero.
+PMQuaternionTest >> testZero [
+ self assert: PMQuaternion zero isZero.
+ self assert: PMQuaternion zero abs isZero.
]
diff --git a/src/Math-Tests-Random/BinomialGeneratorTest.class.st b/src/Math-Tests-Random/BinomialGeneratorTest.class.st
deleted file mode 100644
index 102bf5a24..000000000
--- a/src/Math-Tests-Random/BinomialGeneratorTest.class.st
+++ /dev/null
@@ -1,52 +0,0 @@
-Class {
- #name : #BinomialGeneratorTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-Random'
-}
-
-{ #category : #tests }
-BinomialGeneratorTest >> testBinomialGeneratorConvergesToMean [
- "this test may fail one or more assertions, but its purpose is to verify correct convergence of the binomial distribution, should be Normal (np, np(1-p))"
-
- | gen nums mean |
- mean := Random new next sqrt.
- gen := PMBinomialGenerator numberOfTrials: 3000 probabilityOfSuccess: mean.
- mean := mean * 3000.
- nums := OrderedCollection new.
- (1 to: 3000) do: [ :ea | nums add: gen next ].
- self assert: nums min > (mean * 0.8).
- self assert: nums max < (mean * 1.2).
- self assert: (nums average - mean) abs < 5
-]
-
-{ #category : #tests }
-BinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [
- | g numberOfTrials |
- g := PMBinomialGenerator new.
- numberOfTrials := 10.
- g
- numberOfTrials: numberOfTrials;
- probability: 1.0.
- g generator: PMLinearCongruentialRandomGenerator new.
- self assert: g next equals: numberOfTrials.
- g generator: PMLehmerRandomGenerator new.
- self assert: g next equals: numberOfTrials.
- g generator: PMMersenneTwisterRandomGenerator new.
- self assert: g next equals: numberOfTrials
-]
-
-{ #category : #tests }
-BinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwaysReturnZero [
- | g numberOfTrials |
- g := PMBinomialGenerator new.
- numberOfTrials := 10.
- g
- numberOfTrials: numberOfTrials;
- probability: 0.0.
- g generator: PMLinearCongruentialRandomGenerator new.
- self assert: g next equals: 0.
- g generator: PMLehmerRandomGenerator new.
- self assert: g next equals: 0.
- g generator: PMMersenneTwisterRandomGenerator new.
- self assert: g next equals: 0
-]
diff --git a/src/Math-Tests-Random/ExponentialGeneratorTest.class.st b/src/Math-Tests-Random/ExponentialGeneratorTest.class.st
deleted file mode 100644
index df38b5038..000000000
--- a/src/Math-Tests-Random/ExponentialGeneratorTest.class.st
+++ /dev/null
@@ -1,40 +0,0 @@
-"
-An ExponentialGeneratorTest is a test class for testing the behavior of ExponentialGenerator
-"
-Class {
- #name : #ExponentialGeneratorTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-Random'
-}
-
-{ #category : #tests }
-ExponentialGeneratorTest >> testGenerator [
- | eg |
- eg := PMExponentialGenerator new.
- self
- assert: (eg generator isKindOf: PMExponentialGenerator defaultGeneratorClass).
- self assert: (eg generator isKindOf: PMRandomGenerator).
- eg generator: PMMersenneTwisterRandomGenerator new.
- self assert: (eg generator isKindOf: PMMersenneTwisterRandomGenerator).
- self assert: (eg next isKindOf: Number)
-]
-
-{ #category : #tests }
-ExponentialGeneratorTest >> testPeekAlwaysAnswersTheSame [
- | eg |
- eg := PMExponentialGenerator new.
- self assert: eg peek equals: eg peek.
- self assert: eg peek equals: eg next
-]
-
-{ #category : #tests }
-ExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [
- "testing a random sample seems suspect. We use a 5% interval here"
-
- | eg arr |
- eg := PMExponentialGenerator mean: 10.
- arr := Array new: 10000.
- (1 to: 10000) do: [ :index | arr at: index put: eg next ].
- self
- assert: (arr average between: eg mean * 0.95 and: eg mean * 1.05)
-]
diff --git a/src/Math-Tests-Random/GaussianGeneratorTest.class.st b/src/Math-Tests-Random/GaussianGeneratorTest.class.st
deleted file mode 100644
index c77ea98bd..000000000
--- a/src/Math-Tests-Random/GaussianGeneratorTest.class.st
+++ /dev/null
@@ -1,36 +0,0 @@
-Class {
- #name : #GaussianGeneratorTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-Random'
-}
-
-{ #category : #utils }
-GaussianGeneratorTest >> checkDistributionOf: aGenerator withExpectedMeans: e andExpectedStandardDeviation: sd [
- "fixme: this test ignores the standard deviation and occasionally fails"
- | data m |
- data := Set new.
- 10000 timesRepeat: [ data add: aGenerator next ].
- m := data average.
- self assert: (e - m) abs <= 0.2.
- self assert: (data stdev - sd) abs <= 1
-]
-
-{ #category : #tests }
-GaussianGeneratorTest >> testDistribution [
- | mean standardDeviation g |
- mean := 147.
- standardDeviation := 17.
- g := (PMGaussianGenerator new).
- g
- mean: mean;
- standardDeviation: standardDeviation;
- generator: PMLinearCongruentialRandomGenerator new.
- g generator seed: 42.
- self checkDistributionOf: g withExpectedMeans: mean andExpectedStandardDeviation: standardDeviation.
- "Replicated test in a different place"
- mean := 0.
- standardDeviation := 10 .
- g mean: mean;
- standardDeviation: standardDeviation.
- self checkDistributionOf: g withExpectedMeans: mean andExpectedStandardDeviation: standardDeviation.
-]
diff --git a/src/Math-Tests-Random/BernoulliGeneratorTest.class.st b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st
similarity index 53%
rename from src/Math-Tests-Random/BernoulliGeneratorTest.class.st
rename to src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st
index 57e0c9022..ec209a95a 100644
--- a/src/Math-Tests-Random/BernoulliGeneratorTest.class.st
+++ b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st
@@ -2,24 +2,13 @@
A BernoulliGeneratorTest is a test class for testing the behavior of BernoulliGenerator
"
Class {
- #name : #BernoulliGeneratorTest,
+ #name : #PMBernoulliGeneratorTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-BernoulliGeneratorTest >> testGenerator [
- | g bern |
- g := PMLinearCongruentialRandomGenerator new.
- bern := PMBernoulliGenerator new.
- self
- assert: (bern generator isKindOf: PMBernoulliGenerator defaultGeneratorClass).
- bern generator: g.
- self assert: (bern generator isKindOf: PMLinearCongruentialRandomGenerator)
-]
-
-{ #category : #tests }
-BernoulliGeneratorTest >> testNextYieldsOneOrZero [
+PMBernoulliGeneratorTest >> testNextYieldsOneOrZero [
| gen |
gen := PMBernoulliGenerator fair.
self should: [ | x | x := gen next.
@@ -27,14 +16,14 @@ BernoulliGeneratorTest >> testNextYieldsOneOrZero [
]
{ #category : #tests }
-BernoulliGeneratorTest >> testOneProbabilityGivesOneNext [
+PMBernoulliGeneratorTest >> testOneProbabilityGivesOneNext [
| g |
g := PMBernoulliGenerator withProbability: 1.
self assert: g next equals: 1
]
{ #category : #tests }
-BernoulliGeneratorTest >> testProbabilityIsMutable [
+PMBernoulliGeneratorTest >> testProbabilityIsMutable [
| g |
g := PMBernoulliGenerator withProbability: 0.0.
self assert: g next equals: 0.
@@ -45,7 +34,7 @@ BernoulliGeneratorTest >> testProbabilityIsMutable [
]
{ #category : #tests }
-BernoulliGeneratorTest >> testZeroProbabilityGivesZeroNext [
+PMBernoulliGeneratorTest >> testZeroProbabilityGivesZeroNext [
| g |
g := PMBernoulliGenerator withProbability: 0.0.
self assert: g next equals: 0
diff --git a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st
new file mode 100644
index 000000000..07bfb2814
--- /dev/null
+++ b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st
@@ -0,0 +1,57 @@
+Class {
+ #name : #PMBinomialGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #tests }
+PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [
+ | g numberOfTrials |
+ g := PMBinomialGenerator new.
+ numberOfTrials := 10.
+ g
+ numberOfTrials: numberOfTrials;
+ probability: 1.0.
+ g generator: PMLinearCongruentialRandomGenerator new.
+ self assert: g next equals: numberOfTrials.
+ g generator: PMLehmerRandomGenerator new.
+ self assert: g next equals: numberOfTrials.
+ g generator: PMMersenneTwisterRandomGenerator new.
+ self assert: g next equals: numberOfTrials
+]
+
+{ #category : #tests }
+PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwaysReturnZero [
+ | g numberOfTrials |
+ g := PMBinomialGenerator new.
+ numberOfTrials := 10.
+ g
+ numberOfTrials: numberOfTrials;
+ probability: 0.0.
+ g generator: PMLinearCongruentialRandomGenerator new.
+ self assert: g next equals: 0.
+ g generator: PMLehmerRandomGenerator new.
+ self assert: g next equals: 0.
+ g generator: PMMersenneTwisterRandomGenerator new.
+ self assert: g next equals: 0
+]
+
+{ #category : #tests }
+PMBinomialGeneratorTest >> testSampleMeanConvergesToExpectedValue [
+ "Its purpose is to verify correct convergence of the binomial distribution,
+ should be Normal (np, np(1-p))"
+
+ | gen sample probabilityOfSuccess numberOfTrials |
+ probabilityOfSuccess := (Random seed: 0.0) next sqrt.
+ numberOfTrials := 1000.
+ gen := PMBinomialGenerator
+ numberOfTrials: numberOfTrials
+ probabilityOfSuccess: probabilityOfSuccess.
+
+ sample := PMRandomSample
+ ofSize: numberOfTrials
+ usingGenerator: gen.
+ self assert: sample min > (gen expectedValue * (1 - 0.2)).
+ self assert: sample max < (gen expectedValue * (1 + 0.2)).
+ self assert: (sample average - gen expectedValue) abs < 5
+]
diff --git a/src/Math-Tests-Random/ConstantGeneratorTest.class.st b/src/Math-Tests-Random/PMConstantGeneratorTest.class.st
similarity index 70%
rename from src/Math-Tests-Random/ConstantGeneratorTest.class.st
rename to src/Math-Tests-Random/PMConstantGeneratorTest.class.st
index aa9e5f72d..668de05cb 100644
--- a/src/Math-Tests-Random/ConstantGeneratorTest.class.st
+++ b/src/Math-Tests-Random/PMConstantGeneratorTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #ConstantGeneratorTest,
+ #name : #PMConstantGeneratorTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-ConstantGeneratorTest >> testConstantGenerator [
+PMConstantGeneratorTest >> testConstantGenerator [
| g |
g := PMConstantGenerator new.
g constant: 1.
diff --git a/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st
new file mode 100644
index 000000000..855788f63
--- /dev/null
+++ b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st
@@ -0,0 +1,41 @@
+"
+A PMExponentialGeneratorTest is a test class for testing the behavior of PMExponentialGenerator
+"
+Class {
+ #name : #PMExponentialGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #tests }
+PMExponentialGeneratorTest >> testGenerator [
+ | eg |
+ eg := PMExponentialGenerator new.
+ self
+ assert: (eg generator isKindOf: PMExponentialGenerator defaultGeneratorClass).
+ self assert: (eg generator isKindOf: PMPseudoRandomNumberGenerator).
+ eg generator: PMMersenneTwisterRandomGenerator new.
+ self assert: (eg generator isKindOf: PMMersenneTwisterRandomGenerator).
+ self assert: (eg next isKindOf: Number)
+]
+
+{ #category : #tests }
+PMExponentialGeneratorTest >> testPeekIsIdempotent [
+ | eg |
+ eg := PMExponentialGenerator new.
+ self assert: eg peek equals: eg peek.
+ self assert: eg peek equals: eg next
+]
+
+{ #category : #tests }
+PMExponentialGeneratorTest >> testSampleMeanConvergesToExpectedValue [
+ "testing a random sample seems suspect. We use a 5% interval here"
+
+ | gen sample |
+ gen := PMExponentialGenerator mean: 10.
+
+ sample := PMRandomSample ofSize: 10000 usingGenerator: gen.
+
+ self
+ assert: (sample average between: gen expectedValue * 0.95 and: gen expectedValue * 1.05)
+]
diff --git a/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st
new file mode 100644
index 000000000..e919251f9
--- /dev/null
+++ b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st
@@ -0,0 +1,41 @@
+Class {
+ #name : #PMGaussianGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #utilities }
+PMGaussianGeneratorTest >> assertSampleGeneratedBy: aGenerator convergesToExpectedValue: expectedValue andStandardDeviation: stdDeviation [
+ | sample |
+ sample := PMRandomSample ofSize: 10000 usingGenerator: aGenerator.
+ self assert: (expectedValue - sample average) abs <= 0.2.
+ self assert: (sample stdev - stdDeviation) abs <= 1
+]
+
+{ #category : #tests }
+PMGaussianGeneratorTest >> testSampleMeanAndStandardDeviationConvergeToDistributionValues [
+ | mean standardDeviation g |
+ mean := 147.
+ standardDeviation := 17.
+ g := PMGaussianGenerator new.
+ g
+ mean: mean;
+ standardDeviation: standardDeviation;
+ generator: PMLinearCongruentialRandomGenerator new.
+ g generator seed: 42.
+
+ self
+ assertSampleGeneratedBy: g
+ convergesToExpectedValue: mean
+ andStandardDeviation: standardDeviation.
+ "Replicated test in a different place"
+ mean := 0.
+ standardDeviation := 10.
+ g
+ mean: mean;
+ standardDeviation: standardDeviation.
+ self
+ assertSampleGeneratedBy: g
+ convergesToExpectedValue: mean
+ andStandardDeviation: standardDeviation
+]
diff --git a/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st
new file mode 100644
index 000000000..2573b654e
--- /dev/null
+++ b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st
@@ -0,0 +1,12 @@
+Class {
+ #name : #PMLaplaceGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #tests }
+PMLaplaceGeneratorTest >> testPeekIsIdempotent [
+ | g |
+ g := PMLaplaceGenerator shape: 0.5 scale: 0.3.
+ self assert: g peek equals: g peek
+]
diff --git a/src/Math-Tests-Random/LehmerRandomTest.class.st b/src/Math-Tests-Random/PMLehmerRandomTest.class.st
similarity index 64%
rename from src/Math-Tests-Random/LehmerRandomTest.class.st
rename to src/Math-Tests-Random/PMLehmerRandomTest.class.st
index 5c10502b0..55740df49 100644
--- a/src/Math-Tests-Random/LehmerRandomTest.class.st
+++ b/src/Math-Tests-Random/PMLehmerRandomTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #LehmerRandomTest,
+ #name : #PMLehmerRandomTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-LehmerRandomTest >> testNextBetweenZeroAndOne [
+PMLehmerRandomTest >> testNextBetweenZeroAndOne [
| g |
g := PMLehmerRandomGenerator new.
1000
@@ -14,15 +14,15 @@ LehmerRandomTest >> testNextBetweenZeroAndOne [
]
{ #category : #tests }
-LehmerRandomTest >> testPeekAlwaysReplyTheSameValue [
+PMLehmerRandomTest >> testPeekAnswersSameAsNext [
| g |
g := PMLehmerRandomGenerator new.
- self assert: g peek equals: g peek
+ self assert: g peek equals: g next
]
{ #category : #tests }
-LehmerRandomTest >> testPeekAnswersSameAsNext [
+PMLehmerRandomTest >> testPeekIsIdempotent [
| g |
g := PMLehmerRandomGenerator new.
- self assert: g peek equals: g next
+ self assert: g peek equals: g peek
]
diff --git a/src/Math-Tests-Random/LinearCongruentialRandomTest.class.st b/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st
similarity index 62%
rename from src/Math-Tests-Random/LinearCongruentialRandomTest.class.st
rename to src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st
index b7eae90de..08ae003cb 100644
--- a/src/Math-Tests-Random/LinearCongruentialRandomTest.class.st
+++ b/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #LinearCongruentialRandomTest,
+ #name : #PMLinearCongruentialRandomTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-LinearCongruentialRandomTest >> testNextBetweenZeroAndOne [
+PMLinearCongruentialRandomTest >> testNextBetweenZeroAndOne [
| g |
g := PMLinearCongruentialRandomGenerator new.
1000
@@ -14,15 +14,15 @@ LinearCongruentialRandomTest >> testNextBetweenZeroAndOne [
]
{ #category : #tests }
-LinearCongruentialRandomTest >> testPeekAlwaysReplyTheSameValue [
+PMLinearCongruentialRandomTest >> testPeekAnswersSameAsNext [
| g |
g := PMLinearCongruentialRandomGenerator new.
- self assert: g peek equals: g peek
+ self assert: g peek equals: g next
]
{ #category : #tests }
-LinearCongruentialRandomTest >> testPeekAnswersSameAsNext [
+PMLinearCongruentialRandomTest >> testPeekIsIdempotent [
| g |
g := PMLinearCongruentialRandomGenerator new.
- self assert: g peek equals: g next
+ self assert: g peek equals: g peek
]
diff --git a/src/Math-Tests-Random/MersenneTwisterRandomTest.class.st b/src/Math-Tests-Random/PMMersenneTwisterRandomTest.class.st
similarity index 77%
rename from src/Math-Tests-Random/MersenneTwisterRandomTest.class.st
rename to src/Math-Tests-Random/PMMersenneTwisterRandomTest.class.st
index 7cef314c0..8555b7777 100644
--- a/src/Math-Tests-Random/MersenneTwisterRandomTest.class.st
+++ b/src/Math-Tests-Random/PMMersenneTwisterRandomTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #MersenneTwisterRandomTest,
+ #name : #PMMersenneTwisterRandomTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-MersenneTwisterRandomTest >> testNext10BetweenZeroAndTen [
+PMMersenneTwisterRandomTest >> testNext10BetweenZeroAndTen [
| g |
g := PMMersenneTwisterRandomGenerator new.
1000
@@ -16,7 +16,7 @@ MersenneTwisterRandomTest >> testNext10BetweenZeroAndTen [
]
{ #category : #tests }
-MersenneTwisterRandomTest >> testNextBetweenZeroAndOne [
+PMMersenneTwisterRandomTest >> testNextBetweenZeroAndOne [
| g |
g := PMMersenneTwisterRandomGenerator new.
1000
@@ -25,7 +25,7 @@ MersenneTwisterRandomTest >> testNextBetweenZeroAndOne [
]
{ #category : #tests }
-MersenneTwisterRandomTest >> testNextFloatExcludeUpper [
+PMMersenneTwisterRandomTest >> testNextFloatExcludeUpper [
"this revealed a bug in early versions, excludeUpper was producing between 0 and 2"
| g sample1 sample2 |
diff --git a/src/Math-Tests-Random/NumberGeneratorTest.class.st b/src/Math-Tests-Random/PMNumberGeneratorTest.class.st
similarity index 77%
rename from src/Math-Tests-Random/NumberGeneratorTest.class.st
rename to src/Math-Tests-Random/PMNumberGeneratorTest.class.st
index cae28f0f3..82c45070b 100644
--- a/src/Math-Tests-Random/NumberGeneratorTest.class.st
+++ b/src/Math-Tests-Random/PMNumberGeneratorTest.class.st
@@ -1,11 +1,11 @@
Class {
- #name : #NumberGeneratorTest,
+ #name : #PMNumberGeneratorTest,
#superclass : #TestCase,
- #category : 'Math-Tests-Random'
+ #category : #'Math-Tests-Random'
}
{ #category : #tests }
-NumberGeneratorTest >> testPeekAnswersSame [
+PMNumberGeneratorTest >> testPeekIsIdempotent [
"every subclass should implement some basic behavior."
PMNumberGenerator subclasses
diff --git a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st
new file mode 100644
index 000000000..d4d89644b
--- /dev/null
+++ b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st
@@ -0,0 +1,44 @@
+Class {
+ #name : #PMPoissonGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #tests }
+PMPoissonGeneratorTest >> testPeekIsIdempotent [
+ | poisson |
+ poisson := PMPoissonGenerator lambda: 0.1.
+ self assert: poisson peek equals: poisson peek
+]
+
+{ #category : #tests }
+PMPoissonGeneratorTest >> testPeekReturnsSameAsNext [
+ | poisson |
+ poisson := PMPoissonGenerator lambda: 0.1.
+ self assert: poisson peek equals: poisson next
+]
+
+{ #category : #tests }
+PMPoissonGeneratorTest >> testPeekWorksAfterSampling [
+ | poisson random |
+ poisson := PMPoissonGenerator lambda: 0.1.
+ 1 to: 100 do: [ :ea | poisson next ].
+ random := poisson peek.
+ self assert: random equals: poisson peek.
+ self assert: random equals: poisson next
+]
+
+{ #category : #tests }
+PMPoissonGeneratorTest >> testSampleMeanConvergesToExpectedValue [
+ "law of large numbers"
+
+ "made non-random, old random version in comments"
+
+ | gen sample |
+ gen := PMPoissonGenerator lambda: 5.
+ "added for non-randomness"
+ gen generator seed: 42.
+
+ sample := PMRandomSample ofSize: 1000 usingGenerator: gen.
+ self assert: (sample average between: (gen expectedValue * 0.8) and: (gen expectedValue * 1.2))
+]
diff --git a/src/Math-Tests-Random/PMPseudoRandomNumberGeneratorTest.class.st b/src/Math-Tests-Random/PMPseudoRandomNumberGeneratorTest.class.st
new file mode 100644
index 000000000..7145cc0d5
--- /dev/null
+++ b/src/Math-Tests-Random/PMPseudoRandomNumberGeneratorTest.class.st
@@ -0,0 +1,75 @@
+Class {
+ #name : #PMPseudoRandomNumberGeneratorTest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #private }
+PMPseudoRandomNumberGeneratorTest >> pseudoRandomNumberGeneratorsDo: aBlock [
+ "Instanciates a pseudo random number generator
+ to yield to the block"
+
+ PMPseudoRandomNumberGenerator subclasses
+ do: [ :typeOfGenerator |
+ | generator |
+ generator := typeOfGenerator new.
+ aBlock value: generator ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamDoesntRespondToContents [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen | self should: [ gen contents ] raise: Error ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamIsReadOnly [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen |
+ self shouldnt: [ gen isWriteable ].
+ self assert: gen isReadable ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamNeverEnds [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen | self shouldnt: [ gen atEnd ] ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamPeekIsNext [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen |
+ | value |
+ value := gen peek.
+ self assert: gen peek equals: value.
+ self assert: gen next equals: value ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamProducesNumbers [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen |
+ self assert: gen next isNumber.
+ self assert: gen next isFloat ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testGeneratorStreamProducesRandomNumbers [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen |
+ | value |
+ value := gen next.
+ self shouldnt: [ gen next = value ] ]
+]
+
+{ #category : #tests }
+PMPseudoRandomNumberGeneratorTest >> testNextGivesArrayOfNumbers [
+ self
+ pseudoRandomNumberGeneratorsDo: [ :gen |
+ | samples |
+ samples := gen next: 10.
+ self assert: samples size equals: 10.
+ self assert: (samples at: 1) isFloat.
+ self assert: samples asSet size equals: 10 ]
+]
diff --git a/src/Math-Tests-Random/PMRandomSample.class.st b/src/Math-Tests-Random/PMRandomSample.class.st
new file mode 100644
index 000000000..de60a8386
--- /dev/null
+++ b/src/Math-Tests-Random/PMRandomSample.class.st
@@ -0,0 +1,21 @@
+"
+I generate sample numerical data for the convergence tests given a size and distribution/PRNG
+
+messages:
+ - generateASampleOfSize: size usingGenerator:gen
+"
+Class {
+ #name : #PMRandomSample,
+ #superclass : #Object,
+ #category : #'Math-Tests-Random'
+}
+
+{ #category : #tests }
+PMRandomSample class >> ofSize: size usingGenerator: gen [
+ "Generates sample data given a distribution"
+ | sample |
+ sample := OrderedCollection new.
+ size timesRepeat: [ sample add: gen next ].
+ ^ sample
+
+]
diff --git a/src/Math-Tests-Random/PoissonGeneratorTest.class.st b/src/Math-Tests-Random/PoissonGeneratorTest.class.st
deleted file mode 100644
index f3239de18..000000000
--- a/src/Math-Tests-Random/PoissonGeneratorTest.class.st
+++ /dev/null
@@ -1,46 +0,0 @@
-Class {
- #name : #PoissonGeneratorTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-Random'
-}
-
-{ #category : #tests }
-PoissonGeneratorTest >> testPeekReturnsSameAsNext [
- | poisson random |
- poisson := PMPoissonGenerator lambda: 0.1.
- random := poisson peek.
- self assert: random equals: poisson next
-]
-
-{ #category : #tests }
-PoissonGeneratorTest >> testPeekReturnsSameTwice [
- | poisson random |
- poisson := PMPoissonGenerator lambda: 0.1.
- random := poisson peek.
- self assert: random equals: poisson peek
-]
-
-{ #category : #tests }
-PoissonGeneratorTest >> testPeekWorksAfterSampling [
- | poisson random |
- poisson := PMPoissonGenerator lambda: 0.1.
- (1 to: 100) do: [ :ea | poisson next ].
- random := poisson peek.
- self assert: random equals: poisson peek.
- self assert: random equals: poisson next
-]
-
-{ #category : #tests }
-PoissonGeneratorTest >> testSampleAverageConvergesToLambda [
- "law of large numbers"
-
- "made non-random, old random version in comments"
-
- | poisson samples |
- samples := OrderedCollection new.
- poisson := PMPoissonGenerator lambda: 5. "((1000 atRandom: Random new) -1)"
- poisson generator seed: 42. "added for non-randomness"
- 1000 timesRepeat: [ samples add: poisson next ].
- self assert: samples average >= (poisson lambda * 0.8).
- self assert: samples average <= (poisson lambda * 1.2)
-]
diff --git a/src/Math-Tests-Random/RandomGeneratorTest.class.st b/src/Math-Tests-Random/RandomGeneratorTest.class.st
deleted file mode 100644
index e2f45531f..000000000
--- a/src/Math-Tests-Random/RandomGeneratorTest.class.st
+++ /dev/null
@@ -1,73 +0,0 @@
-Class {
- #name : #RandomGeneratorTest,
- #superclass : #TestCase,
- #category : 'Math-Tests-Random'
-}
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [
- PMRandomGenerator subclasses do:
- [:cls | | gen value |
- gen := cls new.
- self should: [gen contents] raise: Error].
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamIsReadOnly [
- PMRandomGenerator subclasses
- do: [ :cls |
- | gen |
- gen := cls new.
- self shouldnt: [ gen isWriteable ].
- self assert: gen isReadable ]
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamNeverEnds [
- PMRandomGenerator subclasses do:
- [:cls | | gen |
- gen := cls new.
- self shouldnt: [gen atEnd]].
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamPeekIsNext [
- PMRandomGenerator subclasses
- do: [ :cls |
- | gen value |
- gen := cls new.
- value := gen peek.
- self assert: gen peek equals: value.
- self assert: gen next equals: value ]
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamProducesNumbers [
- PMRandomGenerator subclasses
- do: [ :cls |
- | gen |
- gen := cls new.
- self assert: gen next isNumber.
- self assert: gen next isFloat ]
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testGeneratorStreamProducesRandomNumbers [
- PMRandomGenerator subclasses do:
- [:cls | | gen value |
- gen := cls new.
- value := gen next.
- self shouldnt: [gen next = value]].
-]
-
-{ #category : #tests }
-RandomGeneratorTest >> testNextGivesArrayOfNumbers [
- PMRandomGenerator subclasses
- do: [ :cls |
- | gen samples |
- gen := cls new.
- samples := gen next: 10.
- self assert: samples size equals: 10.
- self assert: (samples at: 1) isFloat.
- self assert: samples asSet size equals: 10 ]
-]
diff --git a/src/Math-RandomDistributionBased/PMLaplaceGeneratorTest.class.st b/src/Math-Tests-RandomDistributionBased/PMLaplaceGeneratorTest.class.st
similarity index 87%
rename from src/Math-RandomDistributionBased/PMLaplaceGeneratorTest.class.st
rename to src/Math-Tests-RandomDistributionBased/PMLaplaceGeneratorTest.class.st
index 92785818d..af5fec00c 100644
--- a/src/Math-RandomDistributionBased/PMLaplaceGeneratorTest.class.st
+++ b/src/Math-Tests-RandomDistributionBased/PMLaplaceGeneratorTest.class.st
@@ -1,7 +1,7 @@
Class {
#name : #PMLaplaceGeneratorTest,
#superclass : #TestCase,
- #category : 'Math-RandomDistributionBased'
+ #category : #'Math-Tests-RandomDistributionBased'
}
{ #category : #'as yet unclassified' }
diff --git a/src/Math-Tests-RandomDistributionBased/package.st b/src/Math-Tests-RandomDistributionBased/package.st
new file mode 100644
index 000000000..64bc9cfc6
--- /dev/null
+++ b/src/Math-Tests-RandomDistributionBased/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-RandomDistributionBased' }
diff --git a/src/Math-Tests-TSNE/PMTSNETest.class.st b/src/Math-Tests-TSNE/PMTSNETest.class.st
new file mode 100644
index 000000000..322b5cc15
--- /dev/null
+++ b/src/Math-Tests-TSNE/PMTSNETest.class.st
@@ -0,0 +1,83 @@
+"
+I test the method of the class PMTSNE.
+"
+Class {
+ #name : #PMTSNETest,
+ #superclass : #TestCase,
+ #category : #'Math-Tests-TSNE'
+}
+
+{ #category : #tests }
+PMTSNETest >> testComputePValues [
+ | t |
+
+ t := (PMTSNE new)
+ x: (PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)));
+ perplexity: 30.0.
+ self assert: t computePValues closeTo: (PMMatrix rows: {{0. 2/3. 2/3.}. {2/3. 0. 2/3}. {2/3. 2/3. 0.}})
+]
+
+{ #category : #tests }
+PMTSNETest >> testComputePairwiseAffinities [
+ | t correctAffinities |
+
+ t := (PMTSNE new)
+ x: (PMMatrix rows: #(#(0 0) #(2 2) #(2 0)));
+ perplexity: 30.0.
+ correctAffinities := PMMatrix rows: #(
+ #(0 0.5 0.5)
+ #(0.5 0 0.5)
+ #(0.5 0.5 0)
+ ).
+ self assert: t computePairwiseAffinities closeTo: correctAffinities.
+
+ "This test case has large pairwise distances, which makes exp(-D*beta) = 0"
+ t x: (PMMatrix rows: #(#(1 2 3.14) #(0 4 -43) #(-5 -9 -150) #(120 5 1))).
+ correctAffinities := PMMatrix rows: #(
+ #(0 0.333333 0.333333 0.333333)
+ #(0.333333 0 0.333333 0.333333)
+ #(0.333333 0.333333 0 0.333333)
+ #(0.333333 0.333333 0.333333 0)
+ ).
+ self assert: t computePairwiseAffinities closeTo: correctAffinities.
+]
+
+{ #category : #tests }
+PMTSNETest >> testComputePairwiseDistances [
+ | t |
+ t := (PMTSNE
+ new)
+ x: (PMMatrix rows: #(#(1 2) #(3 4))).
+ self assert: t computePairwiseDistances equals: (PMMatrix rows: #(#(0 8) #(8 0)))
+]
+
+{ #category : #tests }
+PMTSNETest >> testEntropyOfAndPRowWithBeta [
+ | distanceVector pVector entropy |
+ "Input points are (0, 0), (2, 2) and (2, 0)"
+ distanceVector := #(0 8 4) asPMVector.
+ pVector := PMVector new: (distanceVector size).
+ entropy := PMTSNE entropyOf: distanceVector andPRow: pVector withBeta: 2.0.
+ self assert: entropy closeTo: 0.003020119571023052.
+ self assert: pVector closeTo: { 0.99966454 . 0.00000011 . 0.00033535 } asPMVector.
+
+]
+
+{ #category : #tests }
+PMTSNETest >> testInitialDimsSetByDefaultWithFifty [
+ | t |
+ t := PMTSNE
+ new
+ x: (PMTSNE gridDataGeneratorOf: 5);
+ start.
+ self assert: t initialDims equals: 50
+]
+
+{ #category : #tests }
+PMTSNETest >> testreduceXToInputDimsUsing [
+ | t |
+ t := (PMTSNE new)
+ x: (PMMatrix rows: #(#(0 0) #(2 2) #(2 0))).
+ t reduceXToInputDimsUsing: PMPrincipalComponentAnalyserJacobiTransformation.
+ self assert: (t x) closeTo: (PMMatrix rows: #(#(-0.5 -1.5) #(-0.5 1.5) #(1 0))).
+]
diff --git a/src/Math-Tests-TSNE/package.st b/src/Math-Tests-TSNE/package.st
new file mode 100644
index 000000000..dcc5e6fce
--- /dev/null
+++ b/src/Math-Tests-TSNE/package.st
@@ -0,0 +1 @@
+Package { #name : #'Math-Tests-TSNE' }