From f20a849ac92729f567851698cdff3b1c664842f6 Mon Sep 17 00:00:00 2001 From: hernanmd Date: Wed, 25 Jul 2018 00:34:41 -0300 Subject: [PATCH 001/161] Added convenience methods with tests #atAllPut: (Matrix instance protocol) #atColumn:put:repeat: #initializeRows:columns: #rows:columns: (Matrix class protocol) #rows:columns:element: (Matrix class protocol) --- src/Math-Matrix/PMMatrix.class.st | 43 ++++++++++++++++++++ src/Math-Tests-Matrix/PMMatrixTest.class.st | 45 +++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 89823ece3..6eb9c81ca 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -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" @@ -231,6 +247,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 +269,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. " @@ -415,6 +451,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." diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 35c864902..4ea448145 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -4,6 +4,32 @@ Class { #category : 'Math-Tests-Matrix' } +{ #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 | @@ -432,6 +458,25 @@ PMMatrixTest >> testPrintOn [ self shouldnt: [m printOn: stream] raise: Error ] +{ #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 } PMMatrixTest >> testSimpleMatrixOperations [ | s m s2 r r2 | From 1d8b36b0037fadb03773fd7a3dd4fdf1af5b4884 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 25 Jul 2018 13:10:08 +0100 Subject: [PATCH 002/161] Clean class PMFloatingPointMachine and sync with the book --- src/Math-Core/PMFloatingPointMachine.class.st | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Math-Core/PMFloatingPointMachine.class.st b/src/Math-Core/PMFloatingPointMachine.class.st index c4b3db4e7..26f7e6bc4 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 } @@ -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 } From 3c64775134209ae60bae065991214ae388dcd7ae Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 25 Jul 2018 13:11:57 +0100 Subject: [PATCH 003/161] Cleaning --- src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st | 7 ++++++- src/Math-DHB-Numerical/PMVectorAccumulator.class.st | 8 ++++++-- src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st | 8 ++++++++ src/Math-Tests-KDTree/KDTreeTest.class.st | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st diff --git a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st b/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st index fc251caf1..9df86ceb7 100644 --- a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st +++ b/src/Math-DHB-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-DHB-Numerical-Math-UtilsAccumulator' } { #category : #transformation } diff --git a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st b/src/Math-DHB-Numerical/PMVectorAccumulator.class.st index a52770d67..967778b52 100644 --- a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st +++ b/src/Math-DHB-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-DHB-Numerical-Math-UtilsAccumulator' } { #category : #'instance creation' } diff --git a/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st b/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st new file mode 100644 index 000000000..cc246926d --- /dev/null +++ b/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st @@ -0,0 +1,8 @@ +" +A PMVectorAccumulatorTest is a test class for testing the behavior of PMVectorAccumulator +" +Class { + #name : #PMVectorAccumulatorTest, + #superclass : #TestCase, + #category : #'Math-DHB-Numerical-Tests' +} diff --git a/src/Math-Tests-KDTree/KDTreeTest.class.st b/src/Math-Tests-KDTree/KDTreeTest.class.st index faad10864..2088e8d8b 100644 --- a/src/Math-Tests-KDTree/KDTreeTest.class.st +++ b/src/Math-Tests-KDTree/KDTreeTest.class.st @@ -27,7 +27,7 @@ tree := simpleTree ifTrue: [ PMKDTree withAll: aCollection ] ifFalse: [PMIndexed { #category : #running } KDTreeTest >> setUp [ -rand :=Random new. + rand := Random new ] { #category : #tests } From 3a995eb28cb0ec16b354dd7941a1f7aa2f31e0fe Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Thu, 26 Jul 2018 13:53:19 +0100 Subject: [PATCH 004/161] Code cleaning during book sync session --- .../PMErfApproximation.class.st | 6 ++--- src/Math-DHB-Numerical/Number.extension.st | 22 +++++++------------ 2 files changed, 10 insertions(+), 18 deletions(-) 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-DHB-Numerical/Number.extension.st b/src/Math-DHB-Numerical/Number.extension.st index af3da97b7..be25d1c91 100644 --- a/src/Math-DHB-Numerical/Number.extension.st +++ b/src/Math-DHB-Numerical/Number.extension.st @@ -9,10 +9,9 @@ Number >> addPolynomial: aPolynomial [ { #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 + "Computes the beta function of the receiver and aNumber" + + ^ (self logBeta: aNumber) exp ] { #category : #'*Math-DHB-Numerical' } @@ -51,17 +50,14 @@ Number >> gamma [ { #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 + "Computes the logarithm of the beta function of the receiver and aNumber" + + ^ 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 " + "Computes the log of the Gamma function (for positive numbers only)" ^self > 1 ifTrue: [ PMLanczosFormula new logGamma: self] ifFalse:[ self > 0 @@ -102,9 +98,7 @@ Number class >> random [ { #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 " + generally called from Number>>equalsTo:" | norm | norm := self abs max: aNumber abs. ^norm <= PMFloatingPointMachine new defaultNumericalPrecision From 92a8c510dbd6816456677fefe7b10c3995c531a0 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Thu, 26 Jul 2018 15:33:58 +0100 Subject: [PATCH 005/161] Typos --- src/Math-Core/PMFloatingPointMachine.class.st | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Math-Core/PMFloatingPointMachine.class.st b/src/Math-Core/PMFloatingPointMachine.class.st index 26f7e6bc4..26b9a0620 100644 --- a/src/Math-Core/PMFloatingPointMachine.class.st +++ b/src/Math-Core/PMFloatingPointMachine.class.st @@ -69,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 } @@ -82,7 +82,7 @@ PMFloatingPointMachine >> computeMachinePrecision [ machinePrecision := one. [ tmp := one + machinePrecision. tmp - one = zero] - whileFalse:[ machinePrecision := machinePrecision * inverseRadix]. + whileFalse:[ machinePrecision := machinePrecision * inverseRadix] ] { #category : #information } @@ -96,7 +96,7 @@ PMFloatingPointMachine >> computeNegativeMachinePrecision [ negativeMachinePrecision := one. [ tmp := one - negativeMachinePrecision. tmp - one = zero] - whileFalse:[ negativeMachinePrecision := negativeMachinePrecision * inverseRadix]. + whileFalse:[ negativeMachinePrecision := negativeMachinePrecision * inverseRadix] ] { #category : #information } @@ -114,7 +114,7 @@ PMFloatingPointMachine >> computeRadix [ [ b := b + b. tmp1 := a + b. radix := ( tmp1 - a) truncated. - radix = 0 ] whileTrue: []. + radix = 0 ] whileTrue: [] ] { #category : #information } From a0ac18ac986fe28fa301970b88067ee2af2c3c69 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 10:35:27 +0100 Subject: [PATCH 006/161] Sync with book chap 6 --- src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st b/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st index a35c1f684..9404a0123 100644 --- a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st +++ b/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st @@ -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" From 9266b790fc866aa16485c913022f8bdaeee54e3b Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 14:56:52 +0100 Subject: [PATCH 007/161] Cleaning code --- src/Math-DHB-Numerical/PMSeriesTermServer.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st b/src/Math-DHB-Numerical/PMSeriesTermServer.class.st index 804f05d7d..992918236 100644 --- a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st +++ b/src/Math-DHB-Numerical/PMSeriesTermServer.class.st @@ -10,5 +10,5 @@ Class { { #category : #initialization } PMSeriesTermServer >> setArgument: aNumber [ - x := aNumber asFloat. + x := aNumber asFloat ] From 9521e2eacb93761a32ba8b070109dc82c3160ff0 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 14:57:05 +0100 Subject: [PATCH 008/161] Clean PCA code --- .../PMPrincipalComponentAnalyserTest.class.st | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 9947132ce..cd00278c4 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -12,6 +12,7 @@ Class { { #category : #initialization } PMPrincipalComponentAnalyserTest >> setUp [ + super setUp. accumulator := PMCovarianceAccumulator new: 5. server := PMPrincipalComponentAnalysisServer new. 100 timesRepeat: [ accumulator accumulate: server next ]. From c06a2332733df5a263250a4049c278781833cb50 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 20:38:23 +0100 Subject: [PATCH 009/161] Cleaning --- .../PMCovarianceAccumulator.class.st | 5 ++- .../PMVectorAccumulator.class.st | 16 +++----- .../PMJacobiTransformation.class.st | 40 +++++-------------- src/Math-Matrix/PMSymmetricMatrix.class.st | 5 ++- 4 files changed, 22 insertions(+), 44 deletions(-) diff --git a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st b/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st index 9df86ceb7..d272fdcea 100644 --- a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st +++ b/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st @@ -45,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/PMVectorAccumulator.class.st b/src/Math-DHB-Numerical/PMVectorAccumulator.class.st index 967778b52..761355d1f 100644 --- a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st +++ b/src/Math-DHB-Numerical/PMVectorAccumulator.class.st @@ -23,7 +23,6 @@ PMVectorAccumulator class >> new: anInteger [ { #category : #transformation } PMVectorAccumulator >> accumulate: aVectorOrArray [ - | delta | count := count + 1. delta := average - aVectorOrArray asPMVector scaleBy: 1 / count. @@ -33,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-Matrix/PMJacobiTransformation.class.st b/src/Math-Matrix/PMJacobiTransformation.class.st index 137489a90..cc3db88a7 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,7 @@ PMJacobiTransformation class >> new [ { #category : #operation } PMJacobiTransformation >> evaluateIteration [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 1/6/99 " + "(c) Copyrights Didier BESSET, 1999, all rights reserved" | indices | indices := self largestOffDiagonalIndices. self transformAt: ( indices at: 1) and: ( indices at: 2). @@ -44,9 +43,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 +60,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 +73,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 +82,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 +109,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 +122,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 +141,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/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 } From 42fe28e4c5923d03b5756a09bcbb50892d4d8e31 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 20:39:29 +0100 Subject: [PATCH 010/161] Add a class similar to StandardScaler in Scikit-learn --- .../PMDataTransformer.class.st | 24 ++++++++++++ .../PMStandardizationScaler.class.st | 37 +++++++++++++++++++ .../PMStandardizationScalerTest.class.st | 23 ++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st create mode 100644 src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st create mode 100644 src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st diff --git a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st new file mode 100644 index 000000000..c9ef5ccf5 --- /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: aCollection [ + ^ self subclassResponsibility +] + +{ #category : #'as yet unclassified' } +PMDataTransformer >> fitAndTransform: aCollection [ + ^ (self fit: aCollection) transform: aCollection +] + +{ #category : #transforming } +PMDataTransformer >> transform: aCollection [ + ^ self subclassResponsibility +] diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st new file mode 100644 index 000000000..c01da6a9e --- /dev/null +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -0,0 +1,37 @@ +Class { + #name : #PMStandardizationScaler, + #superclass : #PMDataTransformer, + #instVars : [ + 'accumulator' + ], + #category : #'Math-PrincipalComponentAnalysis' +} + +{ #category : #'as yet unclassified' } +PMStandardizationScaler >> fit: aCollection [ + "Compute the mean and the scale of a Collection (in order to have a std of 1)" + + accumulator := PMCovarianceAccumulator new: aCollection first size. + aCollection do: [ :each | accumulator accumulate: each ] +] + +{ #category : #accessing } +PMStandardizationScaler >> mean [ + ^ accumulator average +] + +{ #category : #transforming } +PMStandardizationScaler >> transform: aCollection [ + "Perform standardization by centering and scaling" + +] + +{ #category : #'as yet unclassified' } +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-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st new file mode 100644 index 000000000..e808bc4e3 --- /dev/null +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -0,0 +1,23 @@ +Class { + #name : #PMStandardizationScalerTest, + #superclass : #TestCase, + #category : #'Math-PrincipalComponentAnalysis' +} + +{ #category : #tests } +PMStandardizationScalerTest >> testMean [ + | anArray t | + anArray := #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). + t := PMStandardizationScaler new. + t fit: anArray. + self assert: t mean asArray closeTo: #(1.0 0.0 0.333333) +] + +{ #category : #tests } +PMStandardizationScalerTest >> testVariance [ + | anArray t | + anArray := #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + t := PMStandardizationScaler new. + t fit: anArray. + self assert: t variance asArray closeTo: #(0.25 0.25) +] From 4d7bcbacde5079cf6215709041626ba8564ac061 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 21:12:25 +0100 Subject: [PATCH 011/161] Add scale for PMStandardizationScaler --- .../PMStandardizationScaler.class.st | 10 +++++++--- .../PMStandardizationScalerTest.class.st | 11 ++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index c01da6a9e..404b3fc27 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -20,6 +20,11 @@ PMStandardizationScaler >> mean [ ^ accumulator average ] +{ #category : #'as yet unclassified' } +PMStandardizationScaler >> scale [ + ^ self variance sqrt +] + { #category : #transforming } PMStandardizationScaler >> transform: aCollection [ "Perform standardization by centering and scaling" @@ -30,8 +35,7 @@ PMStandardizationScaler >> transform: aCollection [ PMStandardizationScaler >> variance [ "Return the diagonal of the covarianceMatrix" - |c| + | c | c := accumulator covarianceMatrix. - ^(1 to: c numberOfRows ) collect:[:each| c at: each at: each] - + ^ (1 to: c numberOfRows) collect: [ :each | c at: each at: each ] ] diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index e808bc4e3..10efd8ea0 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -10,7 +10,16 @@ PMStandardizationScalerTest >> testMean [ anArray := #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). t := PMStandardizationScaler new. t fit: anArray. - self assert: t mean asArray closeTo: #(1.0 0.0 0.333333) + self assert: t mean asArray closeTo: #(1.0 0.0 0.3333333) +] + +{ #category : #tests } +PMStandardizationScalerTest >> testScale [ + | anArray t | + anArray := #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + t := PMStandardizationScaler new. + t fit: anArray. + self assert: t scale asArray closeTo: #(0.5 0.5) ] { #category : #tests } From 307a0401d6bfc3c5b3618151c4828462e168f46e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 21:27:43 +0100 Subject: [PATCH 012/161] Use PMMatrix for PMDataTransformer classes --- .../PMDataTransformer.class.st | 8 ++++---- .../PMStandardizationScaler.class.st | 12 ++++++------ .../PMStandardizationScalerTest.class.st | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st index c9ef5ccf5..f3e9b4438 100644 --- a/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMDataTransformer.class.st @@ -9,16 +9,16 @@ Class { } { #category : #'as yet unclassified' } -PMDataTransformer >> fit: aCollection [ +PMDataTransformer >> fit: aPMMatrix [ ^ self subclassResponsibility ] { #category : #'as yet unclassified' } -PMDataTransformer >> fitAndTransform: aCollection [ - ^ (self fit: aCollection) transform: aCollection +PMDataTransformer >> fitAndTransform: aPMMatrix [ + ^ (self fit: aPMMatrix) transform: aPMMatrix ] { #category : #transforming } -PMDataTransformer >> transform: aCollection [ +PMDataTransformer >> transform: aPMMatrix [ ^ self subclassResponsibility ] diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index 404b3fc27..45344f0c5 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -8,11 +8,11 @@ Class { } { #category : #'as yet unclassified' } -PMStandardizationScaler >> fit: aCollection [ - "Compute the mean and the scale of a Collection (in order to have a std of 1)" +PMStandardizationScaler >> fit: aPMMatrix [ + "Compute the mean and the scale of a PMMatrix (in order to have a std of 1)" - accumulator := PMCovarianceAccumulator new: aCollection first size. - aCollection do: [ :each | accumulator accumulate: each ] + accumulator := PMCovarianceAccumulator new: aPMMatrix numberOfColumns. + aPMMatrix rowsDo: [ :each | accumulator accumulate: each ] ] { #category : #accessing } @@ -20,7 +20,7 @@ PMStandardizationScaler >> mean [ ^ accumulator average ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PMStandardizationScaler >> scale [ ^ self variance sqrt ] @@ -31,7 +31,7 @@ PMStandardizationScaler >> transform: aCollection [ ] -{ #category : #'as yet unclassified' } +{ #category : #information } PMStandardizationScaler >> variance [ "Return the diagonal of the covarianceMatrix" diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index 10efd8ea0..d9453b28b 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -7,7 +7,7 @@ Class { { #category : #tests } PMStandardizationScalerTest >> testMean [ | anArray t | - anArray := #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). + anArray := PMMatrix rows: #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). t := PMStandardizationScaler new. t fit: anArray. self assert: t mean asArray closeTo: #(1.0 0.0 0.3333333) @@ -16,7 +16,7 @@ PMStandardizationScalerTest >> testMean [ { #category : #tests } PMStandardizationScalerTest >> testScale [ | anArray t | - anArray := #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + anArray := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). t := PMStandardizationScaler new. t fit: anArray. self assert: t scale asArray closeTo: #(0.5 0.5) @@ -25,7 +25,7 @@ PMStandardizationScalerTest >> testScale [ { #category : #tests } PMStandardizationScalerTest >> testVariance [ | anArray t | - anArray := #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + anArray := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). t := PMStandardizationScaler new. t fit: anArray. self assert: t variance asArray closeTo: #(0.25 0.25) From 60c965fd943f52a708443bc9321be8d0805e9bb8 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 30 Jul 2018 21:36:59 +0100 Subject: [PATCH 013/161] Add a transform test --- .../PMStandardizationScaler.class.st | 3 ++- .../PMStandardizationScalerTest.class.st | 26 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index 45344f0c5..afe4e3339 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -26,9 +26,10 @@ PMStandardizationScaler >> scale [ ] { #category : #transforming } -PMStandardizationScaler >> transform: aCollection [ +PMStandardizationScaler >> transform: aPMMatrix [ "Perform standardization by centering and scaling" + ^ (aPMMatrix rowsCollect: [ :each | each - self mean ]) rowsCollect: [ :each | each / self scale ] ] { #category : #information } diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index d9453b28b..165c3b753 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -6,27 +6,35 @@ Class { { #category : #tests } PMStandardizationScalerTest >> testMean [ - | anArray t | - anArray := PMMatrix rows: #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). + | aMatrix t | + aMatrix := PMMatrix rows: #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). t := PMStandardizationScaler new. - t fit: anArray. + t fit: aMatrix. self assert: t mean asArray closeTo: #(1.0 0.0 0.3333333) ] { #category : #tests } PMStandardizationScalerTest >> testScale [ - | anArray t | - anArray := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + | 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: anArray. + 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) asArray equals: #(#(-1.0 -1.0) #(-1.0 -1.0) #(1.0 1.0) #(1.0 1.0)) +] + { #category : #tests } PMStandardizationScalerTest >> testVariance [ - | anArray t | - anArray := PMMatrix rows: #((0.0 0.0) #(0.0 0.0) #(1.0 1.0) #(1.0 1.0)). + | 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: anArray. + t fit: aMatrix. self assert: t variance asArray closeTo: #(0.25 0.25) ] From 2e4ce5c6dc3eee5a1b03668c94fc4b31edf4d380 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 31 Jul 2018 09:13:25 +0100 Subject: [PATCH 014/161] Close #77. Implement class PMStandardizationScaler for doing standardization cleaning on matrices + abstract class PMDataTransformer. 5 unit tests include. --- .../PMStandardizationScaler.class.st | 4 ++-- .../PMStandardizationScalerTest.class.st | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index afe4e3339..92d397024 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -28,8 +28,8 @@ PMStandardizationScaler >> scale [ { #category : #transforming } PMStandardizationScaler >> transform: aPMMatrix [ "Perform standardization by centering and scaling" - - ^ (aPMMatrix rowsCollect: [ :each | each - self mean ]) rowsCollect: [ :each | each / self scale ] + + ^ PMMatrix rows: ((PMMatrix rows: (aPMMatrix rowsCollect: [ :each | each - self mean ])) rowsCollect: [ :each| each / (self scale) ]) ] { #category : #information } diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index 165c3b753..35a329e34 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -5,12 +5,12 @@ Class { } { #category : #tests } -PMStandardizationScalerTest >> testMean [ +PMStandardizationScalerTest >> testMean [ | aMatrix t | - aMatrix := PMMatrix rows: #(#(1.0 -1.0 2.0) #(2.0 0.0 0.0) #(0.0 1.0 -1.0)). + 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: #(1.0 0.0 0.3333333) + self assert: t mean asArray closeTo: #(0.5 0.5) ] { #category : #tests } @@ -27,7 +27,17 @@ 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) asArray equals: #(#(-1.0 -1.0) #(-1.0 -1.0) #(1.0 1.0) #(1.0 1.0)) + 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 } From 151aec2b509d714cd471bb5a1cc9bc0ade01ea5e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 31 Jul 2018 11:51:35 +0100 Subject: [PATCH 015/161] Add a fit: and transform: methods to PCA but apparently there is a bug. Results different from what you obtain from Python ... --- .../PMPrincipalComponentAnalyser.class.st | 32 ++++++++++++++++--- .../PMPrincipalComponentAnalyserTest.class.st | 12 +++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st index a20fbe66a..c06037aeb 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st @@ -12,9 +12,10 @@ Class { #superclass : #Object, #instVars : [ 'accumulatorForCovarianceMatrix', - 'jacobiTransform' + 'jacobiTransform', + 'componentsNumber' ], - #category : 'Math-PrincipalComponentAnalysis' + #category : #'Math-PrincipalComponentAnalysis' } { #category : #'instance creation' } @@ -32,7 +33,23 @@ PMPrincipalComponentAnalyser >> accumulate: aPMVectorOrArray [ PMPrincipalComponentAnalyser >> components [ "Precondition: accumulate: should have been used." - ^ self jacobiTransform evaluate + ^ self jacobiTransform evaluate copyFrom: 1 to: componentsNumber +] + +{ #category : #accessing } +PMPrincipalComponentAnalyser >> componentsNumber [ + ^ componentsNumber +] + +{ #category : #accessing } +PMPrincipalComponentAnalyser >> componentsNumber: anInteger [ + componentsNumber := anInteger +] + +{ #category : #accessing } +PMPrincipalComponentAnalyser >> fit: aPMMatrix [ + self initialize: aPMMatrix numberOfColumns. + aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ] ] { #category : #initialization } @@ -45,9 +62,16 @@ PMPrincipalComponentAnalyser >> jacobiTransform [ ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ] ] +{ #category : #accessing } +PMPrincipalComponentAnalyser >> transform: aPMMatrix [ + "Apply dimensionality reduction to aPMMatrix" + + ^ aPMMatrix * self transformMatrix transpose +] + { #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 + ^ PMMatrix rows: (self jacobiTransform transform rows copyFrom:1 to: componentsNumber ) ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index cd00278c4..ffeff28e4 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -48,3 +48,15 @@ PMPrincipalComponentAnalyserTest >> testLowEigenvalues [ expected := #(3.623277676214216e7 766.1878578405343 -8.608930577556605e-13 2.1213150252733508e-13 -1.9556315119125588e-13) asPMVector. actual - expected do: [ :each | self assert: each < 10e-8 ] ] + +{ #category : #tests } +PMPrincipalComponentAnalyserTest >> testTransformMatrix [ + | m pca | + m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). + pca := PMPrincipalComponentAnalyser new initialize: 2. + pca componentsNumber: 2. + m rowsDo: [ :eachRow | pca accumulate: eachRow ]. + pca components. + self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) + #(0.54491354 -0.83849224))) +] From ca2420d1823d1c31f20c53e1eb6f165646a18cf9 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 31 Jul 2018 14:26:53 +0100 Subject: [PATCH 016/161] Clean PMSingularValueDecomposition --- .../PMSingularValueDecomposition.class.st | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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 ] From d833fe5414a9d4ed8b34c4e450b7d4a288fd83ef Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 31 Jul 2018 15:01:25 +0100 Subject: [PATCH 017/161] Some optimisation for PMStandardizationScaler>>transform: --- .../PMStandardizationScaler.class.st | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index 92d397024..51cfa51f4 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -29,7 +29,10 @@ PMStandardizationScaler >> scale [ PMStandardizationScaler >> transform: aPMMatrix [ "Perform standardization by centering and scaling" - ^ PMMatrix rows: ((PMMatrix rows: (aPMMatrix rowsCollect: [ :each | each - self mean ])) rowsCollect: [ :each| each / (self scale) ]) + |mean scale| + mean := self mean. + scale := self scale. + ^ PMMatrix rows: ((PMMatrix rows: (aPMMatrix rowsCollect: [ :each | each - mean ])) rowsCollect: [ :each| each / scale]) ] { #category : #information } From ebad93743ef18c151b2f6cd1d8bb645ef9de2b0f Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 Aug 2018 16:31:24 +0100 Subject: [PATCH 018/161] Refactor PMPrincipalComponentAnalyser in order to have 2 implementation classes (Jacobi transformation of the covariance matrix and SVD) and one abstract classes for all PCA. Still 2 unit tests not green. --- .../PMPrincipalComponentAnalyser.class.st | 52 ++------------ ...onentAnalyserJacobiTransformation.class.st | 67 +++++++++++++++++++ .../PMPrincipalComponentAnalyserSVD.class.st | 27 ++++++++ .../PMPrincipalComponentAnalyserTest.class.st | 5 +- 4 files changed, 101 insertions(+), 50 deletions(-) create mode 100644 src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st create mode 100644 src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st index c06037aeb..591c1771f 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyser.class.st @@ -1,41 +1,12 @@ -" -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 : #'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 >> components [ - "Precondition: accumulate: should have been used." - - ^ self jacobiTransform evaluate copyFrom: 1 to: componentsNumber -] - { #category : #accessing } PMPrincipalComponentAnalyser >> componentsNumber [ ^ componentsNumber @@ -48,30 +19,15 @@ PMPrincipalComponentAnalyser >> componentsNumber: anInteger [ { #category : #accessing } PMPrincipalComponentAnalyser >> fit: aPMMatrix [ - self initialize: aPMMatrix numberOfColumns. - aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ] -] - -{ #category : #initialization } -PMPrincipalComponentAnalyser >> initialize: anInteger [ - accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: anInteger + ^ self subclassResponsibility ] { #category : #accessing } -PMPrincipalComponentAnalyser >> jacobiTransform [ - ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ] +PMPrincipalComponentAnalyser >> fitAndTransform: aPMMatrix [ + ^ (self fit: aPMMatrix) transform: aPMMatrix ] { #category : #accessing } PMPrincipalComponentAnalyser >> transform: aPMMatrix [ - "Apply dimensionality reduction to aPMMatrix" - - ^ aPMMatrix * self transformMatrix transpose -] - -{ #category : #accessing } -PMPrincipalComponentAnalyser >> 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 ) + ^ self subclassResponsibility ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st new file mode 100644 index 000000000..558f977cb --- /dev/null +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st @@ -0,0 +1,67 @@ +" +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 [ + self initialize: aPMMatrix numberOfColumns. + aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ]. + self components +] + +{ #category : #initialization } +PMPrincipalComponentAnalyserJacobiTransformation >> initialize: anInteger [ + accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: anInteger +] + +{ #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..eff5a46a7 --- /dev/null +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -0,0 +1,27 @@ +Class { + #name : #PMPrincipalComponentAnalyserSVD, + #superclass : #PMPrincipalComponentAnalyser, + #instVars : [ + 'svd' + ], + #category : #'Math-PrincipalComponentAnalysis' +} + +{ #category : #accessing } +PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ + svd := PMSingularValueDecomposition new initialize: aPMMatrix. +] + +{ #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: (svd rightSingularForm rows copyFrom:1 to: componentsNumber ) +] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index ffeff28e4..61553a16f 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -31,7 +31,8 @@ PMPrincipalComponentAnalyserTest >> testCanCreateCovarianceMatrix [ { #category : #tests } PMPrincipalComponentAnalyserTest >> testEigenvalues [ | actual expected analyser | - analyser := PMPrincipalComponentAnalyser new: 5. + analyser := PMPrincipalComponentAnalyserJacobiTransformation new. + analyser componentsNumber: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. @@ -53,7 +54,7 @@ PMPrincipalComponentAnalyserTest >> testLowEigenvalues [ PMPrincipalComponentAnalyserTest >> testTransformMatrix [ | m pca | m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - pca := PMPrincipalComponentAnalyser new initialize: 2. + pca := PMPrincipalComponentAnalyserJacobiTransformation new initialize: 2. pca componentsNumber: 2. m rowsDo: [ :eachRow | pca accumulate: eachRow ]. pca components. From 1e6be76f262fb5289dd2f0ad8d835751e3f181fd Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 Aug 2018 16:31:43 +0100 Subject: [PATCH 019/161] Cleanup setUp in PMSingularValueDecompositionTest --- .../PMSingularValueDecompositionTest.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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." From 6071f81ab9ef61b1df0b5abed4f2a8bdf4b719ee Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Thu, 2 Aug 2018 16:19:40 +0100 Subject: [PATCH 020/161] Clean and sync with book --- .../PMIncompleteBetaFractionTermServer.class.st | 16 ++++++++-------- .../PMIncompleteBetaFunction.class.st | 2 +- .../PMIncompleteGammaFunction.class.st | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st b/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st index 733274b83..a8b26162f 100644 --- a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st +++ b/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st @@ -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-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-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 } From 37b54f3fd421e2bb50057fe3a4b3ed0b19890eb8 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 08:56:20 +0100 Subject: [PATCH 021/161] Add flattenOnColumns and flattenOnRows + tests Close #79 --- src/Math-Matrix/PMMatrix.class.st | 18 +++++++++++++++++- src/Math-Tests-Matrix/PMMatrixTest.class.st | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 6eb9c81ca..643f7217d 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -434,6 +434,22 @@ PMMatrix >> equalsTo: aMatrix [ ^ true ] +{ #category : #'as yet unclassified' } +PMMatrix >> flattenOnColumns [ + | answer | + answer := #(). + self columnsDo: [ :each | answer := answer , each asArray ]. + ^ answer asPMVector +] + +{ #category : #'as yet unclassified' } +PMMatrix >> flattenOnRows [ + | answer | + answer := #(). + self rowsDo: [ :each | answer := answer , each asArray ]. + ^ answer asPMVector +] + { #category : #comparing } PMMatrix >> hash [ ^ rows hash @@ -495,7 +511,7 @@ PMMatrix >> isSymmetric [ { #category : #private } PMMatrix >> largestPowerOf2SmallerThan: anInteger [ - "Private - " + "Private" | m m2| m := 2. [ m2 := m * 2. diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 4ea448145..d1c300006 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -97,6 +97,20 @@ PMMatrixTest >> testEigenvaluesLargest [ self assert: ((roots at: 2) - eigenvalue) abs < 1.0e-08 ] +{ #category : #tests } +PMMatrixTest >> testFlattenOnColumns [ + | m | + m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). + self assert: m flattenOnColumns equals: #(1 4 7 2 5 8 3 6 9) asPMVector +] + +{ #category : #tests } +PMMatrixTest >> testFlattenOnRows [ + | m | + m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). + self assert: m flattenOnRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector +] + { #category : #'linear algebra' } PMMatrixTest >> testLUPDecomposition [ "Code Example 8.10" From d36b29fcc5aeb5feda6e1f75d95e3e4568c0ae85 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 09:35:00 +0100 Subject: [PATCH 022/161] Add argMaxOnColumns + argMaxOnRows for PMMatrix and argMax on vector. Close #80 --- src/Math-Core/PMVector.class.st | 7 +++++++ src/Math-Matrix/PMMatrix.class.st | 10 +++++++++ .../PMVectorTest.class.st | 9 ++++++++ src/Math-Tests-Matrix/PMMatrixTest.class.st | 21 +++++++++++++++---- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 8d1652cb3..a501fef1b 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -113,6 +113,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 [ diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 643f7217d..171b49922 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -227,6 +227,16 @@ 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)." diff --git a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st b/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st index a1893c6ab..d7594239b 100644 --- a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st +++ b/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st @@ -34,6 +34,15 @@ 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 >> testAsArray [ self assert: #(1 2 3 4) asPMVector asArray equals: #(1 2 3 4) diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index d1c300006..0890e4a12 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -4,6 +4,20 @@ Class { #category : 'Math-Tests-Matrix' } +{ #category : #tests } +PMMatrixTest >> testArgMaxOnColumns [ + | m | + m := PMMatrix rows: #(#(0 1 2) #(3 4 5)). + self assert: m argMaxOnColumns equals: #(2 2 2) asPMVector +] + +{ #category : #tests } +PMMatrixTest >> testArgMaxOnRows [ + | m | + m := PMMatrix rows: #(#(0 1 2) #(3 4 5)). + self assert: m argMaxOnRows equals: #(3 3) asPMVector +] + { #category : #tests } PMMatrixTest >> testAtAllPut [ @@ -111,7 +125,7 @@ PMMatrixTest >> testFlattenOnRows [ self assert: m flattenOnRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector ] -{ #category : #'linear algebra' } +{ #category : #tests } PMMatrixTest >> testLUPDecomposition [ "Code Example 8.10" @@ -149,7 +163,7 @@ PMMatrixTest >> testLinearEquations [ self assert: (sol2 at: 3) equals: 2 ] -{ #category : #'linear algebra' } +{ #category : #tests } PMMatrixTest >> testLinearEquationsSingle [ | s sol | s := PMLinearEquationSystem @@ -468,8 +482,7 @@ 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 } From e6ec6c157ff6b0a0af55e51605854203f8d3859e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 10:09:55 +0100 Subject: [PATCH 023/161] Following discussion #79 and #80, I rename the flatten methods and add more tests for argmax. --- src/Math-Matrix/PMMatrix.class.st | 4 ++-- src/Math-Tests-Matrix/PMMatrixTest.class.st | 24 ++++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 171b49922..42d0a31a1 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -445,7 +445,7 @@ PMMatrix >> equalsTo: aMatrix [ ] { #category : #'as yet unclassified' } -PMMatrix >> flattenOnColumns [ +PMMatrix >> flattenColumns [ | answer | answer := #(). self columnsDo: [ :each | answer := answer , each asArray ]. @@ -453,7 +453,7 @@ PMMatrix >> flattenOnColumns [ ] { #category : #'as yet unclassified' } -PMMatrix >> flattenOnRows [ +PMMatrix >> flattenRows [ | answer | answer := #(). self rowsDo: [ :each | answer := answer , each asArray ]. diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 0890e4a12..c8302e07a 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -6,16 +6,20 @@ Class { { #category : #tests } PMMatrixTest >> testArgMaxOnColumns [ - | m | - m := PMMatrix rows: #(#(0 1 2) #(3 4 5)). - self assert: m argMaxOnColumns equals: #(2 2 2) asPMVector + | 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 [ - | m | - m := PMMatrix rows: #(#(0 1 2) #(3 4 5)). - self assert: m argMaxOnRows equals: #(3 3) asPMVector + | 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 } @@ -112,17 +116,17 @@ PMMatrixTest >> testEigenvaluesLargest [ ] { #category : #tests } -PMMatrixTest >> testFlattenOnColumns [ +PMMatrixTest >> testFlattenColumns [ | m | m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). - self assert: m flattenOnColumns equals: #(1 4 7 2 5 8 3 6 9) asPMVector + self assert: m flattenColumns equals: #(1 4 7 2 5 8 3 6 9) asPMVector ] { #category : #tests } -PMMatrixTest >> testFlattenOnRows [ +PMMatrixTest >> testFlattenRows [ | m | m := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). - self assert: m flattenOnRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector + self assert: m flattenRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector ] { #category : #tests } From 482c2954ba82841bf0229554897de72b877279fb Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 10:59:31 +0100 Subject: [PATCH 024/161] Remove unecessary code in cos, cosh, log, sin, sinh, sqrt, tan and tanh on a matrix --- src/Math-Matrix/PMMatrix.class.st | 41 ++++++++------------- src/Math-Tests-Matrix/PMMatrixTest.class.st | 7 ++++ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 42d0a31a1..df3788d33 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -372,17 +372,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 } @@ -532,9 +530,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]) ] @@ -790,18 +786,15 @@ PMMatrix >> setDiagonal: aVector [ { #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 } @@ -827,9 +820,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 } @@ -898,18 +890,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-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index c8302e07a..b4ba9730b 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -235,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 | From 0ceabfdd2a1b95dcedbff946e299f658655b1299 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 11:05:11 +0100 Subject: [PATCH 025/161] Add a sign op on PMMAtrix + one test --- src/Math-Matrix/PMMatrix.class.st | 7 +++++++ src/Math-Tests-Matrix/PMMatrixTest.class.st | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index df3788d33..a2ca52cee 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -783,6 +783,13 @@ 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" diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index b4ba9730b..38dab0130 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -439,6 +439,13 @@ PMMatrixTest >> testMatrixMultiplyElementwise [ self assert: ((c rowAt: 2) at: 3) equals: 21 ] +{ #category : #comparing } +PMMatrixTest >> testMatrixSign [ + | a | + a := PMMatrix rows: #(#(-2 2 0) #(2 0 -2)). + a assert: a sign equals: (PMMatrix rows: #((-1 1 0) (1 0 -1))) +] + { #category : #'linear algebra' } PMMatrixTest >> testMatrixSubtract [ | a b c | From f8d1dcddede6735300124145acdf65b5176e638a Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 15:28:22 +0100 Subject: [PATCH 026/161] Remove PMPrincipalComponentAnalysisServer and tests because we change completely the API and old version got some problems with encapsulation ... --- ...onentAnalyserJacobiTransformation.class.st | 7 +-- .../PMPrincipalComponentAnalyserTest.class.st | 54 ++++--------------- ...MPrincipalComponentAnalysisServer.class.st | 30 ----------- ...ncipalComponentAnalysisServerTest.class.st | 13 ----- 4 files changed, 11 insertions(+), 93 deletions(-) delete mode 100644 src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServer.class.st delete mode 100644 src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalysisServerTest.class.st diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st index 558f977cb..76f96958e 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserJacobiTransformation.class.st @@ -37,16 +37,11 @@ PMPrincipalComponentAnalyserJacobiTransformation >> components [ { #category : #accessing } PMPrincipalComponentAnalyserJacobiTransformation >> fit: aPMMatrix [ - self initialize: aPMMatrix numberOfColumns. + accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: aPMMatrix numberOfColumns. aPMMatrix rowsDo: [ :eachRow | self accumulate: eachRow ]. self components ] -{ #category : #initialization } -PMPrincipalComponentAnalyserJacobiTransformation >> initialize: anInteger [ - accumulatorForCovarianceMatrix := PMCovarianceAccumulator new: anInteger -] - { #category : #accessing } PMPrincipalComponentAnalyserJacobiTransformation >> jacobiTransform [ ^ jacobiTransform ifNil: [ jacobiTransform := PMJacobiTransformation matrix: accumulatorForCovarianceMatrix covarianceMatrix ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 61553a16f..20c9a0577 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -10,54 +10,20 @@ Class { #category : 'Math-PrincipalComponentAnalysis' } -{ #category : #initialization } -PMPrincipalComponentAnalyserTest >> setUp [ - super 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 := PMPrincipalComponentAnalyserJacobiTransformation new. - analyser componentsNumber: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 ] +PMPrincipalComponentAnalyserTest >> testTransformMatrixWithJacobiTransformation [ + | m pca | + m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). + pca := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. + pca fit: m. + self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) ] { #category : #tests } -PMPrincipalComponentAnalyserTest >> testTransformMatrix [ +PMPrincipalComponentAnalyserTest >> testTransformMatrixWithSVD [ | m pca | m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - pca := PMPrincipalComponentAnalyserJacobiTransformation new initialize: 2. - pca componentsNumber: 2. - m rowsDo: [ :eachRow | pca accumulate: eachRow ]. - pca components. - self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) - #(0.54491354 -0.83849224))) + pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. + pca fit: m. + self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) ] 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) -] From 68c622d53eb3a7d4bc8437d2c78db42fc2abb2e2 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 15:36:26 +0100 Subject: [PATCH 027/161] Commit tests for PCA. --- .../PMPrincipalComponentAnalyserSVD.class.st | 25 +++++++++++++++++-- .../PMPrincipalComponentAnalyserTest.class.st | 11 ++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index eff5a46a7..7b2b9964d 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -2,7 +2,9 @@ Class { #name : #PMPrincipalComponentAnalyserSVD, #superclass : #PMPrincipalComponentAnalyser, #instVars : [ - 'svd' + 'svd', + 'u', + 'v' ], #category : #'Math-PrincipalComponentAnalysis' } @@ -10,6 +12,25 @@ Class { { #category : #accessing } PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ svd := PMSingularValueDecomposition new initialize: aPMMatrix. + u := svd leftSingularForm. + v := svd rightSingularForm. + "self flipEigenvectorsSign" + "flip does not work correctly at the moment" +] + +{ #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" + + "does not work at the moment" + | signs maxAbsCols i | + maxAbsCols := (u abs) argMaxOnColumns. + i := 0. + signs := (u rowsCollect: [ :each| i := i + 1. each at: (maxAbsCols at: i) + ]) sign. + u := u * signs. + v := v productWithVector: (signs copyFrom:1 to: v numberOfColumns) ] { #category : #accessing } @@ -23,5 +44,5 @@ PMPrincipalComponentAnalyserSVD >> transform: aPMMatrix [ PMPrincipalComponentAnalyserSVD >> transformMatrix [ "Return a matrix that can be applied to any data vector to extract the relevant component of the data vector" - ^ PMMatrix rows: (svd rightSingularForm rows copyFrom:1 to: componentsNumber ) + ^ PMMatrix rows: (v rows copyFrom: 1 to: componentsNumber) ] diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 20c9a0577..fbcc2defd 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -10,6 +10,17 @@ Class { #category : 'Math-PrincipalComponentAnalysis' } +{ #category : #tests } +PMPrincipalComponentAnalyserTest >> 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 := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. + pca2 fit: m. + self assert: pca1 transformMatrix closeTo: pca2 transformMatrix +] + { #category : #tests } PMPrincipalComponentAnalyserTest >> testTransformMatrixWithJacobiTransformation [ | m pca | From 4754ceb621df7f4186cb24c461a894830b7a9901 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 Aug 2018 16:01:36 +0100 Subject: [PATCH 028/161] Add one example with PCA with SVD on IRIS dataset --- .../PMPrincipalComponentAnalyserSVD.class.st | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 7b2b9964d..2c604bb3b 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -9,6 +9,32 @@ Class { #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 := PMSingularValueDecomposition new initialize: aPMMatrix. From cd0407ef702e0905456c7a2f59677660572f59d0 Mon Sep 17 00:00:00 2001 From: Oleksandr Zaytsev Date: Sat, 4 Aug 2018 10:39:19 -0400 Subject: [PATCH 029/161] Update CONTRIBUTING.md - changed 8 space indentation to 4 spaces --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 75457fa84..a7c383fcc 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: 'development' path: 'src'; + baseline: 'PolyMath'; + load. ``` where you replace XXX with your github user name. From 35f238cfa83801e77eb4de57e83fefc8169ee1d0 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 4 Aug 2018 18:05:50 +0100 Subject: [PATCH 030/161] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7c383fcc..c70fe89ec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`. From 48753393054d52608e138fc04087d16c95b1f793 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 4 Nov 2018 16:39:50 +0000 Subject: [PATCH 031/161] Moved the tests to a more sensible package --- .../PMSmoothedDensityTest.class.st | 2 +- src/Math-Tests-KernelSmoothing/package.st | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename src/{Math-KernelSmoothing => Math-Tests-KernelSmoothing}/PMSmoothedDensityTest.class.st (98%) create mode 100644 src/Math-Tests-KernelSmoothing/package.st 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' } From 510aa306dc1575d5d394e325533815d486253bad Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 4 Nov 2018 16:50:07 +0000 Subject: [PATCH 032/161] Moved the tests to a more sensible package. --- .../NumberExtensionsTest.class.st | 2 +- src/Math-Tests-Number-Extensions/package.st | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename src/{Math-Number-Extensions => Math-Tests-Number-Extensions}/NumberExtensionsTest.class.st (91%) create mode 100644 src/Math-Tests-Number-Extensions/package.st diff --git a/src/Math-Number-Extensions/NumberExtensionsTest.class.st b/src/Math-Tests-Number-Extensions/NumberExtensionsTest.class.st similarity index 91% rename from src/Math-Number-Extensions/NumberExtensionsTest.class.st rename to src/Math-Tests-Number-Extensions/NumberExtensionsTest.class.st index 09bd235dc..3d09246f8 100644 --- a/src/Math-Number-Extensions/NumberExtensionsTest.class.st +++ b/src/Math-Tests-Number-Extensions/NumberExtensionsTest.class.st @@ -1,7 +1,7 @@ Class { #name : #NumberExtensionsTest, #superclass : #TestCase, - #category : #'Math-Number-Extensions' + #category : #'Math-Tests-Number-Extensions' } { #category : #tests } 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' } From d90f38d9f675b97e5f04263af3667fac1b36966c Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 4 Nov 2018 16:58:06 +0000 Subject: [PATCH 033/161] Moved the tests to a more sensible package. --- .../PMPrincipalComponentAnalyserTest.class.st | 2 +- .../PMStandardizationScalerTest.class.st | 2 +- src/Math-Tests-PrincipalComponentAnalysis/package.st | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) rename src/{Math-PrincipalComponentAnalysis => Math-Tests-PrincipalComponentAnalysis}/PMPrincipalComponentAnalyserTest.class.st (96%) rename src/{Math-PrincipalComponentAnalysis => Math-Tests-PrincipalComponentAnalysis}/PMStandardizationScalerTest.class.st (96%) create mode 100644 src/Math-Tests-PrincipalComponentAnalysis/package.st diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st similarity index 96% rename from src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st rename to src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index fbcc2defd..2062f8c4c 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -7,7 +7,7 @@ Class { 'accumulator', 'server' ], - #category : 'Math-PrincipalComponentAnalysis' + #category : #'Math-Tests-PrincipalComponentAnalysis' } { #category : #tests } diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st similarity index 96% rename from src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st rename to src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index 35a329e34..0f7e56d36 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMStandardizationScalerTest, #superclass : #TestCase, - #category : #'Math-PrincipalComponentAnalysis' + #category : #'Math-Tests-PrincipalComponentAnalysis' } { #category : #tests } 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' } From 3a16adfc8e34191e73886bcedd99f036e815715d Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 4 Nov 2018 17:04:14 +0000 Subject: [PATCH 034/161] Moved the tests to a more sensible package. --- .../PMLaplaceGeneratorTest.class.st | 2 +- src/Math-Tests-RandomDistributionBased/package.st | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename src/{Math-RandomDistributionBased => Math-Tests-RandomDistributionBased}/PMLaplaceGeneratorTest.class.st (87%) create mode 100644 src/Math-Tests-RandomDistributionBased/package.st 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' } From 5f4f2680897ce0efa565c794293767c0eef70190 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 4 Nov 2018 17:17:41 +0000 Subject: [PATCH 035/161] Corrected the test - of course PMMatrix does not have the assert message as part of its interface. --- src/Math-Tests-Matrix/PMMatrixTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 38dab0130..62c49f910 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -443,7 +443,7 @@ PMMatrixTest >> testMatrixMultiplyElementwise [ PMMatrixTest >> testMatrixSign [ | a | a := PMMatrix rows: #(#(-2 2 0) #(2 0 -2)). - a assert: a sign equals: (PMMatrix rows: #((-1 1 0) (1 0 -1))) + self assert: a sign equals: (PMMatrix rows: #((-1 1 0) (1 0 -1))) ] { #category : #'linear algebra' } From 5d63cb7a32b84aa2e953dc5a8d73f918af237cb2 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 15:43:28 +0100 Subject: [PATCH 036/161] Add .project metadata --- .project | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 000000000..81083cc71 --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'src' +} \ No newline at end of file From fd6150034e50cbc269cea528cd68c24b2b9782ee Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 16:03:09 +0100 Subject: [PATCH 037/161] Rename Quaternion as PMQuaternion --- src/Math-Quaternion/Number.extension.st | 8 +- src/Math-Quaternion/PMComplex.extension.st | 6 +- ...ternion.class.st => PMQuaternion.class.st} | 118 +++++++++--------- ...extension.st => PMQuaternion.extension.st} | 26 ++-- ...est.class.st => PMQuaternionTest.class.st} | 78 ++++++------ 5 files changed, 118 insertions(+), 118 deletions(-) rename src/Math-Quaternion/{Quaternion.class.st => PMQuaternion.class.st} (87%) rename src/Math-Quaternion/{Quaternion.extension.st => PMQuaternion.extension.st} (80%) rename src/Math-Tests-Quaternion/{QuaternionTest.class.st => PMQuaternionTest.class.st} (84%) 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 87% rename from src/Math-Quaternion/Quaternion.class.st rename to src/Math-Quaternion/PMQuaternion.class.st index 5c226a2e0..9ac93fb99 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,31 +160,31 @@ 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 [ +PMQuaternion >> addPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 19/4/99 @@ -194,7 +194,7 @@ Quaternion >> addPolynomial: aPolynomial [ ] { #category : #accessing } -Quaternion >> angle [ +PMQuaternion >> angle [ "answer the rotation angle associated with the receiver" | sinThetaSur2 cosThetaSur2 | @@ -204,14 +204,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 +219,7 @@ Quaternion >> asQuaternion [ ] { #category : #arithmetic } -Quaternion >> conjugated [ +PMQuaternion >> conjugated [ "Return the conjugate of this quaternion number." ^self species @@ -230,7 +230,7 @@ Quaternion >> conjugated [ ] { #category : #'mathematical functions' } -Quaternion >> cos [ +PMQuaternion >> cos [ "Answer the receiver cosine" | z w | @@ -246,21 +246,21 @@ 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 [ +PMQuaternion >> dividingPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 17/4/99 " ^aPolynomial timesNumber: (1 / self) ] { #category : #'mathematical functions' } -Quaternion >> exp [ +PMQuaternion >> exp [ "Answer the receiver exponential" | z w | @@ -276,7 +276,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 +286,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 +303,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 +311,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 +338,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 +351,7 @@ Quaternion >> k [ ] { #category : #'mathematical functions' } -Quaternion >> ln [ +PMQuaternion >> ln [ "Answer the receiver natural logarithm" | z | @@ -374,14 +374,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,14 +390,14 @@ 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 [ +PMQuaternion >> 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 " @@ -405,27 +405,27 @@ Quaternion >> productWithVector: aVector [ ] { #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 +433,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 +450,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 +475,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 +507,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 +519,7 @@ Quaternion >> reduce [ ] { #category : #'mathematical functions' } -Quaternion >> sin [ +PMQuaternion >> sin [ "Answer the receiver sine" | z w | @@ -535,24 +535,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 +580,21 @@ Quaternion >> storeOn: aStream [ ] { #category : #'*Math-Quaternion' } -Quaternion >> subtractToPolynomial: aPolynomial [ +PMQuaternion >> subtractToPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 19/4/99 " ^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,7 +604,7 @@ Quaternion >> tanh [ ] { #category : #'*Math-Quaternion' } -Quaternion >> timesPolynomial: aPolynomial [ +PMQuaternion >> timesPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 17/4/99 added to Complex class 12 May 2012, Daniel Uber @@ -613,7 +613,7 @@ Quaternion >> timesPolynomial: aPolynomial [ ] { #category : #accessing } -Quaternion >> unreal [ +PMQuaternion >> unreal [ "answer the unreal part of the receiver" ^self species diff --git a/src/Math-Quaternion/Quaternion.extension.st b/src/Math-Quaternion/PMQuaternion.extension.st similarity index 80% rename from src/Math-Quaternion/Quaternion.extension.st rename to src/Math-Quaternion/PMQuaternion.extension.st index 5a6d05c6c..890210c8c 100644 --- a/src/Math-Quaternion/Quaternion.extension.st +++ b/src/Math-Quaternion/PMQuaternion.extension.st @@ -1,7 +1,7 @@ -Extension { #name : #Quaternion } +Extension { #name : #PMQuaternion } { #category : #'*Math-Quaternion' } -Quaternion >> addPolynomial: aPolynomial [ +PMQuaternion >> addPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 19/4/99 @@ -11,14 +11,14 @@ Quaternion >> addPolynomial: aPolynomial [ ] { #category : #'*Math-Quaternion' } -Quaternion >> dividingPolynomial: aPolynomial [ +PMQuaternion >> 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 [ +PMQuaternion >> 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 " @@ -26,13 +26,7 @@ Quaternion >> productWithVector: aVector [ ] { #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 [ +PMQuaternion class >> random [ "Answers a random quaternion with abs at most one." ^ (0.5 - Float random) @@ -42,14 +36,20 @@ Quaternion class >> random [ ] { #category : #'*Math-Quaternion' } -Quaternion >> subtractToPolynomial: aPolynomial [ +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 [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 19/4/99 " ^aPolynomial addNumber: self negated ] { #category : #'*Math-Quaternion' } -Quaternion >> timesPolynomial: aPolynomial [ +PMQuaternion >> timesPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 17/4/99 added to Complex class 12 May 2012, Daniel Uber 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. ] From 853efd6b4024eb9c5b445037498f4a15aa983017 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 16:42:53 +0100 Subject: [PATCH 038/161] QuantileTest => PMQuantileTest --- ...eTest.class.st => PMQuantileTest.class.st} | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) rename src/Math-Tests-Quantile/{QuantileTest.class.st => PMQuantileTest.class.st} (92%) 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 From d5fe64e13cd150a4b567660cdcdb302534754e23 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 16:58:58 +0100 Subject: [PATCH 039/161] Working on #16 --- ...verTest.class.st => PMAB2SolverTest.class.st} | 12 ++++++------ ...erTest.class.st => PMAB2StepperTest.class.st} | 12 ++++++------ ...verTest.class.st => PMAB3SolverTest.class.st} | 12 ++++++------ ...erTest.class.st => PMAB3StepperTest.class.st} | 12 ++++++------ ...verTest.class.st => PMAB4SolverTest.class.st} | 10 +++++----- ...erTest.class.st => PMAB4StepperTest.class.st} | 12 ++++++------ ...verTest.class.st => PMAM3SolverTest.class.st} | 10 +++++----- ...erTest.class.st => PMAM3StepperTest.class.st} | 14 +++++++------- ...verTest.class.st => PMAM4SolverTest.class.st} | 10 +++++----- ...erTest.class.st => PMAM4StepperTest.class.st} | 12 ++++++------ ...erTest.class.st => PMBDF2SolverTest.class.st} | 12 ++++++------ ...rTest.class.st => PMBDF2StepperTest.class.st} | 14 +++++++------- ...erTest.class.st => PMBDF3SolverTest.class.st} | 10 +++++----- ...rTest.class.st => PMBDF3StepperTest.class.st} | 12 ++++++------ ...erTest.class.st => PMBDF4SolverTest.class.st} | 10 +++++----- ...rTest.class.st => PMBDF4StepperTest.class.st} | 12 ++++++------ ...ass.st => PMBeckwardEulerSolverTest.class.st} | 10 +++++----- ...ss.st => PMBeckwardEulerStepperTest.class.st} | 12 ++++++------ ...rTest.class.st => PMEulerSolverTest.class.st} | 10 +++++----- ...Test.class.st => PMEulerStepperTest.class.st} | 12 ++++++------ ...rTest.class.st => PMHeunStepperTest.class.st} | 14 +++++++------- ....st => PMImplicitMidpointSolverTest.class.st} | 6 +++--- ...st => PMImplicitMidpointStepperTest.class.st} | 14 +++++++------- ...st.class.st => PMMidpointSolverTest.class.st} | 14 +++++++------- ...t.class.st => PMMidpointStepperTest.class.st} | 16 ++++++++-------- ...temTest.class.st => PMODESystemTest.class.st} | 14 +++++++------- ....class.st => PMRungeKuttaSolverTest.class.st} | 14 +++++++------- ...class.st => PMRungeKuttaStepperTest.class.st} | 16 ++++++++-------- ...epperTest.class.st => PMStepperTest.class.st} | 10 +++++----- ...t.class.st => PMTrapezoidSolverTest.class.st} | 10 +++++----- ....class.st => PMTrapezoidStepperTest.class.st} | 14 +++++++------- 31 files changed, 186 insertions(+), 186 deletions(-) rename src/Math-Tests-ODE/{AB2SolverTest.class.st => PMAB2SolverTest.class.st} (90%) rename src/Math-Tests-ODE/{AB2StepperTest.class.st => PMAB2StepperTest.class.st} (88%) rename src/Math-Tests-ODE/{AB3SolverTest.class.st => PMAB3SolverTest.class.st} (90%) rename src/Math-Tests-ODE/{AB3StepperTest.class.st => PMAB3StepperTest.class.st} (87%) rename src/Math-Tests-ODE/{AB4SolverTest.class.st => PMAB4SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{AB4StepperTest.class.st => PMAB4StepperTest.class.st} (88%) rename src/Math-Tests-ODE/{AM3SolverTest.class.st => PMAM3SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{AM3StepperTest.class.st => PMAM3StepperTest.class.st} (90%) rename src/Math-Tests-ODE/{AM4SolverTest.class.st => PMAM4SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{AM4StepperTest.class.st => PMAM4StepperTest.class.st} (88%) rename src/Math-Tests-ODE/{BDF2SolverTest.class.st => PMBDF2SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{BDF2StepperTest.class.st => PMBDF2StepperTest.class.st} (90%) rename src/Math-Tests-ODE/{BDF3SolverTest.class.st => PMBDF3SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{BDF3StepperTest.class.st => PMBDF3StepperTest.class.st} (88%) rename src/Math-Tests-ODE/{BDF4SolverTest.class.st => PMBDF4SolverTest.class.st} (91%) rename src/Math-Tests-ODE/{BDF4StepperTest.class.st => PMBDF4StepperTest.class.st} (90%) rename src/Math-Tests-ODE/{BeckwardEulerSolverTest.class.st => PMBeckwardEulerSolverTest.class.st} (87%) rename src/Math-Tests-ODE/{BeckwardEulerStepperTest.class.st => PMBeckwardEulerStepperTest.class.st} (87%) rename src/Math-Tests-ODE/{EulerSolverTest.class.st => PMEulerSolverTest.class.st} (90%) rename src/Math-Tests-ODE/{EulerStepperTest.class.st => PMEulerStepperTest.class.st} (88%) rename src/Math-Tests-ODE/{HeunStepperTest.class.st => PMHeunStepperTest.class.st} (88%) rename src/Math-Tests-ODE/{ImplicitMidpointSolverTest.class.st => PMImplicitMidpointSolverTest.class.st} (80%) rename src/Math-Tests-ODE/{ImplicitMidpointStepperTest.class.st => PMImplicitMidpointStepperTest.class.st} (85%) rename src/Math-Tests-ODE/{MidpointSolverTest.class.st => PMMidpointSolverTest.class.st} (91%) rename src/Math-Tests-ODE/{MidpointStepperTest.class.st => PMMidpointStepperTest.class.st} (88%) rename src/Math-Tests-ODE/{ODESystemTest.class.st => PMODESystemTest.class.st} (82%) rename src/Math-Tests-ODE/{RungeKuttaSolverTest.class.st => PMRungeKuttaSolverTest.class.st} (91%) rename src/Math-Tests-ODE/{RungeKuttaStepperTest.class.st => PMRungeKuttaStepperTest.class.st} (87%) rename src/Math-Tests-ODE/{StepperTest.class.st => PMStepperTest.class.st} (71%) rename src/Math-Tests-ODE/{TrapezoidSolverTest.class.st => PMTrapezoidSolverTest.class.st} (90%) rename src/Math-Tests-ODE/{TrapezoidStepperTest.class.st => PMTrapezoidStepperTest.class.st} (87%) diff --git a/src/Math-Tests-ODE/AB2SolverTest.class.st b/src/Math-Tests-ODE/PMAB2SolverTest.class.st similarity index 90% rename from src/Math-Tests-ODE/AB2SolverTest.class.st rename to src/Math-Tests-ODE/PMAB2SolverTest.class.st index 444301007..0eb7f29cc 100644 --- a/src/Math-Tests-ODE/AB2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB2SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ AB2SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -AB2SolverTest >> testSimpleSystem3 [ +PMAB2SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [:x :t | 2 * t * x]. @@ -29,7 +29,7 @@ AB2SolverTest >> testSimpleSystem3 [ ] { #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 ) / @@ -42,7 +42,7 @@ AB2SolverTest >> testSimpleSystem4 [ ] { #category : #'tests-solving' } -AB2SolverTest >> testVectorSystem [ +PMAB2SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [:x :t | diff --git a/src/Math-Tests-ODE/AB2StepperTest.class.st b/src/Math-Tests-ODE/PMAB2StepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/AB2StepperTest.class.st rename to src/Math-Tests-ODE/PMAB2StepperTest.class.st index c4ae41762..1424df3bc 100644 --- a/src/Math-Tests-ODE/AB2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB2StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #AB2StepperTest, + #name : #PMAB2StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -AB2StepperTest >> testOrderIsTwo [ +PMAB2StepperTest >> testOrderIsTwo [ self assert: AB2Stepper order equals: 2 ] { #category : #'tests-stepping' } -AB2StepperTest >> testSimpleSystem [ +PMAB2StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ AB2StepperTest >> testSimpleSystem [ ] { #category : #'tests-stepping' } -AB2StepperTest >> testSimpleSystem2 [ +PMAB2StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -56,7 +56,7 @@ AB2StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -AB2StepperTest >> testSimpleSystem3 [ +PMAB2StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/AB3SolverTest.class.st b/src/Math-Tests-ODE/PMAB3SolverTest.class.st similarity index 90% rename from src/Math-Tests-ODE/AB3SolverTest.class.st rename to src/Math-Tests-ODE/PMAB3SolverTest.class.st index 900943eac..782d0510f 100644 --- a/src/Math-Tests-ODE/AB3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB3SolverTest.class.st @@ -1,11 +1,11 @@ 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 @@ -32,7 +32,7 @@ AB3SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -AB3SolverTest >> testSimpleSystem3 [ +PMAB3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -58,7 +58,7 @@ AB3SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -AB3SolverTest >> testSimpleSystem4 [ +PMAB3SolverTest >> testSimpleSystem4 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem @@ -79,7 +79,7 @@ AB3SolverTest >> testSimpleSystem4 [ ] { #category : #'tests-solving' } -AB3SolverTest >> testVectorSystem [ +PMAB3SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.001. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/AB3StepperTest.class.st b/src/Math-Tests-ODE/PMAB3StepperTest.class.st similarity index 87% rename from src/Math-Tests-ODE/AB3StepperTest.class.st rename to src/Math-Tests-ODE/PMAB3StepperTest.class.st index d219e946b..b46b9a416 100644 --- a/src/Math-Tests-ODE/AB3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB3StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #AB3StepperTest, + #name : #PMAB3StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -AB3StepperTest >> testOrderIsThree [ +PMAB3StepperTest >> testOrderIsThree [ self assert: AB3Stepper order equals: 3 ] { #category : #'tests-stepping' } -AB3StepperTest >> testSimpleSystem [ +PMAB3StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ AB3StepperTest >> testSimpleSystem [ ] { #category : #'tests-stepping' } -AB3StepperTest >> testSimpleSystem2 [ +PMAB3StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -56,7 +56,7 @@ AB3StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -AB3StepperTest >> testSimpleSystem3 [ +PMAB3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/AB4SolverTest.class.st b/src/Math-Tests-ODE/PMAB4SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/AB4SolverTest.class.st rename to src/Math-Tests-ODE/PMAB4SolverTest.class.st index 210b8d7a7..b2f4df603 100644 --- a/src/Math-Tests-ODE/AB4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB4SolverTest.class.st @@ -1,11 +1,11 @@ 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 @@ -32,7 +32,7 @@ AB4SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -AB4SolverTest >> testSimpleSystem3 [ +PMAB4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -79,7 +79,7 @@ AB4SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -AB4SolverTest >> testVectorSystem [ +PMAB4SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.001. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/AB4StepperTest.class.st b/src/Math-Tests-ODE/PMAB4StepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/AB4StepperTest.class.st rename to src/Math-Tests-ODE/PMAB4StepperTest.class.st index 367fdf6c7..9b46697f7 100644 --- a/src/Math-Tests-ODE/AB4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB4StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #AB4StepperTest, + #name : #PMAB4StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -AB4StepperTest >> testOrderIsFour [ +PMAB4StepperTest >> testOrderIsFour [ self assert: AB4Stepper order equals: 4 ] { #category : #'tests-stepping' } -AB4StepperTest >> testSimpleSystem [ +PMAB4StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ AB4StepperTest >> testSimpleSystem [ ] { #category : #'tests-stepping' } -AB4StepperTest >> testSimpleSystem2 [ +PMAB4StepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -56,7 +56,7 @@ AB4StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -AB4StepperTest >> testSimpleSystem3 [ +PMAB4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/AM3SolverTest.class.st b/src/Math-Tests-ODE/PMAM3SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/AM3SolverTest.class.st rename to src/Math-Tests-ODE/PMAM3SolverTest.class.st index 7c9edaa6e..527c6067a 100644 --- a/src/Math-Tests-ODE/AM3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM3SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ AM3SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -AM3SolverTest >> testSimpleSystem3 [ +PMAM3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -57,7 +57,7 @@ AM3SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -AM3SolverTest >> testVectorSystem [ +PMAM3SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/AM3StepperTest.class.st b/src/Math-Tests-ODE/PMAM3StepperTest.class.st similarity index 90% rename from src/Math-Tests-ODE/AM3StepperTest.class.st rename to src/Math-Tests-ODE/PMAM3StepperTest.class.st index 49b58fcf8..8734e3277 100644 --- a/src/Math-Tests-ODE/AM3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM3StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #AM3StepperTest, + #name : #PMAM3StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -AM3StepperTest >> testOrderIsThree [ +PMAM3StepperTest >> testOrderIsThree [ self assert: AM3Stepper order equals: 3 ] { #category : #'tests-stepping' } -AM3StepperTest >> testSimpleSystem [ +PMAM3StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -42,7 +42,7 @@ AM3StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -AM3StepperTest >> testSimpleSystem3 [ +PMAM3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -82,7 +82,7 @@ AM3StepperTest >> testSimpleSystem3 [ ] { #category : #'tests-stepping' } -AM3StepperTest >> testVectorSystem [ +PMAM3StepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/AM4SolverTest.class.st b/src/Math-Tests-ODE/PMAM4SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/AM4SolverTest.class.st rename to src/Math-Tests-ODE/PMAM4SolverTest.class.st index 22caf7824..a7b22a852 100644 --- a/src/Math-Tests-ODE/AM4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM4SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ AM4SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -AM4SolverTest >> testSimpleSystem3 [ +PMAM4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -57,7 +57,7 @@ AM4SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -AM4SolverTest >> testVectorSystem [ +PMAM4SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/AM4StepperTest.class.st b/src/Math-Tests-ODE/PMAM4StepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/AM4StepperTest.class.st rename to src/Math-Tests-ODE/PMAM4StepperTest.class.st index df2aacf50..46507b18e 100644 --- a/src/Math-Tests-ODE/AM4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM4StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #AM4StepperTest, + #name : #PMAM4StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -AM4StepperTest >> testOrderIsFour [ +PMAM4StepperTest >> testOrderIsFour [ self assert: AM4Stepper order equals: 4 ] { #category : #'tests-stepping' } -AM4StepperTest >> testSimpleSystem [ +PMAM4StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -42,7 +42,7 @@ AM4StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -AM4StepperTest >> testSimpleSystem3 [ +PMAM4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/BDF2SolverTest.class.st b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/BDF2SolverTest.class.st rename to src/Math-Tests-ODE/PMBDF2SolverTest.class.st index d51b4a6d4..b544590c8 100644 --- a/src/Math-Tests-ODE/BDF2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ BDF2SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -BDF2SolverTest >> testSimpleSystem3 [ +PMBDF2SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -57,7 +57,7 @@ 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 ]. @@ -88,7 +88,7 @@ BDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ ] { #category : #'tests-solving' } -BDF2SolverTest >> testSolveX0T0T1 [ +PMBDF2SolverTest >> testSolveX0T0T1 [ | solver stepper system dt finalState | dt := 0.1. system := ImplicitSystem block: [ :x :t | (t * x) exp ]. diff --git a/src/Math-Tests-ODE/BDF2StepperTest.class.st b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st similarity index 90% rename from src/Math-Tests-ODE/BDF2StepperTest.class.st rename to src/Math-Tests-ODE/PMBDF2StepperTest.class.st index 3c7cb6b9f..cc96df244 100644 --- a/src/Math-Tests-ODE/BDF2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #BDF2StepperTest, + #name : #PMBDF2StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -BDF2StepperTest >> testOrderIsTwo [ +PMBDF2StepperTest >> testOrderIsTwo [ self assert: BDF2Stepper order equals: 2 ] { #category : #'tests-stepping' } -BDF2StepperTest >> testSimpleSystem [ +PMBDF2StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -43,7 +43,7 @@ BDF2StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -BDF2StepperTest >> testSimpleSystem3 [ +PMBDF2StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -83,7 +83,7 @@ BDF2StepperTest >> testSimpleSystem3 [ ] { #category : #'tests-stepping' } -BDF2StepperTest >> testVectorSystem [ +PMBDF2StepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.0001. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/BDF3SolverTest.class.st b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/BDF3SolverTest.class.st rename to src/Math-Tests-ODE/PMBDF3SolverTest.class.st index 0fb65a690..0f0dfd351 100644 --- a/src/Math-Tests-ODE/BDF3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ BDF3SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -BDF3SolverTest >> testSimpleSystem3 [ +PMBDF3SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -57,7 +57,7 @@ BDF3SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -BDF3SolverTest >> testVectorSystem [ +PMBDF3SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/BDF3StepperTest.class.st b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/BDF3StepperTest.class.st rename to src/Math-Tests-ODE/PMBDF3StepperTest.class.st index f45237145..7724eddec 100644 --- a/src/Math-Tests-ODE/BDF3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #BDF3StepperTest, + #name : #PMBDF3StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -BDF3StepperTest >> testOrderIsThree [ +PMBDF3StepperTest >> testOrderIsThree [ self assert: BDF3Stepper order equals: 3 ] { #category : #'tests-stepping' } -BDF3StepperTest >> testSimpleSystem [ +PMBDF3StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -42,7 +42,7 @@ BDF3StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -BDF3StepperTest >> testSimpleSystem3 [ +PMBDF3StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/BDF4SolverTest.class.st b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/BDF4SolverTest.class.st rename to src/Math-Tests-ODE/PMBDF4SolverTest.class.st index 387855cf9..e3056dc7d 100644 --- a/src/Math-Tests-ODE/BDF4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -18,7 +18,7 @@ BDF4SolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -BDF4SolverTest >> testSimpleSystem3 [ +PMBDF4SolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -65,7 +65,7 @@ BDF4SolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -BDF4SolverTest >> testVectorSystem [ +PMBDF4SolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/BDF4StepperTest.class.st b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st similarity index 90% rename from src/Math-Tests-ODE/BDF4StepperTest.class.st rename to src/Math-Tests-ODE/PMBDF4StepperTest.class.st index c842c7efc..a0b0881a9 100644 --- a/src/Math-Tests-ODE/BDF4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #BDF4StepperTest, + #name : #PMBDF4StepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -BDF4StepperTest >> testOrderIsFour [ +PMBDF4StepperTest >> testOrderIsFour [ self assert: BDF4Stepper order equals: 4 ] { #category : #'tests-stepping' } -BDF4StepperTest >> testSimpleSystem [ +PMBDF4StepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -43,7 +43,7 @@ BDF4StepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -BDF4StepperTest >> testSimpleSystem3 [ +PMBDF4StepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st similarity index 87% rename from src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st rename to src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st index 92dfec4a6..2ff16eda2 100644 --- a/src/Math-Tests-ODE/BeckwardEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st @@ -1,11 +1,11 @@ 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 ]. @@ -24,7 +24,7 @@ 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)]. @@ -35,7 +35,7 @@ BeckwardEulerSolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -BeckwardEulerSolverTest >> testVectorSystem [ +PMBeckwardEulerSolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st similarity index 87% rename from src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st rename to src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st index 3528fe026..9d94eeaf2 100644 --- a/src/Math-Tests-ODE/BeckwardEulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st @@ -1,11 +1,11 @@ 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 | @@ -26,7 +26,7 @@ BeckwardEulerStepperTest >> testDoStepTime [ ] { #category : #'tests-stepping' } -BeckwardEulerStepperTest >> testDoStepTimeStepSize [ +PMBeckwardEulerStepperTest >> testDoStepTimeStepSize [ | stepper sys dt | sys := ImplicitSystem block: [ :x :t | x * t ]. stepper := ImplicitStepper onSystem: sys. @@ -38,7 +38,7 @@ 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)]. @@ -49,7 +49,7 @@ BeckwardEulerStepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -BeckwardEulerStepperTest >> testSimpleSystem3 [ +PMBeckwardEulerStepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. diff --git a/src/Math-Tests-ODE/EulerSolverTest.class.st b/src/Math-Tests-ODE/PMEulerSolverTest.class.st similarity index 90% rename from src/Math-Tests-ODE/EulerSolverTest.class.st rename to src/Math-Tests-ODE/PMEulerSolverTest.class.st index 5997d8c43..d8d1be1ba 100644 --- a/src/Math-Tests-ODE/EulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMEulerSolverTest.class.st @@ -2,13 +2,13 @@ An ODESolverTest is a test class for testing the behavior of ODESolver " Class { - #name : #EulerSolverTest, + #name : #PMEulerSolverTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-solving' } -EulerSolverTest >> testSimpleSystem2 [ +PMEulerSolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -35,7 +35,7 @@ EulerSolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -EulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ +PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ | solver stepper system dt finalState | dt := 0.2. system := ExplicitSystem block: [ :x :t | (t * x) exp ]. @@ -66,7 +66,7 @@ EulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ ] { #category : #'tests-solving' } -EulerSolverTest >> testSolveX0T0T1 [ +PMEulerSolverTest >> testSolveX0T0T1 [ | solver stepper system dt finalState | dt := 0.1. system := ExplicitSystem block: [ :x :t | (t * x) exp ]. diff --git a/src/Math-Tests-ODE/EulerStepperTest.class.st b/src/Math-Tests-ODE/PMEulerStepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/EulerStepperTest.class.st rename to src/Math-Tests-ODE/PMEulerStepperTest.class.st index 5acf749f1..3a65e5f4d 100644 --- a/src/Math-Tests-ODE/EulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMEulerStepperTest.class.st @@ -2,13 +2,13 @@ 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 | @@ -27,7 +27,7 @@ EulerStepperTest >> testDoStepTime [ ] { #category : #'tests-stepping' } -EulerStepperTest >> testDoStepTimeStepSize [ +PMEulerStepperTest >> testDoStepTimeStepSize [ | stepper sys dt | sys := ExplicitSystem block: [ :x :t | x * t ]. stepper := ExplicitStepper onSystem: sys. @@ -39,7 +39,7 @@ EulerStepperTest >> testDoStepTimeStepSize [ ] { #category : #'tests-stepping' } -EulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ +PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ | order | order := ExplicitStepper new order. self assert: order notNil. @@ -47,7 +47,7 @@ EulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ ] { #category : #'tests-stepping' } -EulerStepperTest >> testVectorSystem [ +PMEulerStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.001. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/HeunStepperTest.class.st b/src/Math-Tests-ODE/PMHeunStepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/HeunStepperTest.class.st rename to src/Math-Tests-ODE/PMHeunStepperTest.class.st index ca001422f..90d9d9cc6 100644 --- a/src/Math-Tests-ODE/HeunStepperTest.class.st +++ b/src/Math-Tests-ODE/PMHeunStepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #HeunStepperTest, + #name : #PMHeunStepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #tests } -HeunStepperTest >> testOrderIsTwo [ +PMHeunStepperTest >> testOrderIsTwo [ self assert: HeunStepper order equals: 2 ] { #category : #tests } -HeunStepperTest >> testSimpleSystem [ +PMHeunStepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ HeunStepperTest >> testSimpleSystem [ ] { #category : #tests } -HeunStepperTest >> testSimpleSystem2 [ +PMHeunStepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem @@ -56,7 +56,7 @@ HeunStepperTest >> testSimpleSystem2 [ ] { #category : #tests } -HeunStepperTest >> testSimpleSystem3 [ +PMHeunStepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -82,7 +82,7 @@ HeunStepperTest >> testSimpleSystem3 [ ] { #category : #tests } -HeunStepperTest >> testVectorSystem [ +PMHeunStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st similarity index 80% rename from src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st rename to src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st index 865f6210a..7cff177b9 100644 --- a/src/Math-Tests-ODE/ImplicitMidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #ImplicitMidpointSolverTest, + #name : #PMImplicitMidpointSolverTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-solving' } -ImplicitMidpointSolverTest >> testSimpleSystem2 [ +PMImplicitMidpointSolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ImplicitSystem block: [:x :t | 3 * (t negated exp) - (0.4 * x)]. diff --git a/src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st similarity index 85% rename from src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st rename to src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st index f41419c32..602710202 100644 --- a/src/Math-Tests-ODE/ImplicitMidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #ImplicitMidpointStepperTest, + #name : #PMImplicitMidpointStepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -ImplicitMidpointStepperTest >> testOrderIsTwo [ +PMImplicitMidpointStepperTest >> testOrderIsTwo [ self assert: ImplicitMidpointStepper order equals: 2 ] { #category : #'tests-stepping' } -ImplicitMidpointStepperTest >> testSimpleSystem [ +PMImplicitMidpointStepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ 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)]. @@ -40,7 +40,7 @@ ImplicitMidpointStepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -ImplicitMidpointStepperTest >> testSimpleSystem3 [ +PMImplicitMidpointStepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -59,7 +59,7 @@ ImplicitMidpointStepperTest >> testSimpleSystem3 [ ] { #category : #'tests-stepping' } -ImplicitMidpointStepperTest >> testVectorSystem [ +PMImplicitMidpointStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/MidpointSolverTest.class.st b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st similarity index 91% rename from src/Math-Tests-ODE/MidpointSolverTest.class.st rename to src/Math-Tests-ODE/PMMidpointSolverTest.class.st index bd7b431a3..3bf9a3d1d 100644 --- a/src/Math-Tests-ODE/MidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st @@ -1,11 +1,11 @@ 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 ]. @@ -24,7 +24,7 @@ MidpointSolverTest >> testSimpleSystem [ ] { #category : #'tests-solving' } -MidpointSolverTest >> testSimpleSystem1 [ +PMMidpointSolverTest >> testSimpleSystem1 [ | solver stepper system dt | dt := 0.025. system := ExplicitSystem block: [ :x :t | t tan + 1 ]. @@ -57,7 +57,7 @@ MidpointSolverTest >> testSimpleSystem1 [ ] { #category : #'tests-solving' } -MidpointSolverTest >> testSimpleSystem2 [ +PMMidpointSolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem @@ -91,7 +91,7 @@ MidpointSolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -MidpointSolverTest >> testSimpleSystem3 [ +PMMidpointSolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -131,7 +131,7 @@ MidpointSolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -MidpointSolverTest >> testVectorSystem [ +PMMidpointSolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/MidpointStepperTest.class.st b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st similarity index 88% rename from src/Math-Tests-ODE/MidpointStepperTest.class.st rename to src/Math-Tests-ODE/PMMidpointStepperTest.class.st index f925a23be..bf99258d8 100644 --- a/src/Math-Tests-ODE/MidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st @@ -1,16 +1,16 @@ Class { - #name : #MidpointStepperTest, + #name : #PMMidpointStepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #'tests-stepping' } -MidpointStepperTest >> testOrderIsTwo [ +PMMidpointStepperTest >> testOrderIsTwo [ self assert: MidpointStepper order equals: 2 ] { #category : #'tests-stepping' } -MidpointStepperTest >> testSimpleSystem [ +PMMidpointStepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -29,7 +29,7 @@ MidpointStepperTest >> testSimpleSystem [ ] { #category : #'tests-stepping' } -MidpointStepperTest >> testSimpleSystem2 [ +PMMidpointStepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -56,7 +56,7 @@ MidpointStepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -MidpointStepperTest >> testSimpleSystem3 [ +PMMidpointStepperTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -89,7 +89,7 @@ MidpointStepperTest >> testSimpleSystem3 [ ] { #category : #'tests-stepping' } -MidpointStepperTest >> testSimpleSystem4 [ +PMMidpointStepperTest >> testSimpleSystem4 [ | solver stepper system dt | dt := 0.0001. system := ExplicitSystem @@ -109,7 +109,7 @@ MidpointStepperTest >> testSimpleSystem4 [ ] { #category : #'tests-stepping' } -MidpointStepperTest >> testVectorSystem [ +PMMidpointStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/ODESystemTest.class.st b/src/Math-Tests-ODE/PMODESystemTest.class.st similarity index 82% rename from src/Math-Tests-ODE/ODESystemTest.class.st rename to src/Math-Tests-ODE/PMODESystemTest.class.st index 2a08e42ab..4ce88164d 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 ] { #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 91% rename from src/Math-Tests-ODE/RungeKuttaSolverTest.class.st rename to src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st index 880da0416..865627d2d 100644 --- a/src/Math-Tests-ODE/RungeKuttaSolverTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st @@ -1,11 +1,11 @@ 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 ]. @@ -24,7 +24,7 @@ RungeKuttaSolverTest >> testSimpleSystem [ ] { #category : #'tests-solving' } -RungeKuttaSolverTest >> testSimpleSystem1 [ +PMRungeKuttaSolverTest >> testSimpleSystem1 [ | solver stepper system dt | dt := 0.025. system := ExplicitSystem block: [ :x :t | t tan + 1 ]. @@ -57,7 +57,7 @@ RungeKuttaSolverTest >> testSimpleSystem1 [ ] { #category : #'tests-solving' } -RungeKuttaSolverTest >> testSimpleSystem2 [ +PMRungeKuttaSolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem @@ -91,7 +91,7 @@ RungeKuttaSolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -RungeKuttaSolverTest >> testSimpleSystem3 [ +PMRungeKuttaSolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ExplicitSystem block: [ :x :t | 2 * t * x ]. @@ -131,7 +131,7 @@ RungeKuttaSolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -RungeKuttaSolverTest >> testVectorSystem [ +PMRungeKuttaSolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/RungeKuttaStepperTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st similarity index 87% rename from src/Math-Tests-ODE/RungeKuttaStepperTest.class.st rename to src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st index 84eb1dec8..3537c6d31 100644 --- a/src/Math-Tests-ODE/RungeKuttaStepperTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st @@ -1,11 +1,11 @@ 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. @@ -20,7 +20,7 @@ RungeKuttaStepperTest >> testDoStepTimeStepSize1 [ ] { #category : #'tests-stepping' } -RungeKuttaStepperTest >> testDoStepTimeStepSize2 [ +PMRungeKuttaStepperTest >> testDoStepTimeStepSize2 [ | stepper sys dt | sys := ExplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. @@ -33,12 +33,12 @@ RungeKuttaStepperTest >> testDoStepTimeStepSize2 [ ] { #category : #'tests-stepping' } -RungeKuttaStepperTest >> testOrderIsFour [ +PMRungeKuttaStepperTest >> testOrderIsFour [ self assert: RungeKuttaStepper order equals: 4 ] { #category : #'tests-stepping' } -RungeKuttaStepperTest >> testSimpleSystem [ +PMRungeKuttaStepperTest >> testSimpleSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem block: [ :x :t | t sin ]. @@ -57,7 +57,7 @@ RungeKuttaStepperTest >> testSimpleSystem [ ] { #category : #'tests-stepping' } -RungeKuttaStepperTest >> testSimpleSystem2 [ +PMRungeKuttaStepperTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.5. system := ExplicitSystem @@ -84,7 +84,7 @@ RungeKuttaStepperTest >> testSimpleSystem2 [ ] { #category : #'tests-stepping' } -RungeKuttaStepperTest >> testVectorSystem [ +PMRungeKuttaStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ExplicitSystem diff --git a/src/Math-Tests-ODE/StepperTest.class.st b/src/Math-Tests-ODE/PMStepperTest.class.st similarity index 71% rename from src/Math-Tests-ODE/StepperTest.class.st rename to src/Math-Tests-ODE/PMStepperTest.class.st index fd26770e6..8126c1ae8 100644 --- a/src/Math-Tests-ODE/StepperTest.class.st +++ b/src/Math-Tests-ODE/PMStepperTest.class.st @@ -2,23 +2,23 @@ A StepperTest is a test class for testing the behavior of Stepper " Class { - #name : #StepperTest, + #name : #PMStepperTest, #superclass : #TestCase, - #category : 'Math-Tests-ODE' + #category : #'Math-Tests-ODE' } { #category : #tests } -StepperTest >> testOrderIsNilForBaseClass [ +PMStepperTest >> testOrderIsNilForBaseClass [ self assert: Stepper order isNil ] { #category : #tests } -StepperTest >> testOrderIsNilForInstanceOfBaseClass [ +PMStepperTest >> testOrderIsNilForInstanceOfBaseClass [ self assert: Stepper new order isNil ] { #category : #tests } -StepperTest >> testSystem [ +PMStepperTest >> testSystem [ | stepper sys | sys := ExplicitSystem new. sys block: [ :x :t | t ]. diff --git a/src/Math-Tests-ODE/TrapezoidSolverTest.class.st b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st similarity index 90% rename from src/Math-Tests-ODE/TrapezoidSolverTest.class.st rename to src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st index c4ecc7b88..47673f908 100644 --- a/src/Math-Tests-ODE/TrapezoidSolverTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st @@ -1,11 +1,11 @@ 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)]. @@ -17,7 +17,7 @@ TrapezoidSolverTest >> testSimpleSystem2 [ ] { #category : #'tests-solving' } -TrapezoidSolverTest >> testSimpleSystem3 [ +PMTrapezoidSolverTest >> testSimpleSystem3 [ | solver stepper system dt | dt := 0.5. system := ImplicitSystem block: [ :x :t | 2 * t * x ]. @@ -57,7 +57,7 @@ TrapezoidSolverTest >> testSimpleSystem3 [ ] { #category : #'tests-solving' } -TrapezoidSolverTest >> testVectorSystem [ +PMTrapezoidSolverTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem diff --git a/src/Math-Tests-ODE/TrapezoidStepperTest.class.st b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st similarity index 87% rename from src/Math-Tests-ODE/TrapezoidStepperTest.class.st rename to src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st index 80e703266..3bee704ad 100644 --- a/src/Math-Tests-ODE/TrapezoidStepperTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st @@ -1,11 +1,11 @@ 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 | @@ -25,7 +25,7 @@ TrapezoidStepperTest >> testDoStepTime [ ] { #category : #'tests-stepping' } -TrapezoidStepperTest >> testDoStepTimeStepSize1 [ +PMTrapezoidStepperTest >> testDoStepTimeStepSize1 [ | stepper sys dt | sys := ImplicitSystem block: [ :x :t | x * t ]. stepper := TrapezoidStepper onSystem: sys. @@ -40,7 +40,7 @@ TrapezoidStepperTest >> testDoStepTimeStepSize1 [ ] { #category : #'tests-stepping' } -TrapezoidStepperTest >> testDoStepTimeStepSize2 [ +PMTrapezoidStepperTest >> testDoStepTimeStepSize2 [ | stepper sys dt | sys := ImplicitSystem block: [ :x :t | 3 * t negated exp - (0.4 * x) ]. @@ -53,12 +53,12 @@ TrapezoidStepperTest >> testDoStepTimeStepSize2 [ ] { #category : #'tests-stepping' } -TrapezoidStepperTest >> testOrderIsTwo [ +PMTrapezoidStepperTest >> testOrderIsTwo [ self assert: TrapezoidStepper order equals: 2 ] { #category : #'tests-stepping' } -TrapezoidStepperTest >> testVectorSystem [ +PMTrapezoidStepperTest >> testVectorSystem [ | solver stepper system dt | dt := 0.01. system := ImplicitSystem From 3c3438c972d901e3a4415f1cc1e59888e44c0989 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:30:00 +0100 Subject: [PATCH 040/161] Add PM prefix for Math-Tests-Random classes #16 --- ...ss.st => PMBernoulliGeneratorTest.class.st} | 14 +++++++------- ...ass.st => PMBinomialGeneratorTest.class.st} | 10 +++++----- ...ass.st => PMConstantGeneratorTest.class.st} | 6 +++--- ....st => PMExponentialGeneratorTest.class.st} | 10 +++++----- ...ass.st => PMGaussianGeneratorTest.class.st} | 8 ++++---- ...st.class.st => PMLehmerRandomTest.class.st} | 10 +++++----- ...=> PMLinearCongruentialRandomTest.class.st} | 10 +++++----- ...st => PMMersenneTwisterRandomTest.class.st} | 10 +++++----- ...class.st => PMNumberGeneratorTest.class.st} | 6 +++--- ...lass.st => PMPoissonGeneratorTest.class.st} | 12 ++++++------ ...class.st => PMRandomGeneratorTest.class.st} | 18 +++++++++--------- 11 files changed, 57 insertions(+), 57 deletions(-) rename src/Math-Tests-Random/{BernoulliGeneratorTest.class.st => PMBernoulliGeneratorTest.class.st} (74%) rename src/Math-Tests-Random/{BinomialGeneratorTest.class.st => PMBinomialGeneratorTest.class.st} (80%) rename src/Math-Tests-Random/{ConstantGeneratorTest.class.st => PMConstantGeneratorTest.class.st} (70%) rename src/Math-Tests-Random/{ExponentialGeneratorTest.class.st => PMExponentialGeneratorTest.class.st} (79%) rename src/Math-Tests-Random/{GaussianGeneratorTest.class.st => PMGaussianGeneratorTest.class.st} (79%) rename src/Math-Tests-Random/{LehmerRandomTest.class.st => PMLehmerRandomTest.class.st} (63%) rename src/Math-Tests-Random/{LinearCongruentialRandomTest.class.st => PMLinearCongruentialRandomTest.class.st} (61%) rename src/Math-Tests-Random/{MersenneTwisterRandomTest.class.st => PMMersenneTwisterRandomTest.class.st} (77%) rename src/Math-Tests-Random/{NumberGeneratorTest.class.st => PMNumberGeneratorTest.class.st} (77%) rename src/Math-Tests-Random/{PoissonGeneratorTest.class.st => PMPoissonGeneratorTest.class.st} (78%) rename src/Math-Tests-Random/{RandomGeneratorTest.class.st => PMRandomGeneratorTest.class.st} (72%) diff --git a/src/Math-Tests-Random/BernoulliGeneratorTest.class.st b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st similarity index 74% rename from src/Math-Tests-Random/BernoulliGeneratorTest.class.st rename to src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st index 57e0c9022..2ff085cdb 100644 --- a/src/Math-Tests-Random/BernoulliGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st @@ -2,13 +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 [ +PMBernoulliGeneratorTest >> testGenerator [ | g bern | g := PMLinearCongruentialRandomGenerator new. bern := PMBernoulliGenerator new. @@ -19,7 +19,7 @@ BernoulliGeneratorTest >> testGenerator [ ] { #category : #tests } -BernoulliGeneratorTest >> testNextYieldsOneOrZero [ +PMBernoulliGeneratorTest >> testNextYieldsOneOrZero [ | gen | gen := PMBernoulliGenerator fair. self should: [ | x | x := gen next. @@ -27,14 +27,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 +45,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/BinomialGeneratorTest.class.st b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st similarity index 80% rename from src/Math-Tests-Random/BinomialGeneratorTest.class.st rename to src/Math-Tests-Random/PMBinomialGeneratorTest.class.st index 102bf5a24..5c8791ce5 100644 --- a/src/Math-Tests-Random/BinomialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #BinomialGeneratorTest, + #name : #PMBinomialGeneratorTest, #superclass : #TestCase, - #category : 'Math-Tests-Random' + #category : #'Math-Tests-Random' } { #category : #tests } -BinomialGeneratorTest >> testBinomialGeneratorConvergesToMean [ +PMBinomialGeneratorTest >> 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 | @@ -20,7 +20,7 @@ BinomialGeneratorTest >> testBinomialGeneratorConvergesToMean [ ] { #category : #tests } -BinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [ +PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [ | g numberOfTrials | g := PMBinomialGenerator new. numberOfTrials := 10. @@ -36,7 +36,7 @@ BinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysR ] { #category : #tests } -BinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwaysReturnZero [ +PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwaysReturnZero [ | g numberOfTrials | g := PMBinomialGenerator new. numberOfTrials := 10. 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/ExponentialGeneratorTest.class.st b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st similarity index 79% rename from src/Math-Tests-Random/ExponentialGeneratorTest.class.st rename to src/Math-Tests-Random/PMExponentialGeneratorTest.class.st index df38b5038..3cb2101ac 100644 --- a/src/Math-Tests-Random/ExponentialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st @@ -2,13 +2,13 @@ An ExponentialGeneratorTest is a test class for testing the behavior of ExponentialGenerator " Class { - #name : #ExponentialGeneratorTest, + #name : #PMExponentialGeneratorTest, #superclass : #TestCase, - #category : 'Math-Tests-Random' + #category : #'Math-Tests-Random' } { #category : #tests } -ExponentialGeneratorTest >> testGenerator [ +PMExponentialGeneratorTest >> testGenerator [ | eg | eg := PMExponentialGenerator new. self @@ -20,7 +20,7 @@ ExponentialGeneratorTest >> testGenerator [ ] { #category : #tests } -ExponentialGeneratorTest >> testPeekAlwaysAnswersTheSame [ +PMExponentialGeneratorTest >> testPeekAlwaysAnswersTheSame [ | eg | eg := PMExponentialGenerator new. self assert: eg peek equals: eg peek. @@ -28,7 +28,7 @@ ExponentialGeneratorTest >> testPeekAlwaysAnswersTheSame [ ] { #category : #tests } -ExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [ +PMExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [ "testing a random sample seems suspect. We use a 5% interval here" | eg arr | diff --git a/src/Math-Tests-Random/GaussianGeneratorTest.class.st b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st similarity index 79% rename from src/Math-Tests-Random/GaussianGeneratorTest.class.st rename to src/Math-Tests-Random/PMGaussianGeneratorTest.class.st index c77ea98bd..8b1c7613e 100644 --- a/src/Math-Tests-Random/GaussianGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #GaussianGeneratorTest, + #name : #PMGaussianGeneratorTest, #superclass : #TestCase, - #category : 'Math-Tests-Random' + #category : #'Math-Tests-Random' } { #category : #utils } -GaussianGeneratorTest >> checkDistributionOf: aGenerator withExpectedMeans: e andExpectedStandardDeviation: sd [ +PMGaussianGeneratorTest >> checkDistributionOf: aGenerator withExpectedMeans: e andExpectedStandardDeviation: sd [ "fixme: this test ignores the standard deviation and occasionally fails" | data m | data := Set new. @@ -16,7 +16,7 @@ GaussianGeneratorTest >> checkDistributionOf: aGenerator withExpectedMeans: e an ] { #category : #tests } -GaussianGeneratorTest >> testDistribution [ +PMGaussianGeneratorTest >> testDistribution [ | mean standardDeviation g | mean := 147. standardDeviation := 17. diff --git a/src/Math-Tests-Random/LehmerRandomTest.class.st b/src/Math-Tests-Random/PMLehmerRandomTest.class.st similarity index 63% rename from src/Math-Tests-Random/LehmerRandomTest.class.st rename to src/Math-Tests-Random/PMLehmerRandomTest.class.st index 5c10502b0..21f3ce4a4 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,14 +14,14 @@ LehmerRandomTest >> testNextBetweenZeroAndOne [ ] { #category : #tests } -LehmerRandomTest >> testPeekAlwaysReplyTheSameValue [ +PMLehmerRandomTest >> testPeekAlwaysReplyTheSameValue [ | g | g := PMLehmerRandomGenerator new. self assert: g peek equals: g peek ] { #category : #tests } -LehmerRandomTest >> testPeekAnswersSameAsNext [ +PMLehmerRandomTest >> testPeekAnswersSameAsNext [ | g | g := PMLehmerRandomGenerator new. self assert: g peek equals: g next diff --git a/src/Math-Tests-Random/LinearCongruentialRandomTest.class.st b/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st similarity index 61% rename from src/Math-Tests-Random/LinearCongruentialRandomTest.class.st rename to src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st index b7eae90de..d1dafadb4 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,14 +14,14 @@ LinearCongruentialRandomTest >> testNextBetweenZeroAndOne [ ] { #category : #tests } -LinearCongruentialRandomTest >> testPeekAlwaysReplyTheSameValue [ +PMLinearCongruentialRandomTest >> testPeekAlwaysReplyTheSameValue [ | g | g := PMLinearCongruentialRandomGenerator new. self assert: g peek equals: g peek ] { #category : #tests } -LinearCongruentialRandomTest >> testPeekAnswersSameAsNext [ +PMLinearCongruentialRandomTest >> testPeekAnswersSameAsNext [ | g | g := PMLinearCongruentialRandomGenerator new. self assert: g peek equals: g next 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..cd37c918c 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 >> testPeekAnswersSame [ "every subclass should implement some basic behavior." PMNumberGenerator subclasses diff --git a/src/Math-Tests-Random/PoissonGeneratorTest.class.st b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st similarity index 78% rename from src/Math-Tests-Random/PoissonGeneratorTest.class.st rename to src/Math-Tests-Random/PMPoissonGeneratorTest.class.st index f3239de18..d324cbc6d 100644 --- a/src/Math-Tests-Random/PoissonGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #PoissonGeneratorTest, + #name : #PMPoissonGeneratorTest, #superclass : #TestCase, - #category : 'Math-Tests-Random' + #category : #'Math-Tests-Random' } { #category : #tests } -PoissonGeneratorTest >> testPeekReturnsSameAsNext [ +PMPoissonGeneratorTest >> testPeekReturnsSameAsNext [ | poisson random | poisson := PMPoissonGenerator lambda: 0.1. random := poisson peek. @@ -13,7 +13,7 @@ PoissonGeneratorTest >> testPeekReturnsSameAsNext [ ] { #category : #tests } -PoissonGeneratorTest >> testPeekReturnsSameTwice [ +PMPoissonGeneratorTest >> testPeekReturnsSameTwice [ | poisson random | poisson := PMPoissonGenerator lambda: 0.1. random := poisson peek. @@ -21,7 +21,7 @@ PoissonGeneratorTest >> testPeekReturnsSameTwice [ ] { #category : #tests } -PoissonGeneratorTest >> testPeekWorksAfterSampling [ +PMPoissonGeneratorTest >> testPeekWorksAfterSampling [ | poisson random | poisson := PMPoissonGenerator lambda: 0.1. (1 to: 100) do: [ :ea | poisson next ]. @@ -31,7 +31,7 @@ PoissonGeneratorTest >> testPeekWorksAfterSampling [ ] { #category : #tests } -PoissonGeneratorTest >> testSampleAverageConvergesToLambda [ +PMPoissonGeneratorTest >> testSampleAverageConvergesToLambda [ "law of large numbers" "made non-random, old random version in comments" diff --git a/src/Math-Tests-Random/RandomGeneratorTest.class.st b/src/Math-Tests-Random/PMRandomGeneratorTest.class.st similarity index 72% rename from src/Math-Tests-Random/RandomGeneratorTest.class.st rename to src/Math-Tests-Random/PMRandomGeneratorTest.class.st index e2f45531f..41f41c575 100644 --- a/src/Math-Tests-Random/RandomGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMRandomGeneratorTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #RandomGeneratorTest, + #name : #PMRandomGeneratorTest, #superclass : #TestCase, - #category : 'Math-Tests-Random' + #category : #'Math-Tests-Random' } { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [ +PMRandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [ PMRandomGenerator subclasses do: [:cls | | gen value | gen := cls new. @@ -13,7 +13,7 @@ RandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [ ] { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamIsReadOnly [ +PMRandomGeneratorTest >> testGeneratorStreamIsReadOnly [ PMRandomGenerator subclasses do: [ :cls | | gen | @@ -23,7 +23,7 @@ RandomGeneratorTest >> testGeneratorStreamIsReadOnly [ ] { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamNeverEnds [ +PMRandomGeneratorTest >> testGeneratorStreamNeverEnds [ PMRandomGenerator subclasses do: [:cls | | gen | gen := cls new. @@ -31,7 +31,7 @@ RandomGeneratorTest >> testGeneratorStreamNeverEnds [ ] { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamPeekIsNext [ +PMRandomGeneratorTest >> testGeneratorStreamPeekIsNext [ PMRandomGenerator subclasses do: [ :cls | | gen value | @@ -42,7 +42,7 @@ RandomGeneratorTest >> testGeneratorStreamPeekIsNext [ ] { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamProducesNumbers [ +PMRandomGeneratorTest >> testGeneratorStreamProducesNumbers [ PMRandomGenerator subclasses do: [ :cls | | gen | @@ -52,7 +52,7 @@ RandomGeneratorTest >> testGeneratorStreamProducesNumbers [ ] { #category : #tests } -RandomGeneratorTest >> testGeneratorStreamProducesRandomNumbers [ +PMRandomGeneratorTest >> testGeneratorStreamProducesRandomNumbers [ PMRandomGenerator subclasses do: [:cls | | gen value | gen := cls new. @@ -61,7 +61,7 @@ RandomGeneratorTest >> testGeneratorStreamProducesRandomNumbers [ ] { #category : #tests } -RandomGeneratorTest >> testNextGivesArrayOfNumbers [ +PMRandomGeneratorTest >> testNextGivesArrayOfNumbers [ PMRandomGenerator subclasses do: [ :cls | | gen samples | From 93b194fb6774fefebbe02fca29c29502f2c23186 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:33:40 +0100 Subject: [PATCH 041/161] Add PM prefix for Math-Tests-KolmogorovSmirnov classes #16 --- ...=> PMKolmogorovSmirnov1sampleTest.class.st} | 18 +++++++++--------- ...=> PMKolmogorovSmirnov2sampleTest.class.st} | 14 +++++++------- ... => PMKolmogorovsDistributionTest.class.st} | 10 +++++----- 3 files changed, 21 insertions(+), 21 deletions(-) rename src/Math-Tests-KolmogorovSmirnov/{KolmogorovSmirnov1sampleTest.class.st => PMKolmogorovSmirnov1sampleTest.class.st} (75%) rename src/Math-Tests-KolmogorovSmirnov/{KolmogorovSmirnov2sampleTest.class.st => PMKolmogorovSmirnov2sampleTest.class.st} (84%) rename src/Math-Tests-KolmogorovSmirnov/{KolmogorovsDistributionTest.class.st => PMKolmogorovsDistributionTest.class.st} (89%) diff --git a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st similarity index 75% rename from src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st index 8b39780c2..eea342466 100644 --- a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov1sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st @@ -1,21 +1,21 @@ Class { - #name : #KolmogorovSmirnov1sampleTest, + #name : #PMKolmogorovSmirnov1sampleTest, #superclass : #TestCase, #instVars : [ 'nd', 'ks' ], - #category : 'Math-Tests-KolmogorovSmirnov' + #category : #'Math-Tests-KolmogorovSmirnov' } { #category : #initialization } -KolmogorovSmirnov1sampleTest >> initialize [ +PMKolmogorovSmirnov1sampleTest >> initialize [ nd := PMNormalDistribution new. ks := PMKolmogorovSmirnov1Sample new ] { #category : #running } -KolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [ +PMKolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [ | n | ks populationDistribution: aDistribution. n := 0. @@ -27,7 +27,7 @@ KolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [ ] { #category : #tests } -KolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [ +PMKolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" | d | @@ -36,7 +36,7 @@ KolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [ ] { #category : #tests } -KolmogorovSmirnov1sampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [ +PMKolmogorovSmirnov1sampleTest >> 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))" @@ -44,7 +44,7 @@ KolmogorovSmirnov1sampleTest >> testRejectOfEqualityHypothesesForSampleVersusDis ] { #category : #tests } -KolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [ +PMKolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen not too often" | d | @@ -53,7 +53,7 @@ KolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [ ] { #category : #tests } -KolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [ +PMKolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" | d | @@ -66,7 +66,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 84% rename from src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov2sampleTest.class.st rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st index 460c30d57..006ecf4ab 100644 --- a/src/Math-Tests-KolmogorovSmirnov/KolmogorovSmirnov2sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st @@ -1,19 +1,19 @@ Class { - #name : #KolmogorovSmirnov2sampleTest, + #name : #PMKolmogorovSmirnov2sampleTest, #superclass : #TestCase, #instVars : [ 'k' ], - #category : 'Math-Tests-KolmogorovSmirnov' + #category : #'Math-Tests-KolmogorovSmirnov' } { #category : #initialization } -KolmogorovSmirnov2sampleTest >> initialize [ +PMKolmogorovSmirnov2sampleTest >> initialize [ k := PMKolmogorovSmirnov2Sample new ] { #category : #tests } -KolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ +PMKolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ | nd ks | nd := PMNormalDistribution new. ks := PMKolmogorovSmirnov2Sample compareData: ((1 to: 100) collect: [ :i | nd random ]) withData: ((1 to: 100) collect: [ :i | nd random ]). "--> @@ -24,7 +24,7 @@ KolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ ] { #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 @@ -47,7 +47,7 @@ in Selected Tables in Mathematical Statistics Volume I (1973)" ] { #category : #tests } -KolmogorovSmirnov2sampleTest >> testSmallSample [ +PMKolmogorovSmirnov2sampleTest >> testSmallSample [ "sample from http://www.math.montana.edu/~jobo/st431/ho2b.pdf" | d1 d2 | @@ -62,7 +62,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). From dcf8b6a3edf61c86ba17b72ff86b6e7978276765 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:38:45 +0100 Subject: [PATCH 042/161] Fix #16 for Math-Tests-KDTree --- ...reeTest.class.st => PMKDTreeTest.class.st} | 36 +++++++++---------- ...reTest.class.st => PMNNStoreTest.class.st} | 28 +++++++-------- 2 files changed, 32 insertions(+), 32 deletions(-) rename src/Math-Tests-KDTree/{KDTreeTest.class.st => PMKDTreeTest.class.st} (89%) rename src/Math-Tests-KDTree/{NNStoreTest.class.st => PMNNStoreTest.class.st} (91%) diff --git a/src/Math-Tests-KDTree/KDTreeTest.class.st b/src/Math-Tests-KDTree/PMKDTreeTest.class.st similarity index 89% rename from src/Math-Tests-KDTree/KDTreeTest.class.st rename to src/Math-Tests-KDTree/PMKDTreeTest.class.st index 2088e8d8b..935ae35d0 100644 --- a/src/Math-Tests-KDTree/KDTreeTest.class.st +++ b/src/Math-Tests-KDTree/PMKDTreeTest.class.st @@ -2,36 +2,36 @@ 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 [ +PMKDTreeTest >> setUp [ rand := Random new ] { #category : #tests } -KDTreeTest >> testBenchmark [ +PMKDTreeTest >> testBenchmark [ | aStream s | (RPackage organizer includesPackageNamed: 'Math-Benchmarks-KDTree') ifFalse: [ ^ self skip ]. @@ -46,7 +46,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 +57,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 +69,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 +78,7 @@ KDTreeTest >> testIndexedKDTreeExtremeCase [ ] { #category : #tests } -KDTreeTest >> testIndexedKDTreeSimple [ +PMKDTreeTest >> testIndexedKDTreeSimple [ | r n aTree bTree | r := rand next: 200. aTree := PMIndexedKDTree @@ -98,7 +98,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 +110,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 +121,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 +131,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 +141,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 +155,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 +183,7 @@ KDTreeTest >> testPMVectorCompatibility [ ] { #category : #tests } -KDTreeTest >> testPrintOn [ +PMKDTreeTest >> testPrintOn [ | aStream s | aStream := ReadWriteStream with: ''. (PMKDTree withAll: #(#(1) #(4))) printOn: aStream. @@ -195,7 +195,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)). From ed195aa37cb57e7e06153365143907d6e19dc4a7 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:40:49 +0100 Subject: [PATCH 043/161] #16 for Math-Tests-FastFourierTransform --- .../{TestFFT.class.st => PMFFTTest.class.st} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/Math-Tests-FastFourierTransform/{TestFFT.class.st => PMFFTTest.class.st} (93%) 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 ]. From c64daaa5cb52e26026c95dd82e6ecbff34a51714 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:41:56 +0100 Subject: [PATCH 044/161] Continue to work on #16 --- ...> PMAnotherChromosomeManagerTest.class.st} | 30 +++++++++---------- ...=> PMAnotherGeneticOptimizerTest.class.st} | 30 +++++++++---------- ...est.class.st => PMDataHolderTest.class.st} | 6 ++-- ...> PMErrorAsParameterFunctionTest.class.st} | 14 ++++----- ...class.st => PMErrorMinimizerTest.class.st} | 6 ++-- ...> PMErrorOfParameterFunctionTest.class.st} | 24 +++++++-------- ...st.class.st => PMFunctionFitTest.class.st} | 10 +++---- ...s.st => PMGeneralFunctionFitTest.class.st} | 26 ++++++++-------- ...=> PMSimpleParameterFunctionTest.class.st} | 14 ++++----- 9 files changed, 80 insertions(+), 80 deletions(-) rename src/Math-Tests-FunctionFit/{AnotherChromosomeManagerTest.class.st => PMAnotherChromosomeManagerTest.class.st} (89%) rename src/Math-Tests-FunctionFit/{AnotherGeneticOptimizerTest.class.st => PMAnotherGeneticOptimizerTest.class.st} (83%) rename src/Math-Tests-FunctionFit/{DataHolderTest.class.st => PMDataHolderTest.class.st} (67%) rename src/Math-Tests-FunctionFit/{ErrorAsParameterFunctionTest.class.st => PMErrorAsParameterFunctionTest.class.st} (73%) rename src/Math-Tests-FunctionFit/{ErrorMinimizerTest.class.st => PMErrorMinimizerTest.class.st} (80%) rename src/Math-Tests-FunctionFit/{ErrorOfParameterFunctionTest.class.st => PMErrorOfParameterFunctionTest.class.st} (83%) rename src/Math-Tests-FunctionFit/{FunctionFitTest.class.st => PMFunctionFitTest.class.st} (84%) rename src/Math-Tests-FunctionFit/{GeneralFunctionFitTest.class.st => PMGeneralFunctionFitTest.class.st} (87%) rename src/Math-Tests-FunctionFit/{SimpleParameterFunctionTest.class.st => PMSimpleParameterFunctionTest.class.st} (78%) 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/ErrorMinimizerTest.class.st b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st similarity index 80% rename from src/Math-Tests-FunctionFit/ErrorMinimizerTest.class.st rename to src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st index 998d925f3..12c8b812b 100644 --- a/src/Math-Tests-FunctionFit/ErrorMinimizerTest.class.st +++ b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st @@ -2,13 +2,13 @@ ErrorMinimizerTest tests indirectly also ErrorAsParameterFunction. " Class { - #name : #ErrorMinimizerTest, + #name : #PMErrorMinimizerTest, #superclass : #TestCase, - #category : 'Math-Tests-FunctionFit' + #category : #'Math-Tests-FunctionFit' } { #category : #tests } -ErrorMinimizerTest >> testErrorMinimzer [ +PMErrorMinimizerTest >> 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) ]. 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. From c0f892cafbe42f052a52bedc69d7a9330a38cfa5 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Sat, 10 Nov 2018 18:48:31 +0100 Subject: [PATCH 045/161] More on #16 --- ...est.class.st => PMDualNumberTest.class.st} | 64 +++++++++---------- ...s.st => PMGradientAndHessianTest.class.st} | 8 +-- ...lass.st => PMHyperDualNumberTest.class.st} | 64 +++++++++---------- 3 files changed, 68 insertions(+), 68 deletions(-) rename src/Math-Tests-AutomaticDifferenciation/{DualNumberTest.class.st => PMDualNumberTest.class.st} (89%) rename src/Math-Tests-AutomaticDifferenciation/{GradientAndHessianTest.class.st => PMGradientAndHessianTest.class.st} (85%) rename src/Math-Tests-AutomaticDifferenciation/{HyperDualNumberTest.class.st => PMHyperDualNumberTest.class.st} (89%) diff --git a/src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st similarity index 89% rename from src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st rename to src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st index e2dc75af6..29f213b28 100644 --- a/src/Math-Tests-AutomaticDifferenciation/DualNumberTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st @@ -1,5 +1,5 @@ Class { - #name : #DualNumberTest, + #name : #PMDualNumberTest, #superclass : #TestCase, #instVars : [ 'zero', @@ -8,17 +8,17 @@ Class { 'zeroc', 'onec' ], - #category : 'Math-Tests-AutomaticDifferenciation' + #category : #'Math-Tests-AutomaticDifferenciation' } { #category : #running } -DualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ +PMDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ self assert: aDualNumber equals: anotherDualNumber. self assert: aDualNumber eps equals: anotherDualNumber eps ] { #category : #running } -DualNumberTest >> setUp [ +PMDualNumberTest >> setUp [ zero:=PMDualNumber value: 0 eps: 1. zeroc:=PMDualNumber value: 0 eps: 0. one:=PMDualNumber value: 1 eps: 1. @@ -28,13 +28,13 @@ three :=PMDualNumber value: 3.0 eps: 1. ] { #category : #'tests-arithmetic' } -DualNumberTest >> testAbs [ +PMDualNumberTest >> testAbs [ self assertEquality: three negated abs and:three . ] { #category : #tests } -DualNumberTest >> testAccessing [ +PMDualNumberTest >> testAccessing [ self assert: three eps equals: 1. self assert: three value equals: 3. three value: 2. @@ -44,14 +44,14 @@ DualNumberTest >> testAccessing [ ] { #category : #'tests-arithmetic' } -DualNumberTest >> testAdd [ +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' } -DualNumberTest >> testArcCos [ +PMDualNumberTest >> testArcCos [ |a| self assert: (zero arcCos equalsTo:( PMDualNumber value: Float halfPi eps: -1)). a:=(PMDualNumber value: -1.0 successor eps: 1)arcCos. @@ -60,7 +60,7 @@ self assert:(a eps< -1e6). ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testArcSin [ +PMDualNumberTest >> testArcSin [ | a | self assert: zero arcSin equals: zero. a := (PMDualNumber value: 1.0 predecessor eps: 1) arcSin. @@ -72,14 +72,14 @@ DualNumberTest >> testArcSin [ ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testArcTan [ +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 : #tests } -DualNumberTest >> testConverting [ +PMDualNumberTest >> testConverting [ | a | self assert: zeroc asInteger == 0. self assert: three asInteger == 3. @@ -93,14 +93,14 @@ DualNumberTest >> testConverting [ ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testCos [ +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' } -DualNumberTest >> testDivide [ +PMDualNumberTest >> testDivide [ self should: [ 4.0/(one-1) ] raise:ZeroDivide. self should: [ three/(onec-1) ] raise:ZeroDivide. self assertEquality: three/onec and: three. @@ -112,7 +112,7 @@ self assertEquality: 1/three and: (PMDualNumber value: (1/3)asFloat eps: (-1/9)a ] { #category : #'tests-testing' } -DualNumberTest >> testEqual [ +PMDualNumberTest >> testEqual [ self assert: one equals: onec. self assert: zero equals: zeroc. self assert: one equals: 1.0. @@ -124,7 +124,7 @@ DualNumberTest >> testEqual [ ] { #category : #tests } -DualNumberTest >> testEqualsTo [ +PMDualNumberTest >> testEqualsTo [ self assert: (zeroc equalsTo: zeroc). self deny: (zeroc equalsTo: zero). self assert: (zero equalsTo: zero). @@ -136,7 +136,7 @@ self deny: (one equalsTo: (PMDualNumber value: 1.0000001 eps:1.0000001) ). ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testExp [ +PMDualNumberTest >> testExp [ | a b | b := 3 exp. a := three exp. @@ -146,7 +146,7 @@ DualNumberTest >> testExp [ ] { #category : #tests } -DualNumberTest >> testHash [ +PMDualNumberTest >> testHash [ self assert: one hash equals: onec hash. self assert: zero hash equals: zeroc hash. self assert: one hash equals: 1 hash. @@ -160,7 +160,7 @@ DualNumberTest >> testHash [ ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testLn [ +PMDualNumberTest >> testLn [ | a | a := three ln. self assert: (a eps equalsTo: 1 / 3). @@ -169,7 +169,7 @@ DualNumberTest >> testLn [ ] { #category : #'tests-arithmetic' } -DualNumberTest >> testMultiply [ +PMDualNumberTest >> testMultiply [ self assertEquality: 0*onec and: zeroc . self assertEquality: three*0 and: zeroc. self assertEquality: onec*three and: three . @@ -178,13 +178,13 @@ self assertEquality: (three+2.0)*(1+one) and: (PMDualNumber value: 10.0 eps: 7.0 ] { #category : #'tests-arithmetic' } -DualNumberTest >> testNegated [ +PMDualNumberTest >> testNegated [ self assert: three negated equals: -3. self assert: three negated eps equals: -1 ] { #category : #'tests-testing' } -DualNumberTest >> testOpposites [ +PMDualNumberTest >> testOpposites [ self assert: zeroc even. self deny: one even. self deny: zero odd. @@ -202,7 +202,7 @@ self assert: onec negated negative. ] { #category : #tests } -DualNumberTest >> testPrintOn [ +PMDualNumberTest >> testPrintOn [ |stream| stream := ReadWriteStream on: ''. three printOn: stream. @@ -211,7 +211,7 @@ self assert: (stream contents includesSubstring:' 1') . ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testRaisedTo [ +PMDualNumberTest >> testRaisedTo [ |a | self assertEquality: (three raisedTo: 2) and: three squared. self assertEquality: (three raisedTo: 0) and: onec. @@ -232,7 +232,7 @@ self assert: (a eps equalsTo: (3 raisedTo: 3)*(3 ln +1)). ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testRaisedToInteger [ +PMDualNumberTest >> testRaisedToInteger [ self assertEquality: (three raisedToInteger: 2) and: three squared. self assertEquality: (three raisedToInteger: 1)and: three. self assertEquality: (three raisedToInteger: 0)and: onec. @@ -241,7 +241,7 @@ self assertEquality: (zero raisedToInteger: 4)and:zeroc. ] { #category : #'tests-arithmetic' } -DualNumberTest >> testReciprocal [ +PMDualNumberTest >> testReciprocal [ self should: [ zero reciprocal ] raise:ZeroDivide. self should: [ zeroc reciprocal ] raise:ZeroDivide. self assertEquality: one reciprocal and: (PMDualNumber value: 1 eps: -1). @@ -250,14 +250,14 @@ self assertEquality: three reciprocal and: (PMDualNumber value: (1/3.0) eps: -1 ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testSin [ +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' } -DualNumberTest >> testSmaller [ +PMDualNumberTest >> testSmaller [ self assert: one<1.1. self deny: one<0. self assert: 1>zeroc. @@ -279,7 +279,7 @@ self deny: three> testSqrt [ +PMDualNumberTest >> testSqrt [ | a | self assertEquality: (PMDualNumber value: 16 eps: 5) sqrt @@ -290,20 +290,20 @@ DualNumberTest >> testSqrt [ ] { #category : #'tests-mathematical functions' } -DualNumberTest >> testSquared [ +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' } -DualNumberTest >> testSubtract [ +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' } -DualNumberTest >> testTan [ +PMDualNumberTest >> testTan [ | a b | a := three tan. self assert: a value equals: 3 tan. @@ -315,7 +315,7 @@ DualNumberTest >> testTan [ ] { #category : #'tests-testing' } -DualNumberTest >> testTesting [ +PMDualNumberTest >> testTesting [ self deny: 3 isDualNumber . self assert: one isDualNumber. self assert: zeroc isDualNumber. diff --git a/src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st similarity index 85% rename from src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st rename to src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st index d8b176078..52f3c6021 100644 --- a/src/Math-Tests-AutomaticDifferenciation/GradientAndHessianTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st @@ -1,11 +1,11 @@ Class { - #name : #GradientAndHessianTest, + #name : #PMGradientAndHessianTest, #superclass : #TestCase, - #category : 'Math-Tests-AutomaticDifferenciation' + #category : #'Math-Tests-AutomaticDifferenciation' } { #category : #tests } -GradientAndHessianTest >> test [ +PMGradientAndHessianTest >> test [ | f g h r | f := [ :i | | x y | @@ -31,7 +31,7 @@ GradientAndHessianTest >> test [ ] { #category : #tests } -GradientAndHessianTest >> test2 [ +PMGradientAndHessianTest >> test2 [ |f g h r| f := [:i||x y|x:=i first.y:=i second. (x exp + y exp )ln]. diff --git a/src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st similarity index 89% rename from src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st rename to src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st index 8300477a4..f54bd3d84 100644 --- a/src/Math-Tests-AutomaticDifferenciation/HyperDualNumberTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st @@ -1,5 +1,5 @@ Class { - #name : #HyperDualNumberTest, + #name : #PMHyperDualNumberTest, #superclass : #TestCase, #instVars : [ 'zero', @@ -8,11 +8,11 @@ Class { 'zeroc', 'onec' ], - #category : 'Math-Tests-AutomaticDifferenciation' + #category : #'Math-Tests-AutomaticDifferenciation' } { #category : #running } -HyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ +PMHyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ self assert: aDualNumber equals: anotherDualNumber. self assert: aDualNumber exp equals: anotherDualNumber exp. self assert: aDualNumber eps2 equals: anotherDualNumber eps2. @@ -20,7 +20,7 @@ HyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ ] { #category : #running } -HyperDualNumberTest >> setUp [ +PMHyperDualNumberTest >> 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. @@ -30,13 +30,13 @@ three :=PMHyperDualNumber value: 3 eps: 1 eps2: 1 eps1eps2: 0. ] { #category : #'tests-arithmetic' } -HyperDualNumberTest >> testAbs [ +PMHyperDualNumberTest >> testAbs [ self assertEquality: three negated abs and:three . ] { #category : #tests } -HyperDualNumberTest >> testAccessing [ +PMHyperDualNumberTest >> testAccessing [ self assert: three eps equals: 1. self assert: three value equals: 3. self assert: three eps2 equals: 1. @@ -48,7 +48,7 @@ HyperDualNumberTest >> testAccessing [ ] { #category : #'tests-arithmetic' } -HyperDualNumberTest >> testAdd [ +PMHyperDualNumberTest >> testAdd [ self assertEquality: 0+onec+0 and: onec . self assertEquality: 1+one+onec+0 and: three . three eps1eps2: 2. @@ -56,7 +56,7 @@ self assertEquality: 1+one+one+three+1 and: (PMHyperDualNumber value: 7 eps: 3 e ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testArcCos [ +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: 1eps1eps2:0)arcCos. @@ -68,7 +68,7 @@ self assert:(a eps1eps2< -1e6). ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testArcSin [ +PMHyperDualNumberTest >> testArcSin [ | a | self assert: zero arcSin equals: zero. a := (PMHyperDualNumber @@ -83,7 +83,7 @@ HyperDualNumberTest >> testArcSin [ ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testArcTan [ +PMHyperDualNumberTest >> testArcTan [ self assert: zero arcTan equals: zero. self assertEquality: one negated arcTan @@ -98,7 +98,7 @@ HyperDualNumberTest >> testArcTan [ ] { #category : #tests } -HyperDualNumberTest >> testConverting [ +PMHyperDualNumberTest >> testConverting [ | a | self assert: zeroc asInteger == 0. self assert: three asInteger == 3. @@ -112,14 +112,14 @@ HyperDualNumberTest >> testConverting [ ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testCos [ +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' } -HyperDualNumberTest >> testDivide [ +PMHyperDualNumberTest >> testDivide [ self should: [ 4.0/(one-1) ] raise:ZeroDivide. self should: [ three/(onec-1) ] raise:ZeroDivide. self assertEquality: three/onec and: three. @@ -131,7 +131,7 @@ self assertEquality: 1/three and: (PMHyperDualNumber value: 1/3 eps: -1/9 eps2: ] { #category : #'tests-testing' } -HyperDualNumberTest >> testEqual [ +PMHyperDualNumberTest >> testEqual [ self assert: one equals: onec. self assert: zero equals: zeroc. self assert: one equals: 1.0. @@ -150,7 +150,7 @@ HyperDualNumberTest >> testEqual [ ] { #category : #tests } -HyperDualNumberTest >> testEqualsTo [ +PMHyperDualNumberTest >> testEqualsTo [ self assert: (zeroc equalsTo: zeroc). self deny: (zeroc equalsTo: zero). self assert: (zero equalsTo: zero). @@ -161,7 +161,7 @@ self deny: (one equalsTo: (PMHyperDualNumber value: 1.0000000001 eps: 1.00000000 ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testExp [ +PMHyperDualNumberTest >> testExp [ | a b | b := 3 exp. a := three exp. @@ -173,7 +173,7 @@ HyperDualNumberTest >> testExp [ ] { #category : #tests } -HyperDualNumberTest >> testHash [ +PMHyperDualNumberTest >> testHash [ self assert: one hash equals: onec hash. self assert: zero hash equals: zeroc hash. self assert: one hash equals: 1 hash. @@ -199,7 +199,7 @@ HyperDualNumberTest >> testHash [ ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testLn [ +PMHyperDualNumberTest >> testLn [ | a | a := three ln. self assert: (a eps equalsTo: 1 / 3). @@ -210,7 +210,7 @@ HyperDualNumberTest >> testLn [ ] { #category : #'tests-arithmetic' } -HyperDualNumberTest >> testMultiply [ +PMHyperDualNumberTest >> testMultiply [ self assertEquality: 0*onec and: zeroc . self assertEquality: three*0 and: zeroc. self assertEquality: onec*three and: three . @@ -219,7 +219,7 @@ self assertEquality: (three+2.0)*(1+one) and: ( PMHyperDualNumber value: 10.0 ep ] { #category : #'tests-arithmetic' } -HyperDualNumberTest >> testNegated [ +PMHyperDualNumberTest >> testNegated [ three eps1eps2: -4. self assert: three negated equals: -3. self assert: three negated eps equals: -1. @@ -228,7 +228,7 @@ HyperDualNumberTest >> testNegated [ ] { #category : #'tests-testing' } -HyperDualNumberTest >> testOpposites [ +PMHyperDualNumberTest >> testOpposites [ self assert: zeroc even. self deny: one even. self deny: zero odd. @@ -246,7 +246,7 @@ self assert: onec negated negative. ] { #category : #tests } -HyperDualNumberTest >> testPrintOn [ +PMHyperDualNumberTest >> testPrintOn [ |stream| stream := ReadWriteStream on: ''. three printOn: stream. @@ -256,7 +256,7 @@ self assert: (stream contents includesSubstring:' 0') . ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testRaisedTo [ +PMHyperDualNumberTest >> testRaisedTo [ |a b| self assert: ((three raisedTo: 2) equalsTo: three squared). self assertEquality: (three raisedTo: 0) and: onec. @@ -282,7 +282,7 @@ self assert: (a eps1eps2 equalsTo: b*(3 ln+1)+9). ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testRaisedToInteger [ +PMHyperDualNumberTest >> testRaisedToInteger [ self assertEquality: (three raisedToInteger: 2) and: three squared. self assertEquality: (three raisedToInteger: 1) and: three. self assertEquality: (three raisedToInteger: 0) and: onec. @@ -291,7 +291,7 @@ self assertEquality: (zero raisedToInteger: 4) and: zeroc. ] { #category : #'tests-arithmetic' } -HyperDualNumberTest >> testReciprocal [ +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). @@ -300,14 +300,14 @@ self assertEquality: three reciprocal and: ( PMHyperDualNumber value: (1/3) eps ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testSin [ +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' } -HyperDualNumberTest >> testSmaller [ +PMHyperDualNumberTest >> testSmaller [ self assert: one<1.1. self deny: one<0. self assert: 1>zeroc. @@ -329,7 +329,7 @@ self deny: three> testSqrt [ +PMHyperDualNumberTest >> testSqrt [ | a | self assertEquality: @@ -352,21 +352,21 @@ HyperDualNumberTest >> testSqrt [ ] { #category : #'tests-mathematical functions' } -HyperDualNumberTest >> testSquared [ +PMHyperDualNumberTest >> 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 [ +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' } -HyperDualNumberTest >> testTan [ +PMHyperDualNumberTest >> testTan [ | a | a := three tan. self assert: a value equals: 3 tan. @@ -376,7 +376,7 @@ HyperDualNumberTest >> testTan [ ] { #category : #'tests-testing' } -HyperDualNumberTest >> testTesting [ +PMHyperDualNumberTest >> testTesting [ self deny: 3 isDualNumber . self assert: one isDualNumber. self assert: zeroc isDualNumber. From 0ce6bbc31e7151ee373f9b741b9ea3b2720ebe6e Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 26 Dec 2018 19:05:35 +0000 Subject: [PATCH 046/161] [issue-85] Moved the TestCase classes to more sensible packages. --- .../PMPermutationTest.class.st | 2 +- src/Math-Tests-Permutation/package.st | 1 + src/{Math-TSNE => Math-Tests-TSNE}/TSNETest.class.st | 2 +- src/Math-Tests-TSNE/package.st | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) rename src/{Math-Permutation => Math-Tests-Permutation}/PMPermutationTest.class.st (99%) create mode 100644 src/Math-Tests-Permutation/package.st rename src/{Math-TSNE => Math-Tests-TSNE}/TSNETest.class.st (93%) create mode 100644 src/Math-Tests-TSNE/package.st 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-TSNE/TSNETest.class.st b/src/Math-Tests-TSNE/TSNETest.class.st similarity index 93% rename from src/Math-TSNE/TSNETest.class.st rename to src/Math-Tests-TSNE/TSNETest.class.st index 803475421..e2de10199 100644 --- a/src/Math-TSNE/TSNETest.class.st +++ b/src/Math-Tests-TSNE/TSNETest.class.st @@ -1,7 +1,7 @@ Class { #name : #TSNETest, #superclass : #TestCase, - #category : 'Math-TSNE' + #category : #'Math-Tests-TSNE' } { #category : #tests } 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' } From e3c0ccd61fb0903ab80f913f60e4f4a8b1dc6417 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sat, 5 Jan 2019 19:24:28 +0000 Subject: [PATCH 047/161] [issue-88] Corrected the type. --- .../PMPrincipalComponentAnalyserTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 2062f8c4c..63742f964 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -16,7 +16,7 @@ PMPrincipalComponentAnalyserTest >> testPCAwithPCAandJacobiTransformationReturnS m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). pca1 := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. pca1 fit: m. - pca2 := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. + pca2 := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. pca2 fit: m. self assert: pca1 transformMatrix closeTo: pca2 transformMatrix ] From 56b187fc065438d9ebe5aa6f45f8f0f8af4275f2 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 4 Feb 2019 21:37:49 +0000 Subject: [PATCH 048/161] [issue-81] Added a test for the eigevalues of a 2 x 2 identity matrix as a starting point. --- .../PMJacobiTransformationTest.class.st | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st diff --git a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st new file mode 100644 index 000000000..4f10a870c --- /dev/null +++ b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st @@ -0,0 +1,18 @@ +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 +] From 5bdef020ac96c941467b2f1dfc704badb632b829 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 4 Feb 2019 22:09:54 +0000 Subject: [PATCH 049/161] [issue-81] Added another missing test to confirm that the eigenvectors of I are the unit basis vectors. --- .../PMJacobiTransformationTest.class.st | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st index 4f10a870c..e35f73c7e 100644 --- a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st +++ b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st @@ -16,3 +16,19 @@ PMJacobiTransformationTest >> testEigenvalueOfIdentityMatrixIsOne [ 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 eigenvectors xUnitVector yUnitVector | + identityMatrix := PMMatrix rows: #(#(1 0) #(0 1)). + jacobiTransform := PMJacobiTransformation matrix: identityMatrix. + + eigenvectors := jacobiTransform transform. + + xUnitVector := #(1 0) asPMVector. + self assert: (eigenvectors columnAt: 1) equals: xUnitVector. + yUnitVector := #(0 1) asPMVector. + self assert: (eigenvectors columnAt: 2) equals: yUnitVector. +] From 2fb0d443f160d748a8317389be79b80dc52656fd Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 10 Feb 2019 15:22:38 +0000 Subject: [PATCH 050/161] [issue-81] Simplified the test a bit. --- .../PMJacobiTransformationTest.class.st | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st index e35f73c7e..e7398f98d 100644 --- a/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st +++ b/src/Math-Tests-Matrix/PMJacobiTransformationTest.class.st @@ -21,14 +21,12 @@ PMJacobiTransformationTest >> testEigenvalueOfIdentityMatrixIsOne [ PMJacobiTransformationTest >> testEigenvectorsOfIdentityMatrixAreTheUnitVectors [ "The eigenvectors of I are (1 0) and (0 1), the unit basis vectors" - | identityMatrix jacobiTransform eigenvectors xUnitVector yUnitVector | + | identityMatrix jacobiTransform matrixOfEigenvectors expected | identityMatrix := PMMatrix rows: #(#(1 0) #(0 1)). jacobiTransform := PMJacobiTransformation matrix: identityMatrix. - eigenvectors := jacobiTransform transform. + matrixOfEigenvectors := jacobiTransform transform. - xUnitVector := #(1 0) asPMVector. - self assert: (eigenvectors columnAt: 1) equals: xUnitVector. - yUnitVector := #(0 1) asPMVector. - self assert: (eigenvectors columnAt: 2) equals: yUnitVector. + expected := PMSymmetricMatrix identity: 2. + self assert: matrixOfEigenvectors equals: expected. ] From 67d989490089d0a6e5900929d87974c2e4ca9859 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 6 Mar 2019 16:06:49 +0000 Subject: [PATCH 051/161] [issue-81] Extracted Scikit Learn's algorithm to its own class to allow a little more isolated testing. --- ...iKitLearnEigenvectorFlipAlgorithm.class.st | 69 +++++++++++++++++++ ...LearnEigenvectorFlipAlgorithmTest.class.st | 28 ++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st create mode 100644 src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st new file mode 100644 index 000000000..d7c05c612 --- /dev/null +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -0,0 +1,69 @@ +" +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 : #SciKitLearnEigenvectorFlipAlgorithm, + #superclass : #Object, + #instVars : [ + 'u', + 'v' + ], + #category : #'Math-PrincipalComponentAnalysis' +} + +{ #category : #'instance creation' } +SciKitLearnEigenvectorFlipAlgorithm class >> u: u v: v [ + ^ self new + u: u; + v: v; + yourself +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> computeSigns [ + | maxAbsCols i | + maxAbsCols := u abs argMaxOnColumns. + i := 0. + ^ (u + rowsCollect: [ :each | + i := i + 1. + each at: (maxAbsCols at: i) ]) sign +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ + "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" + + "does not work at the moment" + + | signs | + signs := self computeSigns. + u := u * signs. + v := v productWithVector: (signs copyFrom: 1 to: v numberOfColumns) +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> u [ + ^u +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> u: leftSingularVectors [ + u := leftSingularVectors +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> v [ + ^v +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> v: rightSingularVectors [ + v := rightSingularVectors. +] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st new file mode 100644 index 000000000..3b8571185 --- /dev/null +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -0,0 +1,28 @@ +" +This is the test class that exercises scikit-learn Eigenvector Flip Algorithm + +" +Class { + #name : #SciKitLearnEigenvectorFlipAlgorithmTest, + #superclass : #TestCase, + #category : #'Math-Tests-PrincipalComponentAnalysis' +} + +{ #category : #tests } +SciKitLearnEigenvectorFlipAlgorithmTest >> testFlipEigenvectorsSign [ + "The purpose is to compare the output from fligEigenVectorsSign in + PolyMath with scikit-learn + " + + | m u v flipAlgorithm svd expected signs | + m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). + svd := PMSingularValueDecomposition new initialize: m. + u := svd leftSingularForm. + v := svd rightSingularForm. + flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + signs := flipAlgorithm computeSigns . + + expected := #(-1 -1 -1 1 1 -1) asPMVector. + self assert: signs equals: expected +] From cac097bd9462d820b6e8afc763b3ab0b170db138 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 6 Mar 2019 16:17:04 +0000 Subject: [PATCH 052/161] [issue-81] Refactor - improved the name of the method. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 4 ++-- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index d7c05c612..ed469dc6a 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -24,7 +24,7 @@ SciKitLearnEigenvectorFlipAlgorithm class >> u: u v: v [ ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> computeSigns [ +SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ | maxAbsCols i | maxAbsCols := u abs argMaxOnColumns. i := 0. @@ -43,7 +43,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "does not work at the moment" | signs | - signs := self computeSigns. + signs := self computeSignsFromU. u := u * signs. v := v productWithVector: (signs copyFrom: 1 to: v numberOfColumns) ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 3b8571185..1d3d6ba85 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -21,7 +21,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testFlipEigenvectorsSign [ v := svd rightSingularForm. flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. - signs := flipAlgorithm computeSigns . + signs := flipAlgorithm computeSignsFromU . expected := #(-1 -1 -1 1 1 -1) asPMVector. self assert: signs equals: expected From da438671aad46427b00402b409dbe472a87c11a9 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 13 Mar 2019 22:38:32 +0000 Subject: [PATCH 053/161] [issue-81] Added a method to demonstrate how the argMax message works for vectors over the field of real numbers. --- src/Math-Core/PMVector.class.st | 10 +++++++++- src/Math-Tests-DHB-Numerical/PMVectorTest.class.st | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index a501fef1b..d908bd07d 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -115,8 +115,16 @@ PMVector >> accumulateNegated: aVectorOrAnArray [ { #category : #'as yet unclassified' } PMVector >> argMax [ + | precision | + precision := 1.0e-10. + ^ self argMaxTo: precision +] + +{ #category : #'as yet unclassified' } +PMVector >> argMaxTo: roundingPrecision [ | a | - a := self asArray. + a := self asArray + collect: [ :element | element truncateTo: roundingPrecision ]. ^ a indexOf: a max ] diff --git a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st b/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st index d7594239b..114d575ce 100644 --- a/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st +++ b/src/Math-Tests-DHB-Numerical/PMVectorTest.class.st @@ -43,6 +43,17 @@ PMVectorTest >> testArgMax [ 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) From b3d94f3e80bc854dc3a56dc78847091824b326fe Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sat, 16 Mar 2019 21:00:27 +0000 Subject: [PATCH 054/161] [issue-81] The signs computed by the computeSignsFromU message match Sci-Kit Learn. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 9 +++++---- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index ed469dc6a..23ff3485d 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -25,13 +25,14 @@ SciKitLearnEigenvectorFlipAlgorithm class >> u: u v: v [ { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ - | maxAbsCols i | + | maxAbsCols i maxElements | maxAbsCols := u abs argMaxOnColumns. i := 0. - ^ (u + maxElements := u transpose rowsCollect: [ :each | i := i + 1. - each at: (maxAbsCols at: i) ]) sign + each at: (maxAbsCols at: i) ]. + ^ maxElements sign ] { #category : #accessing } @@ -45,7 +46,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ | signs | signs := self computeSignsFromU. u := u * signs. - v := v productWithVector: (signs copyFrom: 1 to: v numberOfColumns) + v := v * (signs copyFrom: 1 to: v numberOfColumns) ] { #category : #accessing } diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 1d3d6ba85..b3b8672dc 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -9,7 +9,7 @@ Class { } { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testFlipEigenvectorsSign [ +SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ "The purpose is to compare the output from fligEigenVectorsSign in PolyMath with scikit-learn " @@ -23,6 +23,6 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testFlipEigenvectorsSign [ signs := flipAlgorithm computeSignsFromU . - expected := #(-1 -1 -1 1 1 -1) asPMVector. + expected := #(-1 1 1 1 1 1) asPMVector . self assert: signs equals: expected ] From 9ed793b97627f7b2a53fccffccb3b6eca92b240b Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sat, 16 Mar 2019 21:07:14 +0000 Subject: [PATCH 055/161] [issue-81] To make it easier to understand the algebra, return the signs as a vector object. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 23ff3485d..8533e639a 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -32,7 +32,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ rowsCollect: [ :each | i := i + 1. each at: (maxAbsCols at: i) ]. - ^ maxElements sign + ^ maxElements sign asPMVector ] { #category : #accessing } From a507773f6247272fd2b72b0417ff186008c103d5 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 12:42:40 +0000 Subject: [PATCH 056/161] [issue-81] Extracted a helper method and added a test, where the example is taken from scikit-learn. --- ...iKitLearnEigenvectorFlipAlgorithm.class.st | 20 ++++++++-- ...LearnEigenvectorFlipAlgorithmTest.class.st | 38 +++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 8533e639a..92a9bf3a2 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -43,10 +43,24 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "does not work at the moment" - | signs | + | signs matrixForV | signs := self computeSignsFromU. - u := u * signs. - v := v * (signs copyFrom: 1 to: v numberOfColumns) + u := u rowsCollect: [ :row | row dot: signs ]. + matrixForV := self signMatrixForV: signs. + v := v dot: matrixForV +] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV: signs [ + | signsForV | + signsForV := signs copyFrom: 1 to: v numberOfColumns. + ^ PMMatrix + rows: + ((1 to: v numberOfRows) + inject: OrderedCollection new + into: [ :rows :eachRow | + rows add: signsForV. + rows ]) ] { #category : #accessing } diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index b3b8672dc..b49561d78 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -26,3 +26,41 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ expected := #(-1 1 1 1 1 1) asPMVector . self assert: signs equals: expected ] + +{ #category : #tests } +SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ + "We compute a matrix of signs for V 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 v signAlgo signs expected | + 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)). + signs := #(-1 1 1 1 1 1) asPMVector . + signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + + expected := PMMatrix rows: #(#(-1 1) #(-1 1)). + self assert: (signAlgo signMatrixForV: signs) equals: expected +] From f96e321aa0517c36f9ac68b17b2b1f47078e428a Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:37:37 +0000 Subject: [PATCH 057/161] [issue-81] Simplified initialisation of the algorithm, removed obselete method. --- ...iKitLearnEigenvectorFlipAlgorithm.class.st | 43 +++++++++++-------- ...LearnEigenvectorFlipAlgorithmTest.class.st | 4 +- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 92a9bf3a2..919c90057 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -10,7 +10,8 @@ Class { #superclass : #Object, #instVars : [ 'u', - 'v' + 'v', + 'signs' ], #category : #'Math-PrincipalComponentAnalysis' } @@ -18,8 +19,7 @@ Class { { #category : #'instance creation' } SciKitLearnEigenvectorFlipAlgorithm class >> u: u v: v [ ^ self new - u: u; - v: v; + initializeWithU: u andV: v; yourself ] @@ -43,42 +43,47 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "does not work at the moment" - | signs matrixForV | - signs := self computeSignsFromU. + | matrixForV | u := u rowsCollect: [ :row | row dot: signs ]. - matrixForV := self signMatrixForV: signs. + matrixForV := self signMatrixForV. v := v dot: matrixForV ] +{ #category : #initialization } +SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ + "instanciate the algorithm" + u := uMatrix. + v := vMatrix. + signs := self computeSignsFromU . + + +] + { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV: signs [ +SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV [ | signsForV | - signsForV := signs copyFrom: 1 to: v numberOfColumns. + signsForV := self signs copyFrom: 1 to: v numberOfColumns. ^ PMMatrix rows: ((1 to: v numberOfRows) inject: OrderedCollection new into: [ :rows :eachRow | - rows add: signsForV. - rows ]) + rows + add: signsForV; + yourself ]) ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> u [ - ^u +SciKitLearnEigenvectorFlipAlgorithm >> signs [ + ^ signs ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> u: leftSingularVectors [ - u := leftSingularVectors +SciKitLearnEigenvectorFlipAlgorithm >> u [ + ^u ] { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> v [ ^v ] - -{ #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> v: rightSingularVectors [ - v := rightSingularVectors. -] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index b49561d78..9d169447d 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -57,10 +57,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ v := PMMatrix rows: #( #(0.83849224 0.54491354) #(0.54491354 -0.83849224)). - signs := #(-1 1 1 1 1 1) asPMVector . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. - expected := PMMatrix rows: #(#(-1 1) #(-1 1)). - self assert: (signAlgo signMatrixForV: signs) equals: expected + self assert: (signAlgo signMatrixForV) equals: expected ] From 2a6d1cca5d5591f90fe3db761dc2a0a27e208920 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:43:40 +0000 Subject: [PATCH 058/161] [issue-81] Inlined a local variable. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 919c90057..da534f686 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -43,10 +43,8 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "does not work at the moment" - | matrixForV | u := u rowsCollect: [ :row | row dot: signs ]. - matrixForV := self signMatrixForV. - v := v dot: matrixForV + v := v dot: (self signMatrixForV) ] { #category : #initialization } From 4dcd160e3d939a7af427b9bfc46cd38e60a2992f Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:50:33 +0000 Subject: [PATCH 059/161] [issue-81] Developed a method that computes the sign matrix for the U matrix. --- ...iKitLearnEigenvectorFlipAlgorithm.class.st | 12 ++++++ ...LearnEigenvectorFlipAlgorithmTest.class.st | 37 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index da534f686..6f8289282 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -57,6 +57,18 @@ SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ ] +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForU [ + ^ PMMatrix + rows: + ((1 to: u numberOfRows) + inject: OrderedCollection new + into: [ :rows :eachRow | + rows + add: signs; + yourself ]) +] + { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV [ | signsForV | diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 9d169447d..a066a3b40 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -27,6 +27,43 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ self assert: signs equals: expected ] +{ #category : #tests } +SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ + "We compute a matrix of signs for V 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 v signAlgo expected | + 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)). + signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). + self assert: (signAlgo signMatrixForU) equals: expected + +] + { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ "We compute a matrix of signs for V with which From 1ffa708a83ccf8dec2cf458bc446222693b27b3c Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:52:27 +0000 Subject: [PATCH 060/161] [issue-81] Removed an unused variable. --- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index a066a3b40..5f8ec08a4 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -83,7 +83,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ [ 0.54491354 -0.83849224]] " - | u v signAlgo signs expected | + | u v signAlgo expected | u := PMMatrix rows: #( #(-0.21956688 0.53396977) #(-0.35264795 -0.45713538) From 4f052040fe56e01d7d5837ed5753eddddd4cf8ce Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:55:18 +0000 Subject: [PATCH 061/161] [issue-81] Spelling error. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 6f8289282..105d84805 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -49,7 +49,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ { #category : #initialization } SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ - "instanciate the algorithm" + "instantiate the algorithm" u := uMatrix. v := vMatrix. signs := self computeSignsFromU . From 73a980c4958441465bd47c88b6ec999095327a23 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 13:58:27 +0000 Subject: [PATCH 062/161] [issue-81] Removed an obselete comment. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 105d84805..afe45fbe3 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -41,8 +41,6 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609" - "does not work at the moment" - u := u rowsCollect: [ :row | row dot: signs ]. v := v dot: (self signMatrixForV) ] From 9197aef906a9ebcfa9c52b99b4fa4ff3dcc61553 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 14:15:46 +0000 Subject: [PATCH 063/161] [issue-81] Store the flipped matrices in better named state variables. --- ...ciKitLearnEigenvectorFlipAlgorithm.class.st | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index afe45fbe3..c547f5465 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -11,7 +11,9 @@ Class { #instVars : [ 'u', 'v', - 'signs' + 'signs', + 'uFlipped', + 'vFlipped' ], #category : #'Math-PrincipalComponentAnalysis' } @@ -41,8 +43,8 @@ SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609" - u := u rowsCollect: [ :row | row dot: signs ]. - v := v dot: (self signMatrixForV) + uFlipped := u rowsCollect: [ :row | row dot: signs ]. + vFlipped := v dot: (self signMatrixForV) ] { #category : #initialization } @@ -91,7 +93,17 @@ SciKitLearnEigenvectorFlipAlgorithm >> u [ ^u ] +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> uFlipped [ + ^ uFlipped . +] + { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> v [ ^v ] + +{ #category : #accessing } +SciKitLearnEigenvectorFlipAlgorithm >> vFlipped [ + ^ vFlipped . +] From 037d13260303c6b99e01a25625975fa9cd45edc9 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 14:17:09 +0000 Subject: [PATCH 064/161] [issue-81] Removed unused accessor methods. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index c547f5465..3d61a056c 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -88,21 +88,11 @@ SciKitLearnEigenvectorFlipAlgorithm >> signs [ ^ signs ] -{ #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> u [ - ^u -] - { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> uFlipped [ ^ uFlipped . ] -{ #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> v [ - ^v -] - { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> vFlipped [ ^ vFlipped . From 584e6dcf4d32984d2ec4393ee6189bee0bffb1d2 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 14:36:12 +0000 Subject: [PATCH 065/161] [issue-81] Corrected the comment. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 4 ++-- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 3d61a056c..4d6923f9a 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -90,10 +90,10 @@ SciKitLearnEigenvectorFlipAlgorithm >> signs [ { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> uFlipped [ - ^ uFlipped . + ^ PMMatrix rows: (u rowsCollect: [ :row | row dot: signs ]). ] { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> vFlipped [ - ^ vFlipped . + ^ v dot: (self signMatrixForV) . ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 5f8ec08a4..1fb8a8c8d 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -29,7 +29,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ - "We compute a matrix of signs for V with which + "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) From 84053e194d9acf6f892b6ad136cf9195ca078bd8 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 14:37:53 +0000 Subject: [PATCH 066/161] [issue-81] Added a test for uFlipped. --- ...LearnEigenvectorFlipAlgorithmTest.class.st | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 1fb8a8c8d..21fb684ed 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -29,7 +29,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ - "We compute a matrix of signs for U with which + "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) @@ -99,3 +99,45 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ expected := PMMatrix rows: #(#(-1 1) #(-1 1)). self assert: (signAlgo signMatrixForV) equals: expected ] + +{ #category : #tests } +SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ + "Here we calculate the U matrix with its signs flipped + 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 v signAlgo expected | + 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)). + signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + 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: (signAlgo uFlipped) equals: expected + + +] From 31c6da6bd2f406a0bf75b648b3ff045de7177a5a Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 14:39:32 +0000 Subject: [PATCH 067/161] [issue-81] Fixed the comment, again. --- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 21fb684ed..61dd8af32 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -29,7 +29,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ - "We compute a matrix of signs for u with which + "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) From cadba1a3026b196b1fd3f9e86d952d6aaa150df0 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 15:01:42 +0000 Subject: [PATCH 068/161] [issue-81] Added a test for vFlipped, corrected an existing test. --- ...iKitLearnEigenvectorFlipAlgorithm.class.st | 4 +- ...LearnEigenvectorFlipAlgorithmTest.class.st | 40 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 4d6923f9a..a837fec19 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -73,14 +73,14 @@ SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForU [ SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV [ | signsForV | signsForV := self signs copyFrom: 1 to: v numberOfColumns. - ^ PMMatrix + ^ (PMMatrix rows: ((1 to: v numberOfRows) inject: OrderedCollection new into: [ :rows :eachRow | rows add: signsForV; - yourself ]) + yourself ])) transpose ] { #category : #accessing } diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 61dd8af32..ac59b4e07 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -96,7 +96,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ #(0.54491354 -0.83849224)). signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. - expected := PMMatrix rows: #(#(-1 1) #(-1 1)). + expected := PMMatrix rows: #(#(-1 -1) #(1 1)). self assert: (signAlgo signMatrixForV) equals: expected ] @@ -141,3 +141,41 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ ] + +{ #category : #tests } +SciKitLearnEigenvectorFlipAlgorithmTest >> testVFlipped [ + "Here we calculate the U matrix with its signs flipped + 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 v signAlgo expected | + 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)). + signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + expected := PMMatrix rows: #( + #(-0.83849224 -0.54491354) + #(0.54491354 -0.83849224)). + + self assert: (signAlgo vFlipped) equals: expected + + +] From 6eca7c2a9a2316db63b84e3290ed8f8236c52f31 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 15:16:36 +0000 Subject: [PATCH 069/161] [issue-81] Removed unused state variables. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index a837fec19..918f8b937 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -11,9 +11,7 @@ Class { #instVars : [ 'u', 'v', - 'signs', - 'uFlipped', - 'vFlipped' + 'signs' ], #category : #'Math-PrincipalComponentAnalysis' } From 52dda1ef2d68cbbf8ac979f6857d7f476b9c01bf Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 15:22:42 +0000 Subject: [PATCH 070/161] [issue-81] Removed the unused method. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index 918f8b937..b7cb3f239 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -35,16 +35,6 @@ SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ ^ maxElements sign asPMVector ] -{ #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> flipSign [ - "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" - - uFlipped := u rowsCollect: [ :row | row dot: signs ]. - vFlipped := v dot: (self signMatrixForV) -] - { #category : #initialization } SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ "instantiate the algorithm" From 51545e52325da9b63ddbad73ee51e09cbdd2c010 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 16:46:22 +0000 Subject: [PATCH 071/161] [issue-81] Extracted duplicate arrange code to an intent-revealing set up helper. --- ...LearnEigenvectorFlipAlgorithmTest.class.st | 70 +++++++------------ 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index ac59b4e07..0217769dc 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -5,9 +5,27 @@ This is the test class that exercises scikit-learn Eigenvector Flip Algorithm Class { #name : #SciKitLearnEigenvectorFlipAlgorithmTest, #superclass : #TestCase, + #instVars : [ + 'u', + 'v' + ], #category : #'Math-Tests-PrincipalComponentAnalysis' } +{ #category : #initialization } +SciKitLearnEigenvectorFlipAlgorithmTest >> setUpScikitLearnExample [ + 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)). +] + { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ "The purpose is to compare the output from fligEigenVectorsSign in @@ -46,17 +64,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ [ 0.54491354 -0.83849224]] " - | u v signAlgo expected | - 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)). + | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). @@ -83,17 +92,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ [ 0.54491354 -0.83849224]] " - | u v signAlgo expected | - 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)). + | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. expected := PMMatrix rows: #(#(-1 -1) #(1 1)). @@ -116,17 +116,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ [ 0.54491354 -0.83849224]] " - | u v signAlgo expected | - 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)). + | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. expected := PMMatrix rows: #( @@ -158,17 +149,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testVFlipped [ [ 0.54491354 -0.83849224]] " - | u v signAlgo expected | - 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)). + | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. expected := PMMatrix rows: #( From eeeb65e9a367c5961906d2fc03973b32357913cf Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 17 Mar 2019 18:05:44 +0000 Subject: [PATCH 072/161] [issue-81] Use the helper as it generates the same set up. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 4 ++-- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index b7cb3f239..c2674dcb2 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -38,8 +38,8 @@ SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ { #category : #initialization } SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ "instantiate the algorithm" - u := uMatrix. - v := vMatrix. + u := uMatrix . + v := vMatrix . signs := self computeSignsFromU . diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 0217769dc..8805351b4 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -32,16 +32,13 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ PolyMath with scikit-learn " - | m u v flipAlgorithm svd expected signs | - m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - svd := PMSingularValueDecomposition new initialize: m. - u := svd leftSingularForm. - v := svd rightSingularForm. + | flipAlgorithm expected signs | + self setUpScikitLearnExample . flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. signs := flipAlgorithm computeSignsFromU . - expected := #(-1 1 1 1 1 1) asPMVector . + expected := #(-1 1) asPMVector . self assert: signs equals: expected ] From c0a460f0177546d4afa4e62c3859fb0bf417fd14 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 18 Mar 2019 21:49:24 +0000 Subject: [PATCH 073/161] [issue-81] Use the signMatrixForU message to be consistent with vFlipped. --- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index c2674dcb2..d628c796b 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -78,7 +78,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> signs [ { #category : #accessing } SciKitLearnEigenvectorFlipAlgorithm >> uFlipped [ - ^ PMMatrix rows: (u rowsCollect: [ :row | row dot: signs ]). + ^ u dot: (self signMatrixForU). ] { #category : #accessing } From ea6ff01393196a501deb12ae4ff81b6e8aea06a2 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sat, 23 Mar 2019 20:31:59 +0000 Subject: [PATCH 074/161] [issue-81] Moved the duplicated comments to a more sensible place. --- ...LearnEigenvectorFlipAlgorithmTest.class.st | 83 +++++-------------- 1 file changed, 21 insertions(+), 62 deletions(-) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index 8805351b4..bc79004b1 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -14,6 +14,24 @@ Class { { #category : #initialization } SciKitLearnEigenvectorFlipAlgorithmTest >> setUpScikitLearnExample [ +" 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) @@ -44,23 +62,6 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ - "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]] - " - | signAlgo expected | self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. @@ -72,24 +73,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ - "We compute a matrix of signs for V 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]] - " - | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. @@ -99,21 +84,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ - "Here we calculate the U matrix with its signs flipped - 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]] - " - | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. @@ -132,21 +104,8 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ { #category : #tests } SciKitLearnEigenvectorFlipAlgorithmTest >> testVFlipped [ - "Here we calculate the U matrix with its signs flipped - 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]] - " - | signAlgo expected | + self setUpScikitLearnExample . signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. From 83c1f4226ab92a1a281a7a254399742143b9e032 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sat, 23 Mar 2019 21:09:49 +0000 Subject: [PATCH 075/161] [issue-81] We now have a working SVD flip algorithm. --- .../PMPrincipalComponentAnalyserSVD.class.st | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 2c604bb3b..2b76c78b3 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -49,14 +49,11 @@ 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" - "does not work at the moment" - | signs maxAbsCols i | - maxAbsCols := (u abs) argMaxOnColumns. - i := 0. - signs := (u rowsCollect: [ :each| i := i + 1. each at: (maxAbsCols at: i) - ]) sign. - u := u * signs. - v := v productWithVector: (signs copyFrom:1 to: v numberOfColumns) + | algo | + algo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + + u := algo uFlipped . + v := algo vFlipped . ] { #category : #accessing } From 0a0fdc369f04ab2e0f6567ed0525bb8964a4b040 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 24 Mar 2019 14:59:33 +0000 Subject: [PATCH 076/161] [issue-81] Improved the name of the instanciation method. --- .../PMPrincipalComponentAnalyserSVD.class.st | 2 +- .../SciKitLearnEigenvectorFlipAlgorithm.class.st | 2 +- .../SciKitLearnEigenvectorFlipAlgorithmTest.class.st | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 2b76c78b3..235713a8e 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -50,7 +50,7 @@ PMPrincipalComponentAnalyserSVD >> flipEigenvectorsSign [ "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609" | algo | - algo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + algo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. u := algo uFlipped . v := algo vFlipped . diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st index d628c796b..728380b43 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st @@ -17,7 +17,7 @@ Class { } { #category : #'instance creation' } -SciKitLearnEigenvectorFlipAlgorithm class >> u: u v: v [ +SciKitLearnEigenvectorFlipAlgorithm class >> flipU: u andV: v [ ^ self new initializeWithU: u andV: v; yourself diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st index bc79004b1..1017dc652 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st @@ -52,7 +52,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ | flipAlgorithm expected signs | self setUpScikitLearnExample . - flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. signs := flipAlgorithm computeSignsFromU . @@ -64,7 +64,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). self assert: (signAlgo signMatrixForU) equals: expected @@ -76,7 +76,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #(#(-1 -1) #(1 1)). self assert: (signAlgo signMatrixForV) equals: expected @@ -87,7 +87,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #( #(0.21956688 0.53396977) @@ -107,7 +107,7 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testVFlipped [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm u: u v: v. + signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #( #(-0.83849224 -0.54491354) From a4de28e2efc671de10839269cc9288d617928606 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Thu, 28 Mar 2019 22:12:56 +0100 Subject: [PATCH 077/161] Update .smalltalk.ston --- .smalltalk.ston | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index 7f19c7a1b..6deea66ad 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -1,14 +1,15 @@ SmalltalkCISpec { #loading : [ SCIMetacelloLoadSpec { - #baseline : 'PolyMath', + #baseline : 'Kendrick', #directory : 'src', #platforms : [ #pharo ] } ], #testing : { - #categories : [ 'Math-*' ] - } + #categories : [ 'Kendrick-Tests-*', 'Kendrick-InternalDSL'], + #coverage : { + #categories : [ 'Kendrick-*' ] + } + } } - - From 159cb0ab5e9fc52b92bb171f6bdcb2ac5c54a79a Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Thu, 28 Mar 2019 22:16:39 +0100 Subject: [PATCH 078/161] Reverse --- .smalltalk.ston | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index 6deea66ad..7abde374f 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -1,15 +1,12 @@ SmalltalkCISpec { #loading : [ SCIMetacelloLoadSpec { - #baseline : 'Kendrick', + #baseline : 'PolyMath', #directory : 'src', #platforms : [ #pharo ] } ], - #testing : { - #categories : [ 'Kendrick-Tests-*', 'Kendrick-InternalDSL'], - #coverage : { - #categories : [ 'Kendrick-*' ] - } - } + #testing : { + #categories : [ 'Math-*' ] + } } From 8a4b11efb8cf319cb38f2ceae6f6cb947af7b191 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Thu, 28 Mar 2019 22:43:24 +0000 Subject: [PATCH 079/161] [issue-81] The sign flipping is now working in that the test for the SVD-based PCA implementation is now failing rather than erroring. --- .../PMPrincipalComponentAnalyserSVD.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index 235713a8e..b09e670b4 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -37,11 +37,11 @@ d1 scatterplotMatrix. { #category : #accessing } PMPrincipalComponentAnalyserSVD >> fit: aPMMatrix [ - svd := PMSingularValueDecomposition new initialize: aPMMatrix. + svd := aPMMatrix decompose. u := svd leftSingularForm. v := svd rightSingularForm. - "self flipEigenvectorsSign" - "flip does not work correctly at the moment" + self flipEigenvectorsSign + ] { #category : #accessing } From af2bdc164fc8fcc167a5ebbcbc1fb1e327d584e9 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Fri, 29 Mar 2019 08:42:42 +0000 Subject: [PATCH 080/161] [issue-81] Name of the class now conforms to the PolyMath codestyle. --- .../PMPrincipalComponentAnalyserSVD.class.st | 2 +- ...=> PMSciKitLearnSVDFlipAlgorithm.class.st} | 18 +++++++------- ...MSciKitLearnSVDFlipAlgorithmTest.class.st} | 24 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) rename src/Math-PrincipalComponentAnalysis/{SciKitLearnEigenvectorFlipAlgorithm.class.st => PMSciKitLearnSVDFlipAlgorithm.class.st} (73%) rename src/Math-Tests-PrincipalComponentAnalysis/{SciKitLearnEigenvectorFlipAlgorithmTest.class.st => PMSciKitLearnSVDFlipAlgorithmTest.class.st} (75%) diff --git a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st index b09e670b4..fb1eda853 100644 --- a/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserSVD.class.st @@ -50,7 +50,7 @@ PMPrincipalComponentAnalyserSVD >> flipEigenvectorsSign [ "U-based decision like : https://github.com/scikit-learn/scikit-learn/blob/4c65d8e615c9331d37cbb6225c5b67c445a5c959/sklearn/utils/extmath.py#L609" | algo | - algo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + algo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. u := algo uFlipped . v := algo vFlipped . diff --git a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st similarity index 73% rename from src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st rename to src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st index 728380b43..44f7ceeeb 100644 --- a/src/Math-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st @@ -6,7 +6,7 @@ This class uses the SciKit-Learn SVD flip algorithm to ensure the signs of the e " Class { - #name : #SciKitLearnEigenvectorFlipAlgorithm, + #name : #PMSciKitLearnSVDFlipAlgorithm, #superclass : #Object, #instVars : [ 'u', @@ -17,14 +17,14 @@ Class { } { #category : #'instance creation' } -SciKitLearnEigenvectorFlipAlgorithm class >> flipU: u andV: v [ +PMSciKitLearnSVDFlipAlgorithm class >> flipU: u andV: v [ ^ self new initializeWithU: u andV: v; yourself ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ +PMSciKitLearnSVDFlipAlgorithm >> computeSignsFromU [ | maxAbsCols i maxElements | maxAbsCols := u abs argMaxOnColumns. i := 0. @@ -36,7 +36,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> computeSignsFromU [ ] { #category : #initialization } -SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ +PMSciKitLearnSVDFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ "instantiate the algorithm" u := uMatrix . v := vMatrix . @@ -46,7 +46,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> initializeWithU: uMatrix andV: vMatrix [ ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForU [ +PMSciKitLearnSVDFlipAlgorithm >> signMatrixForU [ ^ PMMatrix rows: ((1 to: u numberOfRows) @@ -58,7 +58,7 @@ SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForU [ ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV [ +PMSciKitLearnSVDFlipAlgorithm >> signMatrixForV [ | signsForV | signsForV := self signs copyFrom: 1 to: v numberOfColumns. ^ (PMMatrix @@ -72,16 +72,16 @@ SciKitLearnEigenvectorFlipAlgorithm >> signMatrixForV [ ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> signs [ +PMSciKitLearnSVDFlipAlgorithm >> signs [ ^ signs ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> uFlipped [ +PMSciKitLearnSVDFlipAlgorithm >> uFlipped [ ^ u dot: (self signMatrixForU). ] { #category : #accessing } -SciKitLearnEigenvectorFlipAlgorithm >> vFlipped [ +PMSciKitLearnSVDFlipAlgorithm >> vFlipped [ ^ v dot: (self signMatrixForV) . ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st similarity index 75% rename from src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st rename to src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st index 1017dc652..0702c1592 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/SciKitLearnEigenvectorFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st @@ -3,7 +3,7 @@ This is the test class that exercises scikit-learn Eigenvector Flip Algorithm " Class { - #name : #SciKitLearnEigenvectorFlipAlgorithmTest, + #name : #PMSciKitLearnSVDFlipAlgorithmTest, #superclass : #TestCase, #instVars : [ 'u', @@ -13,7 +13,7 @@ Class { } { #category : #initialization } -SciKitLearnEigenvectorFlipAlgorithmTest >> setUpScikitLearnExample [ +PMSciKitLearnSVDFlipAlgorithmTest >> setUpScikitLearnExample [ " We compute a matrix of signs for U with which we perform a 'dot product' with the original matrix V @@ -45,14 +45,14 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> setUpScikitLearnExample [ ] { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ +PMSciKitLearnSVDFlipAlgorithmTest >> testComputeSignsFromU [ "The purpose is to compare the output from fligEigenVectorsSign in PolyMath with scikit-learn " | flipAlgorithm expected signs | self setUpScikitLearnExample . - flipAlgorithm := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. signs := flipAlgorithm computeSignsFromU . @@ -61,10 +61,10 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testComputeSignsFromU [ ] { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ +PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForU [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). self assert: (signAlgo signMatrixForU) equals: expected @@ -72,22 +72,22 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForU [ ] { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testSignMatrixForV [ +PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForV [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #(#(-1 -1) #(1 1)). self assert: (signAlgo signMatrixForV) equals: expected ] { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ +PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #( #(0.21956688 0.53396977) @@ -103,11 +103,11 @@ SciKitLearnEigenvectorFlipAlgorithmTest >> testUFlipped [ ] { #category : #tests } -SciKitLearnEigenvectorFlipAlgorithmTest >> testVFlipped [ +PMSciKitLearnSVDFlipAlgorithmTest >> testVFlipped [ | signAlgo expected | self setUpScikitLearnExample . - signAlgo := SciKitLearnEigenvectorFlipAlgorithm flipU: u andV: v. + signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. expected := PMMatrix rows: #( #(-0.83849224 -0.54491354) From 3e8d1eecc0453328db408afa5473927d5928f99d Mon Sep 17 00:00:00 2001 From: "C. Fuhrman" Date: Fri, 29 Mar 2019 15:28:38 +0100 Subject: [PATCH 081/161] Support for principalDiagonal function #91 (#92) --- src/Math-Matrix/PMMatrix.class.st | 11 +++++++++++ src/Math-Tests-Matrix/PMMatrixTest.class.st | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index a2ca52cee..c3547d753 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -588,6 +588,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]) diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 62c49f910..3c9457521 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -439,6 +439,12 @@ PMMatrixTest >> testMatrixMultiplyElementwise [ self assert: ((c rowAt: 2) at: 3) equals: 21 ] +{ #category : #'linear algebra' } +PMMatrixTest >> testMatrixPrincipalDiagonal [ + | a | + a := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). + self assert: a principalDiagonal equals: #(1 5 9) asPMVector. + { #category : #comparing } PMMatrixTest >> testMatrixSign [ | a | From 5b950459c6a11d617f173ca459d8d9566effe7c9 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 29 Mar 2019 21:14:45 +0100 Subject: [PATCH 082/161] Update .travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 70991a2ec..a1133a18c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,3 @@ smalltalk: matrix: fast_finish: true - allow_failures: - - smalltalk: Pharo-7.0 - - smalltalk: Pharo64-7.0 From 09fab2e8227f5bba2a04d646172196a88d32544e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 29 Mar 2019 23:17:52 +0100 Subject: [PATCH 083/161] Update PMMatrixTest.class.st --- src/Math-Tests-Matrix/PMMatrixTest.class.st | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 3c9457521..2c065d7bd 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -444,6 +444,7 @@ PMMatrixTest >> testMatrixPrincipalDiagonal [ | a | a := PMMatrix rows: #(#(1 2 3) #(4 5 6) #(7 8 9)). self assert: a principalDiagonal equals: #(1 5 9) asPMVector. +] { #category : #comparing } PMMatrixTest >> testMatrixSign [ @@ -712,8 +713,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 - - - - ] From a1e045bafb63b763fd6bf60340e01970b29967f3 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 29 Mar 2019 23:36:10 +0100 Subject: [PATCH 084/161] missing PM before a class name ... --- .../PMKolmogorovSmirnov2sampleTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st index ba9cdf8a7..8ef63f618 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st @@ -27,7 +27,7 @@ PMKolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ ] { #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)" From b1ec1ef71e52f9ef2629966088f3b979de72cdc4 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 15 Apr 2019 10:15:59 +0100 Subject: [PATCH 085/161] [Issue 81] - 2 PCA implementations that give same results but different from Python scikit-learn implementation (#96) * [issue-81] Categorised the methods, removed duplication to the set up method. * [issue-81] Added additional tests from the example in the Sandia sign ambiguity paper. * [issue-81] Added tests to confirm that we would get the same flipped U and V. * [issue-81] Renamed the set up method to follow convention. * [issue-81] Mobbing with colleagues we decided that it sufficed, because of sign ambiguity, to compare the moduli of the matrices. * [issue-81] Removed the computation of argMax to an certain level of precision. After discussion with colleagues it was deemed inadvisable. * [issue-81] Extracted expected outputs to a local variable with a good name. --- src/Math-Core/PMVector.class.st | 10 +-- .../PMPrincipalComponentAnalyserTest.class.st | 28 ++++-- ...PMSciKitLearnSVDFlipAlgorithmTest.class.st | 66 ++++++-------- ...itLearnSVDFlipAlgorithmSandiaTest.class.st | 85 +++++++++++++++++++ 4 files changed, 131 insertions(+), 58 deletions(-) create mode 100644 src/Math-Tests-PrincipalComponentAnalysis/PMScikitLearnSVDFlipAlgorithmSandiaTest.class.st diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index d908bd07d..a501fef1b 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -115,16 +115,8 @@ PMVector >> accumulateNegated: aVectorOrAnArray [ { #category : #'as yet unclassified' } PMVector >> argMax [ - | precision | - precision := 1.0e-10. - ^ self argMaxTo: precision -] - -{ #category : #'as yet unclassified' } -PMVector >> argMaxTo: roundingPrecision [ | a | - a := self asArray - collect: [ :element | element truncateTo: roundingPrecision ]. + a := self asArray. ^ a indexOf: a max ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index 63742f964..d8c2a23f2 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -18,23 +18,35 @@ PMPrincipalComponentAnalyserTest >> testPCAwithPCAandJacobiTransformationReturnS pca1 fit: m. pca2 := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. pca2 fit: m. - self assert: pca1 transformMatrix closeTo: pca2 transformMatrix + + self assert: pca1 transformMatrix abs closeTo: pca2 transformMatrix abs ] { #category : #tests } PMPrincipalComponentAnalyserTest >> testTransformMatrixWithJacobiTransformation [ - | m pca | - m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - pca := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. + | m pca expected | + m := PMMatrix + rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). + pca := PMPrincipalComponentAnalyserJacobiTransformation new + componentsNumber: 2. + pca fit: m. - self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) + + expected := (PMMatrix + rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs. + self assert: pca transformMatrix abs closeTo: expected ] { #category : #tests } PMPrincipalComponentAnalyserTest >> testTransformMatrixWithSVD [ - | m pca | - m := PMMatrix rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). + | m pca expected | + m := PMMatrix + rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. + pca fit: m. - self assert: pca transformMatrix closeTo: (PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) + + expected := (PMMatrix + rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs. + self assert: pca transformMatrix abs closeTo: expected ] diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st index 0702c1592..270a42603 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithmTest.class.st @@ -7,13 +7,14 @@ Class { #superclass : #TestCase, #instVars : [ 'u', - 'v' + 'v', + 'flipAlgorithm' ], #category : #'Math-Tests-PrincipalComponentAnalysis' } { #category : #initialization } -PMSciKitLearnSVDFlipAlgorithmTest >> setUpScikitLearnExample [ +PMSciKitLearnSVDFlipAlgorithmTest >> setUp [ " We compute a matrix of signs for U with which we perform a 'dot product' with the original matrix V @@ -42,53 +43,44 @@ PMSciKitLearnSVDFlipAlgorithmTest >> setUpScikitLearnExample [ v := PMMatrix rows: #( #(0.83849224 0.54491354) #(0.54491354 -0.83849224)). + + flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. ] -{ #category : #tests } +{ #category : #'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testComputeSignsFromU [ "The purpose is to compare the output from fligEigenVectorsSign in PolyMath with scikit-learn " - | flipAlgorithm expected signs | - self setUpScikitLearnExample . - flipAlgorithm := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. + | expected signs | - signs := flipAlgorithm computeSignsFromU . - - expected := #(-1 1) asPMVector . + signs := flipAlgorithm computeSignsFromU. + + expected := #(-1 1) asPMVector. self assert: signs equals: expected ] -{ #category : #tests } +{ #category : #'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForU [ - | signAlgo expected | - self setUpScikitLearnExample . - signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. - + | expected | expected := PMMatrix rows: #(#(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1) #(-1 1)). - self assert: (signAlgo signMatrixForU) equals: expected + + self assert: (flipAlgorithm signMatrixForU) equals: expected ] -{ #category : #tests } +{ #category : #'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testSignMatrixForV [ - | signAlgo expected | - - self setUpScikitLearnExample . - signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. - + | expected | expected := PMMatrix rows: #(#(-1 -1) #(1 1)). - self assert: (signAlgo signMatrixForV) equals: expected + + self assert: (flipAlgorithm signMatrixForV) equals: expected ] -{ #category : #tests } +{ #category : #'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [ - | signAlgo expected | - - self setUpScikitLearnExample . - signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. - + | expected | expected := PMMatrix rows: #( #(0.21956688 0.53396977) #(0.35264795 -0.45713538) @@ -97,23 +89,15 @@ PMSciKitLearnSVDFlipAlgorithmTest >> testUFlipped [ #(-0.35264795 0.45713538) #(-0.57221483 -0.07683439)). - self assert: (signAlgo uFlipped) equals: expected + self assert: (flipAlgorithm uFlipped) equals: expected ] -{ #category : #tests } +{ #category : #'scikit-learn-example' } PMSciKitLearnSVDFlipAlgorithmTest >> testVFlipped [ - | signAlgo expected | - - self setUpScikitLearnExample . - signAlgo := PMSciKitLearnSVDFlipAlgorithm flipU: u andV: v. - - expected := PMMatrix rows: #( - #(-0.83849224 -0.54491354) - #(0.54491354 -0.83849224)). + | expected | + expected := PMMatrix rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224)). - self assert: (signAlgo vFlipped) equals: expected - - + 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 +] From c20cba68ac21aa2babaece29eea2efe761ca29eb Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Sun, 21 Apr 2019 16:36:47 +0100 Subject: [PATCH 086/161] [Issue 81] 2 PCA implementations that give same results but different from Python scikit-learn implementation (#97) * [issue-81] Added an acceptance test with the mean-centred data from the Lindsay Smith PCA Tutorial paper. * [issue-81] Improved the name of the test method. * [issue-81] Added an acceptance for the Jacobi-based transform: message. --- .../PMPrincipalComponentAnalyserTest.class.st | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st index d8c2a23f2..b648f76b3 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -1,3 +1,9 @@ +" +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, @@ -10,6 +16,41 @@ Class { #category : #'Math-Tests-PrincipalComponentAnalysis' } +{ #category : #'pca tutorial' } +PMPrincipalComponentAnalyserTest >> testJacobiBasedTransformWithMeanCentredMeasurements [ + "As acceptance tests we use the worked example of the PCA tutorial of Lindsay Smith" + | m pca transformedData expected | + m := 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) + ). + pca := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. + + pca fit: m. + transformedData := pca transform: m. + + 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. +] + { #category : #tests } PMPrincipalComponentAnalyserTest >> testPCAwithPCAandJacobiTransformationReturnSame [ | m pca1 pca2 | @@ -22,6 +63,42 @@ PMPrincipalComponentAnalyserTest >> testPCAwithPCAandJacobiTransformationReturnS self assert: pca1 transformMatrix abs closeTo: pca2 transformMatrix abs ] +{ #category : #'pca tutorial' } +PMPrincipalComponentAnalyserTest >> testSVDBasedTransformWithMeanCentredMeasurements [ + "As acceptance tests we use the worked example of the PCA tutorial of Lindsay Smith" + + | m pca transformedData expected | + m := 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) + ). + pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. + + pca fit: m. + transformedData := pca transform: m. + + 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. +] + { #category : #tests } PMPrincipalComponentAnalyserTest >> testTransformMatrixWithJacobiTransformation [ | m pca expected | From d94a6d5cd54fd513e624203df46bce6b8666878d Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 24 Apr 2019 09:05:09 +0100 Subject: [PATCH 087/161] [Issue 81] Refactoring/Clean Up (#98) * [issue-81] Improved the name of the variables. * [issue-81] Improved the name of the categories. * [issue-81] Removed obselete comments. * [issue-81] Emphasised the polymorphism of the two implementations of PCA in their respective tests. * [issue-81] Removed duplicate code to set up messages. * [issue-81] Removed unused instance variables. * [issue-81] Use an existing message that has the same method. * [issue-81] Moved the duplicate acceptance tests to a more sensible place. --- .../PMPCAJacobiTransformationTest.class.st | 14 +++ ...PCASingularValueDecompositionTest.class.st | 25 +++++ .../PMPrincipalComponentAnalyserTest.class.st | 103 ++++-------------- 3 files changed, 58 insertions(+), 84 deletions(-) create mode 100644 src/Math-Tests-PrincipalComponentAnalysis/PMPCAJacobiTransformationTest.class.st create mode 100644 src/Math-Tests-PrincipalComponentAnalysis/PMPCASingularValueDecompositionTest.class.st 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 index b648f76b3..48cea390c 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMPrincipalComponentAnalyserTest.class.st @@ -8,67 +8,33 @@ Class { #name : #PMPrincipalComponentAnalyserTest, #superclass : #TestCase, #instVars : [ - 'average', - 'covarianceMatrix', - 'accumulator', - 'server' + 'pca' ], #category : #'Math-Tests-PrincipalComponentAnalysis' } -{ #category : #'pca tutorial' } -PMPrincipalComponentAnalyserTest >> testJacobiBasedTransformWithMeanCentredMeasurements [ - "As acceptance tests we use the worked example of the PCA tutorial of Lindsay Smith" - | m pca transformedData expected | - m := 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) - ). - pca := PMPrincipalComponentAnalyserJacobiTransformation new componentsNumber: 2. - - pca fit: m. - transformedData := pca transform: m. - - 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. +{ #category : #testing } +PMPrincipalComponentAnalyserTest class >> isAbstract [ + ^ self name = #PMPrincipalComponentAnalyserTest ] -{ #category : #tests } -PMPrincipalComponentAnalyserTest >> 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. +{ #category : #'scikit-learn-example' } +PMPrincipalComponentAnalyserTest >> testTransformMatrix [ + | m expected | + m := PMMatrix + rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - self assert: pca1 transformMatrix abs closeTo: pca2 transformMatrix abs + pca fit: m. + + expected := (PMMatrix + rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs. + self assert: pca transformMatrix abs closeTo: expected ] -{ #category : #'pca tutorial' } -PMPrincipalComponentAnalyserTest >> testSVDBasedTransformWithMeanCentredMeasurements [ - "As acceptance tests we use the worked example of the PCA tutorial of Lindsay Smith" - - | m pca transformedData expected | - m := PMMatrix rows: #( +{ #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) @@ -80,10 +46,8 @@ PMPrincipalComponentAnalyserTest >> testSVDBasedTransformWithMeanCentredMeasurem #(-0.31 -0.31) #(-0.71 -1.01) ). - pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. - pca fit: m. - transformedData := pca transform: m. + transformedData := pca fitAndTransform: meanCentredData. expected := PMMatrix rows: #( #(-0.827970186 -0.175115307) @@ -98,32 +62,3 @@ PMPrincipalComponentAnalyserTest >> testSVDBasedTransformWithMeanCentredMeasurem #(1.22382056 -0.162675287)). self assert: (transformedData abs) closeTo: expected abs. ] - -{ #category : #tests } -PMPrincipalComponentAnalyserTest >> testTransformMatrixWithJacobiTransformation [ - | m pca expected | - m := PMMatrix - rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - pca := PMPrincipalComponentAnalyserJacobiTransformation new - componentsNumber: 2. - - pca fit: m. - - expected := (PMMatrix - rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs. - self assert: pca transformMatrix abs closeTo: expected -] - -{ #category : #tests } -PMPrincipalComponentAnalyserTest >> testTransformMatrixWithSVD [ - | m pca expected | - m := PMMatrix - rows: #(#(-1 -1) #(-2 -1) #(-3 -2) #(1 1) #(2 1) #(3 2)). - pca := PMPrincipalComponentAnalyserSVD new componentsNumber: 2. - - pca fit: m. - - expected := (PMMatrix - rows: #(#(-0.83849224 -0.54491354) #(0.54491354 -0.83849224))) abs. - self assert: pca transformMatrix abs closeTo: expected -] From 5d68807b13891857f65941ca62815d71f8cdeb58 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 10:36:15 +0100 Subject: [PATCH 088/161] Add missing tests in BaselineOf --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 2e762cc74..38329a109 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -76,6 +76,7 @@ BaselineOfPolyMath >> baseline: spec [ 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-ODE' with: [ spec requires: #('Math-ODE') ]; + 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') ]; @@ -88,7 +89,7 @@ BaselineOfPolyMath >> baseline: spec [ 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: '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' 'Math-Tests-PrincipalComponentAnalysis'); group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] From fa2b1b4857c85eafc352ce161d793746073d2d8d Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 11:02:34 +0100 Subject: [PATCH 089/161] Add more missing tests package --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 38329a109..abe8e806e 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -73,14 +73,19 @@ BaselineOfPolyMath >> baseline: spec [ package: 'Math-Tests-FastFourierTransform' with: [ spec requires: #('Math-FastFourierTransform' 'Math-DHB-Numerical' 'Math-Polynomials') ]; package: 'Math-Tests-FunctionFit'; 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-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-Number-Extensions' with: [ spec requires: #('Math-Number-Extensions') ]; package: 'Math-Tests-ODE' with: [ spec requires: #('Math-ODE') ]; + 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-RandomDistributionBased' with: [ spec requires: #('Math-RandomDistributionBased') ]; + package:'Math-Tests-TSNE' with: [ spec requires: #('Math-TSNE') ]; package: 'Math-UtilsDataServer'. "Groups" @@ -89,7 +94,7 @@ BaselineOfPolyMath >> baseline: spec [ 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' 'Math-Tests-PrincipalComponentAnalysis'); + 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' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-KernelSmoothing' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' 'Math-Tests-TSNE' 'Math-Tests-RandomDistributionBased'); group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] From acc851766dad455e1a373b670d25b72e8e67859e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 11:10:41 +0100 Subject: [PATCH 090/161] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index efb045863..d9130ce4b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Metacello new load ``` -We have **767** green tests ! +We have **797** 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: - complex and quaternions extensions, From 8336164c0ef13229df7a663c7fcb128b7514534c Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 11:17:28 +0100 Subject: [PATCH 091/161] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d9130ce4b..ab7c692e3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # PolyMath +Screenshot 2019-04-24 at 11 12 57 + [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) [![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea) @@ -24,7 +26,6 @@ PolyMath is a Smalltalk project, similar to existing scientific libraries like N - Didier Besset's numerical methods, - Ordinary Differential Equation (ODE) solvers. -[![Lorentz attractor with PolyMath and GraphET](https://pbs.twimg.com/media/Ble65B3CYAEkMoR.jpg)](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 From 4562f1ff8798faa8d2ea18aed9277d0211668ad1 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 11:18:02 +0100 Subject: [PATCH 092/161] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab7c692e3..7769dc11f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # PolyMath -Screenshot 2019-04-24 at 11 12 57 - [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) [![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE) +Screenshot 2019-04-24 at 11 12 57 + You can load the code in a fresh Pharo 6.1 image with: ```Smalltalk From 8003696ba09e645d7b562acce49c8c5e48c12b9f Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 13:51:49 +0100 Subject: [PATCH 093/161] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7769dc11f..d30b9a815 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,18 @@ Screenshot 2019-04-24 at 11 12 57 -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 - repository: 'github://PolyMathOrg/PolyMath:master/src'; + repository: 'github://PolyMathOrg/PolyMath:development/src'; baseline: 'PolyMath'; load ``` We have **797** 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: +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, @@ -26,7 +26,6 @@ PolyMath is a Smalltalk project, similar to existing scientific libraries like N - Didier Besset's numerical methods, - Ordinary Differential Equation (ODE) solvers. - A book about PolyMath called "Numerical Methods" is available online: https://github.com/SquareBracketAssociates/NumericalMethods/releases/tag/snapshot-2016-01-17 Some documentation (to be cleaned and reorganized) about PolyMath is available on the Wiki here: From fcc062c56b3a073588d9c9c30d217854494e7a86 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 24 Apr 2019 13:55:20 +0100 Subject: [PATCH 094/161] Update README.md --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d30b9a815..5c5e36856 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Metacello new load ``` -We have **797** green tests ! - +We have **797** 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, @@ -26,7 +26,7 @@ PolyMath is a Pharo project, similar to existing scientific libraries like NumPy - Didier Besset's numerical methods, - Ordinary Differential Equation (ODE) solvers. -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,11 +35,11 @@ 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 - githubUser: 'PolyMathOrg' project: 'PolyMath' commitish: 'master' path: 'src'; + githubUser: 'PolyMathOrg' project: 'PolyMath' commitish: 'development' path: 'src'; baseline: 'PolyMath'; load ``` @@ -49,11 +49,9 @@ To add PolyMath to your baseline just add this: ```Smalltalk spec baseline: 'PolyMath' - with: [ spec repository: 'github://PolyMathOrg/PolyMath:master/src' ] + with: [ spec repository: 'github://PolyMathOrg/PolyMath:development/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 From 89244433b78307b2863df5c70d3f6f3d1c7c50d4 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 29 Apr 2019 08:54:28 +0100 Subject: [PATCH 095/161] [Issue 62] - Rename packages that have DHB in their names (Part 1) (#102) * [issue-62] Removed an empty test case. * [issue-62] Moved the tests to a more appropriate package. * [issue-62] Moved the test class to a more appropriate package. --- src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st | 2 +- .../PMBulirschStoerInterpolator.class.st | 2 +- src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st | 2 +- src/Math-DHB-Numerical/PMCauchyDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st | 2 +- src/Math-DHB-Numerical/PMExponentialDistribution.class.st | 2 +- .../PMFisherTippettDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMFunctionOptimizer.class.st | 2 +- src/Math-DHB-Numerical/PMFunctionalIterator.class.st | 2 +- src/Math-DHB-Numerical/PMGeneticOptimizer.class.st | 2 +- src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st | 2 +- .../PMHistogrammedDistribution.class.st | 2 +- .../PMIncompleteBetaFractionTermServer.class.st | 2 +- .../PMIncompleteBetaFunctionFraction.class.st | 2 +- .../PMIncompleteGammaFractionTermServer.class.st | 2 +- .../PMIncompleteGammaSeriesTermServer.class.st | 2 +- src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st | 2 +- src/Math-DHB-Numerical/PMLanczosFormula.class.st | 2 +- src/Math-DHB-Numerical/PMLaplaceDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMLeastSquareFit.class.st | 2 +- src/Math-DHB-Numerical/PMLineSearch.class.st | 2 +- src/Math-DHB-Numerical/PMLinearRegression.class.st | 2 +- src/Math-DHB-Numerical/PMLogNormalDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMMaximizingPoint.class.st | 2 +- .../PMMaximumLikelihoodHistogramFit.class.st | 2 +- src/Math-DHB-Numerical/PMMinimizingPoint.class.st | 2 +- .../PMMultiVariableGeneralOptimizer.class.st | 2 +- src/Math-DHB-Numerical/PMNevilleInterpolator.class.st | 2 +- src/Math-DHB-Numerical/PMNewtonInterpolator.class.st | 2 +- src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st | 2 +- .../PMOneVariableFunctionOptimizer.class.st | 2 +- src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st | 2 +- src/Math-DHB-Numerical/PMPointSeries.class.st | 2 +- .../PMProbabilityDensityWithUnknownDistribution.class.st | 2 +- .../PMProbabilityDistributionFunction.class.st | 2 +- .../PMProjectedOneVariableFunction.class.st | 2 +- src/Math-DHB-Numerical/PMRombergIntegrator.class.st | 2 +- .../PMScaledProbabilityDensityFunction.class.st | 2 +- src/Math-DHB-Numerical/PMSeriesTermServer.class.st | 2 +- src/Math-DHB-Numerical/PMSimplexOptimizer.class.st | 2 +- src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st | 2 +- src/Math-DHB-Numerical/PMSplineInterpolator.class.st | 2 +- src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st | 2 +- src/Math-DHB-Numerical/PMTriangularDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMUniformDistribution.class.st | 2 +- src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st | 8 -------- src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st | 2 +- src/Math-DHB-Numerical/PMWeibullDistribution.class.st | 2 +- .../PMFixpointTest.class.st | 2 +- src/Math-Tests-Core-Process/package.st | 1 + .../PMVectorTest.class.st | 2 +- src/Math-Tests-Core/package.st | 1 + .../PMCovarianceAccumulatorTest.class.st | 2 +- .../PMDecimalFloatingNumberTest.class.st | 2 +- .../PMExponentialDistributionTest.class.st | 2 +- .../PMFloatingPointMachineTestCase.class.st | 2 +- .../PMGeneticOptimizerBugsTest.class.st | 2 +- .../PMHistogramTestsAndBugs.class.st | 2 +- .../PMNumberExtensionsTestCase.class.st | 2 +- .../PMNumericalMethodsTestCase.class.st | 2 +- src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st | 2 +- 61 files changed, 60 insertions(+), 66 deletions(-) delete mode 100644 src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st rename src/{Math-Tests-DHB-wk => Math-Tests-Core-Process}/PMFixpointTest.class.st (98%) create mode 100644 src/Math-Tests-Core-Process/package.st rename src/{Math-Tests-DHB-Numerical => Math-Tests-Core}/PMVectorTest.class.st (99%) create mode 100644 src/Math-Tests-Core/package.st diff --git a/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st b/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st index f8e92c903..6c9d0b91a 100644 --- a/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st +++ b/src/Math-DHB-Numerical/PMBisectionZeroFinder.class.st @@ -8,7 +8,7 @@ Class { 'positiveX', 'negativeX' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #operation } diff --git a/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st b/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st index 1112b2986..7de85db42 100644 --- a/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st +++ b/src/Math-DHB-Numerical/PMBulirschStoerInterpolator.class.st @@ -1,7 +1,7 @@ Class { #name : #PMBulirschStoerInterpolator, #superclass : #PMNevilleInterpolator, - #category : 'Math-DHB-Numerical-Math-Interpolator' + #category : #'Math-DHB-Numerical-Math-Interpolator' } { #category : #private } diff --git a/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st b/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st index a5a1e15c4..b0bb58d78 100644 --- a/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st +++ b/src/Math-DHB-Numerical/PMCDFNewtonZeroFinder.class.st @@ -7,7 +7,7 @@ Class { #instVars : [ 'old' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #operation } diff --git a/src/Math-DHB-Numerical/PMCauchyDistribution.class.st b/src/Math-DHB-Numerical/PMCauchyDistribution.class.st index 381e60cd0..0ca531517 100644 --- a/src/Math-DHB-Numerical/PMCauchyDistribution.class.st +++ b/src/Math-DHB-Numerical/PMCauchyDistribution.class.st @@ -5,7 +5,7 @@ Class { 'mu', 'beta' ], - #category : 'Math-DHB-Numerical-Math-Distribution' + #category : #'Math-DHB-Numerical-Math-Distribution' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st b/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st index dc8bc9e6a..89c148a29 100644 --- a/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st +++ b/src/Math-DHB-Numerical/PMDecimalFloatingNumber.class.st @@ -17,7 +17,7 @@ Class { #classVars : [ 'Digits' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMExponentialDistribution.class.st b/src/Math-DHB-Numerical/PMExponentialDistribution.class.st index fde747d7e..1df12742a 100644 --- a/src/Math-DHB-Numerical/PMExponentialDistribution.class.st +++ b/src/Math-DHB-Numerical/PMExponentialDistribution.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'beta' ], - #category : 'Math-DHB-Numerical-Math-Distribution' + #category : #'Math-DHB-Numerical-Math-Distribution' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st b/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st index 4c90c18c4..623d224e7 100644 --- a/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st +++ b/src/Math-DHB-Numerical/PMFisherTippettDistribution.class.st @@ -5,7 +5,7 @@ Class { 'alpha', 'beta' ], - #category : 'Math-DHB-Numerical-Math-Distribution' + #category : #'Math-DHB-Numerical-Math-Distribution' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st b/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st index 605735cbf..c571e29e7 100644 --- a/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMFunctionOptimizer.class.st @@ -5,7 +5,7 @@ Class { 'optimizingPointClass', 'bestPoints' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMFunctionalIterator.class.st b/src/Math-DHB-Numerical/PMFunctionalIterator.class.st index bd0bf20ae..3fb208e27 100644 --- a/src/Math-DHB-Numerical/PMFunctionalIterator.class.st +++ b/src/Math-DHB-Numerical/PMFunctionalIterator.class.st @@ -16,7 +16,7 @@ Class { #instVars : [ 'functionBlock' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st b/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st index b1f9763b8..fade5fe25 100644 --- a/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMGeneticOptimizer.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'chromosomeManager' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st b/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st index 037422365..c3957dcfb 100644 --- a/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMHillClimbingOptimizer.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'unidimensionalFinder' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #initialization } diff --git a/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st b/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st index db82646d4..571615fd8 100644 --- a/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st +++ b/src/Math-DHB-Numerical/PMHistogrammedDistribution.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'histogram' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st b/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st index a8b26162f..ee83803ad 100644 --- a/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st +++ b/src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st @@ -5,7 +5,7 @@ Class { 'alpha1', 'alpha2' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st b/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st index 57e212b0a..b32600dfe 100644 --- a/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st +++ b/src/Math-DHB-Numerical/PMIncompleteBetaFunctionFraction.class.st @@ -11,7 +11,7 @@ Class { 'alpha1', 'alpha2' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st b/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st index a565882c0..15b813fde 100644 --- a/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st +++ b/src/Math-DHB-Numerical/PMIncompleteGammaFractionTermServer.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'alpha' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st b/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st index c63dc15c7..58a3fb7fb 100644 --- a/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st +++ b/src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st @@ -5,7 +5,7 @@ Class { 'alpha', 'sum' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st b/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st index cf465e162..a1b1f839d 100644 --- a/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st +++ b/src/Math-DHB-Numerical/PMLagrangeInterpolator.class.st @@ -13,7 +13,7 @@ Class { #instVars : [ 'pointCollection' ], - #category : 'Math-DHB-Numerical-Math-Interpolator' + #category : #'Math-DHB-Numerical-Math-Interpolator' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMLanczosFormula.class.st b/src/Math-DHB-Numerical/PMLanczosFormula.class.st index f2935653e..eb87385ad 100644 --- a/src/Math-DHB-Numerical/PMLanczosFormula.class.st +++ b/src/Math-DHB-Numerical/PMLanczosFormula.class.st @@ -20,7 +20,7 @@ Class { #classVars : [ 'UniqueInstance' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st b/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st index 42727b063..12d9f571f 100644 --- a/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st +++ b/src/Math-DHB-Numerical/PMLaplaceDistribution.class.st @@ -5,7 +5,7 @@ Class { 'mu', 'beta' ], - #category : 'Math-DHB-Numerical-Math-Distribution' + #category : #'Math-DHB-Numerical-Math-Distribution' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMLeastSquareFit.class.st b/src/Math-DHB-Numerical/PMLeastSquareFit.class.st index 45ef541ea..f39ec3794 100644 --- a/src/Math-DHB-Numerical/PMLeastSquareFit.class.st +++ b/src/Math-DHB-Numerical/PMLeastSquareFit.class.st @@ -9,7 +9,7 @@ Class { 'constants', 'degreeOfFreedom' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMLineSearch.class.st b/src/Math-DHB-Numerical/PMLineSearch.class.st index f8da00500..8361d9c89 100644 --- a/src/Math-DHB-Numerical/PMLineSearch.class.st +++ b/src/Math-DHB-Numerical/PMLineSearch.class.st @@ -39,7 +39,7 @@ Class { 'useCubicApproximation', 'extendedResult' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #'instance creation' } diff --git a/src/Math-DHB-Numerical/PMLinearRegression.class.st b/src/Math-DHB-Numerical/PMLinearRegression.class.st index 17e33300a..81b67ce79 100644 --- a/src/Math-DHB-Numerical/PMLinearRegression.class.st +++ b/src/Math-DHB-Numerical/PMLinearRegression.class.st @@ -12,7 +12,7 @@ Class { 'intercept', 'correlationCoefficient' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st b/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st index 967e26612..0d95bf1af 100644 --- a/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st +++ b/src/Math-DHB-Numerical/PMLogNormalDistribution.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'normalDistribution' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMMaximizingPoint.class.st b/src/Math-DHB-Numerical/PMMaximizingPoint.class.st index a9812adc6..f11025656 100644 --- a/src/Math-DHB-Numerical/PMMaximizingPoint.class.st +++ b/src/Math-DHB-Numerical/PMMaximizingPoint.class.st @@ -1,7 +1,7 @@ Class { #name : #PMMaximizingPoint, #superclass : #PMMinimizingPoint, - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st b/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st index a97d4e7c3..53e422cce 100644 --- a/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st +++ b/src/Math-DHB-Numerical/PMMaximumLikelihoodHistogramFit.class.st @@ -5,7 +5,7 @@ Class { 'count', 'countVariance' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #operation } diff --git a/src/Math-DHB-Numerical/PMMinimizingPoint.class.st b/src/Math-DHB-Numerical/PMMinimizingPoint.class.st index 53e05cd4b..7ea57214c 100644 --- a/src/Math-DHB-Numerical/PMMinimizingPoint.class.st +++ b/src/Math-DHB-Numerical/PMMinimizingPoint.class.st @@ -5,7 +5,7 @@ Class { 'value', 'position' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st b/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st index e97954700..e8f3a64d8 100644 --- a/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMMultiVariableGeneralOptimizer.class.st @@ -1,7 +1,7 @@ Class { #name : #PMMultiVariableGeneralOptimizer, #superclass : #PMFunctionOptimizer, - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #operation } diff --git a/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st b/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st index 156286d88..c13b781c0 100644 --- a/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st +++ b/src/Math-DHB-Numerical/PMNevilleInterpolator.class.st @@ -5,7 +5,7 @@ Class { 'leftErrors', 'rightErrors' ], - #category : 'Math-DHB-Numerical-Math-Interpolator' + #category : #'Math-DHB-Numerical-Math-Interpolator' } { #category : #private } diff --git a/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st b/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st index 42c70dac6..c08f3c1d0 100644 --- a/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st +++ b/src/Math-DHB-Numerical/PMNewtonInterpolator.class.st @@ -13,7 +13,7 @@ Class { #instVars : [ 'coefficients' ], - #category : 'Math-DHB-Numerical-Math-Interpolator' + #category : #'Math-DHB-Numerical-Math-Interpolator' } { #category : #transformation } diff --git a/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st b/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st index 7d3ed5e87..21ca25eeb 100644 --- a/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st +++ b/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st @@ -30,7 +30,7 @@ Class { 'lineSearch', 'lineSearchFunctionBlock' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st b/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st index 0c8264d50..34a5cebb4 100644 --- a/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMOneVariableFunctionOptimizer.class.st @@ -4,7 +4,7 @@ Class { #classVars : [ 'GoldenSection' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st b/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st index 7e23d598f..126a940aa 100644 --- a/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st +++ b/src/Math-DHB-Numerical/PMOptimizingBracketFinder.class.st @@ -1,7 +1,7 @@ Class { #name : #PMOptimizingBracketFinder, #superclass : #PMOneVariableFunctionOptimizer, - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMPointSeries.class.st b/src/Math-DHB-Numerical/PMPointSeries.class.st index 59d4994c6..78336b318 100644 --- a/src/Math-DHB-Numerical/PMPointSeries.class.st +++ b/src/Math-DHB-Numerical/PMPointSeries.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'points' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st b/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st index e2b96a38e..2341468f6 100644 --- a/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st +++ b/src/Math-DHB-Numerical/PMProbabilityDensityWithUnknownDistribution.class.st @@ -1,7 +1,7 @@ Class { #name : #PMProbabilityDensityWithUnknownDistribution, #superclass : #PMProbabilityDensity, - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st b/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st index 98295518f..842f3b4e5 100644 --- a/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st +++ b/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'probabilityDensity' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st b/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st index 3282e064f..c28405956 100644 --- a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st +++ b/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st @@ -6,7 +6,7 @@ Class { 'function', 'argument' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMRombergIntegrator.class.st b/src/Math-DHB-Numerical/PMRombergIntegrator.class.st index 38cbe422f..844c4e193 100644 --- a/src/Math-DHB-Numerical/PMRombergIntegrator.class.st +++ b/src/Math-DHB-Numerical/PMRombergIntegrator.class.st @@ -21,7 +21,7 @@ Class { 'points', 'interpolator' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st b/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st index 0bd77eeed..ee5ec788f 100644 --- a/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st +++ b/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st @@ -6,7 +6,7 @@ Class { 'count', 'binWidth' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st b/src/Math-DHB-Numerical/PMSeriesTermServer.class.st index 992918236..94250e331 100644 --- a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st +++ b/src/Math-DHB-Numerical/PMSeriesTermServer.class.st @@ -5,7 +5,7 @@ Class { 'x', 'lastTerm' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #initialization } diff --git a/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st b/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st index 59750fa6c..1aba05384 100644 --- a/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st +++ b/src/Math-DHB-Numerical/PMSimplexOptimizer.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'worstVector' ], - #category : 'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-DHB-Numerical-Math-FunctionIterator' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st b/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st index 9870be10b..ca75007e9 100644 --- a/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st +++ b/src/Math-DHB-Numerical/PMSimpsonIntegrator.class.st @@ -1,7 +1,7 @@ Class { #name : #PMSimpsonIntegrator, #superclass : #PMTrapezeIntegrator, - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #operation } diff --git a/src/Math-DHB-Numerical/PMSplineInterpolator.class.st b/src/Math-DHB-Numerical/PMSplineInterpolator.class.st index 60c5af4c5..710a57e5c 100644 --- a/src/Math-DHB-Numerical/PMSplineInterpolator.class.st +++ b/src/Math-DHB-Numerical/PMSplineInterpolator.class.st @@ -5,7 +5,7 @@ Class { 'startPointDerivative', 'endPointDerivative' ], - #category : 'Math-DHB-Numerical-Math-Interpolator' + #category : #'Math-DHB-Numerical-Math-Interpolator' } { #category : #transformation } diff --git a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st b/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st index 9404a0123..409c3582e 100644 --- a/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st +++ b/src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st @@ -12,7 +12,7 @@ Class { 'sum', 'step' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMTriangularDistribution.class.st b/src/Math-DHB-Numerical/PMTriangularDistribution.class.st index 3a98b8e68..f03a3d065 100644 --- a/src/Math-DHB-Numerical/PMTriangularDistribution.class.st +++ b/src/Math-DHB-Numerical/PMTriangularDistribution.class.st @@ -6,7 +6,7 @@ Class { 'highLimit', 'peak' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMUniformDistribution.class.st b/src/Math-DHB-Numerical/PMUniformDistribution.class.st index 00b62684a..e1813aff0 100644 --- a/src/Math-DHB-Numerical/PMUniformDistribution.class.st +++ b/src/Math-DHB-Numerical/PMUniformDistribution.class.st @@ -5,7 +5,7 @@ Class { 'lowLimit', 'highLimit' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #public } diff --git a/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st b/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st deleted file mode 100644 index cc246926d..000000000 --- a/src/Math-DHB-Numerical/PMVectorAccumulatorTest.class.st +++ /dev/null @@ -1,8 +0,0 @@ -" -A PMVectorAccumulatorTest is a test class for testing the behavior of PMVectorAccumulator -" -Class { - #name : #PMVectorAccumulatorTest, - #superclass : #TestCase, - #category : #'Math-DHB-Numerical-Tests' -} diff --git a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st b/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st index b2f0ed550..43e6756d5 100644 --- a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st +++ b/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st @@ -1,7 +1,7 @@ Class { #name : #PMVectorProjectedFunction, #superclass : #PMProjectedOneVariableFunction, - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } diff --git a/src/Math-DHB-Numerical/PMWeibullDistribution.class.st b/src/Math-DHB-Numerical/PMWeibullDistribution.class.st index ba8597040..8c3d982b0 100644 --- a/src/Math-DHB-Numerical/PMWeibullDistribution.class.st +++ b/src/Math-DHB-Numerical/PMWeibullDistribution.class.st @@ -6,7 +6,7 @@ Class { 'beta', 'norm' ], - #category : 'Math-DHB-Numerical' + #category : #'Math-DHB-Numerical' } { #category : #information } 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 99% rename from src/Math-Tests-DHB-Numerical/PMVectorTest.class.st rename to src/Math-Tests-Core/PMVectorTest.class.st index 114d575ce..84afe11c0 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 } 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/PMCovarianceAccumulatorTest.class.st b/src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st index a9595ab8a..8a5379b7f 100644 --- a/src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st +++ b/src/Math-Tests-DHB-Numerical/PMCovarianceAccumulatorTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMCovarianceAccumulatorTest, #superclass : #TestCase, - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #tests } diff --git a/src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st b/src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st index dab8ca8b8..e8a9445f1 100644 --- a/src/Math-Tests-DHB-Numerical/PMDecimalFloatingNumberTest.class.st +++ b/src/Math-Tests-DHB-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-DHB-Numerical' } { #category : #tests } diff --git a/src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st b/src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st index 9cdaeaf15..5635dafff 100644 --- a/src/Math-Tests-DHB-Numerical/PMExponentialDistributionTest.class.st +++ b/src/Math-Tests-DHB-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-DHB-Numerical' } { #category : #tests } diff --git a/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st b/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st index 5c857e4e9..7d9625560 100644 --- a/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st +++ b/src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st @@ -1,7 +1,7 @@ Class { #name : #PMFloatingPointMachineTestCase, #superclass : #TestCase, - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #precision } diff --git a/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st b/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st index 22305a00a..1f83a52ee 100644 --- a/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st +++ b/src/Math-Tests-DHB-Numerical/PMGeneticOptimizerBugsTest.class.st @@ -6,7 +6,7 @@ Class { 'function', 'optimizer' ], - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #running } diff --git a/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st b/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st index 9ab2c8343..33d96ad82 100644 --- a/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st +++ b/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'h' ], - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #comment } diff --git a/src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st b/src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st index b7cef4718..0bb5b2981 100644 --- a/src/Math-Tests-DHB-Numerical/PMNumberExtensionsTestCase.class.st +++ b/src/Math-Tests-DHB-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-DHB-Numerical' } { #category : #'function evaluation' } diff --git a/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st b/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st index fb5f84316..0896af13c 100644 --- a/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st +++ b/src/Math-Tests-DHB-Numerical/PMNumericalMethodsTestCase.class.st @@ -1,7 +1,7 @@ Class { #name : #PMNumericalMethodsTestCase, #superclass : #TestCase, - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #privateMethods } diff --git a/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st b/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st index afbbcd991..58f8a525c 100644 --- a/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st +++ b/src/Math-Tests-DHB-Numerical/PMStatisticsBugs.class.st @@ -1,7 +1,7 @@ Class { #name : #PMStatisticsBugs, #superclass : #TestCase, - #category : 'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-DHB-Numerical' } { #category : #tests } From ffece49818e6edeff26e9ce6632e216e7dae2e46 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 30 Apr 2019 10:27:38 +0100 Subject: [PATCH 096/161] [issue-62] Removed DHB from the package names. (#103) --- src/Math-DHB-Numerical/package.st | 1 - .../Collection.extension.st | 2 +- .../Integer.extension.st | 4 +- .../Number.extension.st | 42 +++++++++---------- .../PMBisectionZeroFinder.class.st | 2 +- .../PMBulirschStoerInterpolator.class.st | 2 +- .../PMCDFNewtonZeroFinder.class.st | 2 +- .../PMCauchyDistribution.class.st | 2 +- .../PMCovarianceAccumulator.class.st | 2 +- .../PMDecimalFloatingNumber.class.st | 2 +- .../PMExponentialDistribution.class.st | 2 +- .../PMFisherTippettDistribution.class.st | 2 +- .../PMFunctionOptimizer.class.st | 2 +- .../PMFunctionalIterator.class.st | 2 +- .../PMGeneticOptimizer.class.st | 2 +- .../PMHillClimbingOptimizer.class.st | 2 +- .../PMHistogrammedDistribution.class.st | 2 +- ...MIncompleteBetaFractionTermServer.class.st | 2 +- .../PMIncompleteBetaFunctionFraction.class.st | 2 +- ...IncompleteGammaFractionTermServer.class.st | 2 +- ...PMIncompleteGammaSeriesTermServer.class.st | 2 +- .../PMLagrangeInterpolator.class.st | 2 +- .../PMLanczosFormula.class.st | 2 +- .../PMLaplaceDistribution.class.st | 2 +- .../PMLeastSquareFit.class.st | 2 +- .../PMLineSearch.class.st | 2 +- .../PMLinearRegression.class.st | 2 +- .../PMLogNormalDistribution.class.st | 2 +- .../PMMaximizingPoint.class.st | 2 +- .../PMMaximumLikelihoodHistogramFit.class.st | 2 +- .../PMMinimizingPoint.class.st | 2 +- .../PMMultiVariableGeneralOptimizer.class.st | 2 +- .../PMNevilleInterpolator.class.st | 2 +- .../PMNewtonInterpolator.class.st | 2 +- .../PMNewtonZeroFinder.class.st | 2 +- .../PMOneVariableFunctionOptimizer.class.st | 2 +- .../PMOptimizingBracketFinder.class.st | 2 +- .../PMPointSeries.class.st | 2 +- ...ityDensityWithUnknownDistribution.class.st | 2 +- ...PMProbabilityDistributionFunction.class.st | 2 +- .../PMProjectedOneVariableFunction.class.st | 2 +- .../PMRombergIntegrator.class.st | 2 +- ...MScaledProbabilityDensityFunction.class.st | 2 +- .../PMSeriesTermServer.class.st | 2 +- .../PMSimplexOptimizer.class.st | 2 +- .../PMSimpsonIntegrator.class.st | 2 +- .../PMSplineInterpolator.class.st | 2 +- .../PMTrapezeIntegrator.class.st | 2 +- .../PMTriangularDistribution.class.st | 2 +- .../PMUniformDistribution.class.st | 2 +- .../PMVectorAccumulator.class.st | 2 +- .../PMVectorProjectedFunction.class.st | 2 +- .../PMWeibullDistribution.class.st | 2 +- src/Math-Numerical/package.st | 1 + src/Math-Tests-DHB-Numerical/package.st | 1 - src/Math-Tests-DHB-wk/package.st | 1 - .../PMCovarianceAccumulatorTest.class.st | 2 +- .../PMDecimalFloatingNumberTest.class.st | 2 +- .../PMExponentialDistributionTest.class.st | 2 +- .../PMFloatingPointMachineTestCase.class.st | 2 +- .../PMGeneticOptimizerBugsTest.class.st | 2 +- .../PMHistogramTestsAndBugs.class.st | 2 +- .../PMNumberExtensionsTestCase.class.st | 2 +- .../PMNumericalMethodsTestCase.class.st | 2 +- .../PMStatisticsBugs.class.st | 2 +- src/Math-Tests-Numerical/package.st | 1 + 66 files changed, 84 insertions(+), 85 deletions(-) delete mode 100644 src/Math-DHB-Numerical/package.st rename src/{Math-DHB-Numerical => Math-Numerical}/Collection.extension.st (84%) rename src/{Math-DHB-Numerical => Math-Numerical}/Integer.extension.st (83%) rename src/{Math-DHB-Numerical => Math-Numerical}/Number.extension.st (84%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMBisectionZeroFinder.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMBulirschStoerInterpolator.class.st (92%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMCDFNewtonZeroFinder.class.st (95%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMCauchyDistribution.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMCovarianceAccumulator.class.st (96%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMDecimalFloatingNumber.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMExponentialDistribution.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMFisherTippettDistribution.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMFunctionOptimizer.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMFunctionalIterator.class.st (96%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMGeneticOptimizer.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMHillClimbingOptimizer.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMHistogrammedDistribution.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMIncompleteBetaFractionTermServer.class.st (95%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMIncompleteBetaFunctionFraction.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMIncompleteGammaFractionTermServer.class.st (94%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMIncompleteGammaSeriesTermServer.class.st (93%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLagrangeInterpolator.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLanczosFormula.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLaplaceDistribution.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLeastSquareFit.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLineSearch.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLinearRegression.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMLogNormalDistribution.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMMaximizingPoint.class.st (84%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMMaximumLikelihoodHistogramFit.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMMinimizingPoint.class.st (95%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMMultiVariableGeneralOptimizer.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMNevilleInterpolator.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMNewtonInterpolator.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMNewtonZeroFinder.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMOneVariableFunctionOptimizer.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMOptimizingBracketFinder.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMPointSeries.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMProbabilityDensityWithUnknownDistribution.class.st (96%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMProbabilityDistributionFunction.class.st (95%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMProjectedOneVariableFunction.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMRombergIntegrator.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMScaledProbabilityDensityFunction.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMSeriesTermServer.class.st (85%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMSimplexOptimizer.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMSimpsonIntegrator.class.st (91%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMSplineInterpolator.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMTrapezeIntegrator.class.st (98%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMTriangularDistribution.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMUniformDistribution.class.st (99%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMVectorAccumulator.class.st (95%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMVectorProjectedFunction.class.st (97%) rename src/{Math-DHB-Numerical => Math-Numerical}/PMWeibullDistribution.class.st (99%) create mode 100644 src/Math-Numerical/package.st delete mode 100644 src/Math-Tests-DHB-Numerical/package.st delete mode 100644 src/Math-Tests-DHB-wk/package.st rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMCovarianceAccumulatorTest.class.st (96%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMDecimalFloatingNumberTest.class.st (98%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMExponentialDistributionTest.class.st (93%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMFloatingPointMachineTestCase.class.st (98%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMGeneticOptimizerBugsTest.class.st (96%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMHistogramTestsAndBugs.class.st (99%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMNumberExtensionsTestCase.class.st (97%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMNumericalMethodsTestCase.class.st (99%) rename src/{Math-Tests-DHB-Numerical => Math-Tests-Numerical}/PMStatisticsBugs.class.st (99%) create mode 100644 src/Math-Tests-Numerical/package.st 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-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 83% rename from src/Math-DHB-Numerical/Integer.extension.st rename to src/Math-Numerical/Integer.extension.st index 52db9133e..0d9781605 100644 --- a/src/Math-DHB-Numerical/Integer.extension.st +++ b/src/Math-Numerical/Integer.extension.st @@ -1,13 +1,13 @@ 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. diff --git a/src/Math-DHB-Numerical/Number.extension.st b/src/Math-Numerical/Number.extension.st similarity index 84% rename from src/Math-DHB-Numerical/Number.extension.st rename to src/Math-Numerical/Number.extension.st index 40dafb8af..522f034d8 100644 --- a/src/Math-DHB-Numerical/Number.extension.st +++ b/src/Math-Numerical/Number.extension.st @@ -1,33 +1,33 @@ Extension { #name : #Number } -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> addPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 19/4/99 " ^aPolynomial addNumber: self ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> beta: aNumber [ "Computes the beta function of the receiver and aNumber" ^ (self logBeta: aNumber) exp ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-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' } +{ #category : #'*Math-Numerical' } Number >> equalsTo: aNumber [ "compare to Float>>closeTo:" ^self relativelyEqualsTo: aNumber upTo: PMFloatingPointMachine new defaultNumericalPrecision ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> errorFunction [ "Answer the error function for the receiver. (c) Copyrights Didier BESSET, 1999, all rights reserved. @@ -35,7 +35,7 @@ Number >> errorFunction [ ^ PMErfApproximation new value: self ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> gamma [ "Compute the Gamma function for the receiver. (c) Copyrights Didier BESSET, 1999, all rights reserved. @@ -48,14 +48,14 @@ Number >> gamma [ ] ] -{ #category : #'*Math-DHB-Numerical' } +{ #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-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> logGamma [ "Computes the log of the Gamma function (for positive numbers only)" ^self > 1 @@ -66,12 +66,12 @@ Number >> logGamma [ ] ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> productWithMatrix: aMatrix [ ^aMatrix class rows: (aMatrix rowsCollect: [:r| self productWithVector: r]) ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> productWithVector: aVector [ "Answers a new vector product of the receiver with aVector. (c) Copyrights Didier BESSET, 1999, all rights reserved. @@ -79,23 +79,23 @@ Number >> productWithVector: aVector [ ^aVector collect: [ :each | each * self] ] -{ #category : #'*Math-DHB-Numerical' } -Number class >> random [ - "Answers a random number between 0 and the receiver +{ #category : #'*Math-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 " - ^ PMMitchellMooreGenerator new floatValue + ^self class random * self ] -{ #category : #'*Math-DHB-Numerical' } -Number >> random [ - "Answers a random number distributed between 0 and the receiver. +{ #category : #'*Math-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 " - ^self class random * self + ^ PMMitchellMooreGenerator new floatValue ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-Numerical' } Number >> relativelyEqualsTo: aNumber upTo: aSmallNumber [ "compare to Float>>closeTo: generally called from Number>>equalsTo:" @@ -105,14 +105,14 @@ Number >> relativelyEqualsTo: aNumber upTo: aSmallNumber [ or: [ (self - aNumber) abs < ( aSmallNumber * norm)] ] -{ #category : #'*Math-DHB-Numerical' } +{ #category : #'*Math-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' } +{ #category : #'*Math-Numerical' } Number >> timesPolynomial: aPolynomial [ "(c) Copyrights Didier BESSET, 1999, all rights reserved. Initial code: 17/4/99 " 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 6c9d0b91a..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 7de85db42..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 b0bb58d78..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 0ca531517..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 96% rename from src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st rename to src/Math-Numerical/PMCovarianceAccumulator.class.st index d272fdcea..905e1b5d3 100644 --- a/src/Math-DHB-Numerical/PMCovarianceAccumulator.class.st +++ b/src/Math-Numerical/PMCovarianceAccumulator.class.st @@ -9,7 +9,7 @@ Class { #instVars : [ 'covariance' ], - #category : #'Math-DHB-Numerical-Math-UtilsAccumulator' + #category : #'Math-Numerical-Math-UtilsAccumulator' } { #category : #transformation } 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 89c148a29..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 1df12742a..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 623d224e7..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 c571e29e7..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 3fb208e27..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 fade5fe25..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 c3957dcfb..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 571615fd8..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 95% rename from src/Math-DHB-Numerical/PMIncompleteBetaFractionTermServer.class.st rename to src/Math-Numerical/PMIncompleteBetaFractionTermServer.class.st index ee83803ad..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 } 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 b32600dfe..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 15b813fde..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 93% rename from src/Math-DHB-Numerical/PMIncompleteGammaSeriesTermServer.class.st rename to src/Math-Numerical/PMIncompleteGammaSeriesTermServer.class.st index 58a3fb7fb..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 a1b1f839d..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 eb87385ad..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 12d9f571f..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 f39ec3794..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 8361d9c89..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 99% rename from src/Math-DHB-Numerical/PMLinearRegression.class.st rename to src/Math-Numerical/PMLinearRegression.class.st index 81b67ce79..7d0d77f2d 100644 --- a/src/Math-DHB-Numerical/PMLinearRegression.class.st +++ b/src/Math-Numerical/PMLinearRegression.class.st @@ -12,7 +12,7 @@ Class { 'intercept', 'correlationCoefficient' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #creation } 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 0d95bf1af..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 f11025656..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 53e422cce..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 7ea57214c..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 e8f3a64d8..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 c13b781c0..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 c08f3c1d0..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 98% rename from src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st rename to src/Math-Numerical/PMNewtonZeroFinder.class.st index 21ca25eeb..5fcc828fc 100644 --- a/src/Math-DHB-Numerical/PMNewtonZeroFinder.class.st +++ b/src/Math-Numerical/PMNewtonZeroFinder.class.st @@ -30,7 +30,7 @@ Class { 'lineSearch', 'lineSearchFunctionBlock' ], - #category : #'Math-DHB-Numerical-Math-FunctionIterator' + #category : #'Math-Numerical-Math-FunctionIterator' } { #category : #creation } 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 34a5cebb4..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 126a940aa..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 78336b318..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 2341468f6..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 95% rename from src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st rename to src/Math-Numerical/PMProbabilityDistributionFunction.class.st index 842f3b4e5..6c6867759 100644 --- a/src/Math-DHB-Numerical/PMProbabilityDistributionFunction.class.st +++ b/src/Math-Numerical/PMProbabilityDistributionFunction.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'probabilityDensity' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st similarity index 98% rename from src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st rename to src/Math-Numerical/PMProjectedOneVariableFunction.class.st index c28405956..5e8593da2 100644 --- a/src/Math-DHB-Numerical/PMProjectedOneVariableFunction.class.st +++ b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st @@ -6,7 +6,7 @@ Class { 'function', 'argument' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #creation } 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 844c4e193..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 99% rename from src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st rename to src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st index ee5ec788f..b67c8d77b 100644 --- a/src/Math-DHB-Numerical/PMScaledProbabilityDensityFunction.class.st +++ b/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st @@ -6,7 +6,7 @@ Class { 'count', 'binWidth' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #creation } diff --git a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st b/src/Math-Numerical/PMSeriesTermServer.class.st similarity index 85% rename from src/Math-DHB-Numerical/PMSeriesTermServer.class.st rename to src/Math-Numerical/PMSeriesTermServer.class.st index 94250e331..52db49989 100644 --- a/src/Math-DHB-Numerical/PMSeriesTermServer.class.st +++ b/src/Math-Numerical/PMSeriesTermServer.class.st @@ -5,7 +5,7 @@ Class { 'x', 'lastTerm' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #initialization } 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 1aba05384..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 ca75007e9..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 710a57e5c..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 98% rename from src/Math-DHB-Numerical/PMTrapezeIntegrator.class.st rename to src/Math-Numerical/PMTrapezeIntegrator.class.st index 409c3582e..f318c07fe 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 } 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 f03a3d065..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 99% rename from src/Math-DHB-Numerical/PMUniformDistribution.class.st rename to src/Math-Numerical/PMUniformDistribution.class.st index e1813aff0..b0c1f9d59 100644 --- a/src/Math-DHB-Numerical/PMUniformDistribution.class.st +++ b/src/Math-Numerical/PMUniformDistribution.class.st @@ -5,7 +5,7 @@ Class { 'lowLimit', 'highLimit' ], - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #public } diff --git a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st b/src/Math-Numerical/PMVectorAccumulator.class.st similarity index 95% rename from src/Math-DHB-Numerical/PMVectorAccumulator.class.st rename to src/Math-Numerical/PMVectorAccumulator.class.st index 761355d1f..dece9a968 100644 --- a/src/Math-DHB-Numerical/PMVectorAccumulator.class.st +++ b/src/Math-Numerical/PMVectorAccumulator.class.st @@ -13,7 +13,7 @@ Class { 'count', 'average' ], - #category : #'Math-DHB-Numerical-Math-UtilsAccumulator' + #category : #'Math-Numerical-Math-UtilsAccumulator' } { #category : #'instance creation' } diff --git a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st b/src/Math-Numerical/PMVectorProjectedFunction.class.st similarity index 97% rename from src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st rename to src/Math-Numerical/PMVectorProjectedFunction.class.st index 43e6756d5..3f1754a3b 100644 --- a/src/Math-DHB-Numerical/PMVectorProjectedFunction.class.st +++ b/src/Math-Numerical/PMVectorProjectedFunction.class.st @@ -1,7 +1,7 @@ Class { #name : #PMVectorProjectedFunction, #superclass : #PMProjectedOneVariableFunction, - #category : #'Math-DHB-Numerical' + #category : #'Math-Numerical' } { #category : #information } 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 8c3d982b0..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-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-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 8a5379b7f..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 e8a9445f1..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 5635dafff..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 98% rename from src/Math-Tests-DHB-Numerical/PMFloatingPointMachineTestCase.class.st rename to src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st index 7d9625560..506b9410c 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 } 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 1f83a52ee..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 99% rename from src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st rename to src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st index 33d96ad82..30d5595b4 100644 --- a/src/Math-Tests-DHB-Numerical/PMHistogramTestsAndBugs.class.st +++ b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'h' ], - #category : #'Math-Tests-DHB-Numerical' + #category : #'Math-Tests-Numerical' } { #category : #comment } 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 0bb5b2981..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 0896af13c..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 58f8a525c..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' } From f63ba44f5c02d52d8d2ee1e5edd78e516f30cecd Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 10:45:04 +0100 Subject: [PATCH 097/161] Remove all DHB in baseline --- .../BaselineOfPolyMath.class.st | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index abe8e806e..befbc20d5 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -31,35 +31,35 @@ BaselineOfPolyMath >> baseline: spec [ 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-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-DHB-Numerical' 'Math-Core-Process' 'Math-Matrix') ]; - package: 'Math-Complex' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Polynomials') ]; + 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-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-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-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-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-RandomDistributionBased' with: [ spec requires: #('Math-Numerical' 'Math-Polynomials') ]; package: 'Math-Series'; package: 'Math-StatisticalMoments' with: [ spec requires: #('Math-Core' 'Math-DistributionForHistogram') ]; package: 'Math-TSNE'; @@ -68,14 +68,13 @@ BaselineOfPolyMath >> baseline: spec [ 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-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-KernelSmoothing' with:[spec requires: #('Math-KernelSmoothing')]; - 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-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-Permutation' with: [ spec requires: #('Math-Permutation') ]; @@ -92,9 +91,9 @@ BaselineOfPolyMath >> baseline: spec [ 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: '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'); 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' 'Math-Tests-PrincipalComponentAnalysis' 'Math-Tests-KernelSmoothing' 'Math-Tests-Number-Extensions' 'Math-Tests-Permutation' 'Math-Tests-TSNE' 'Math-Tests-RandomDistributionBased'); + 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-RandomDistributionBased'); group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] From e3ee6e34bfdb3afffac30aacb7a262b26d6f5349 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 10:55:33 +0100 Subject: [PATCH 098/161] Missing packages in the baseline --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index befbc20d5..08120b5e2 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -68,6 +68,7 @@ BaselineOfPolyMath >> baseline: spec [ 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-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'; @@ -91,9 +92,9 @@ BaselineOfPolyMath >> baseline: spec [ 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-Numerical' 'Math-Random' 'Math-KDTree' 'Math-ODE' 'Math-ArbitraryPrecisionFloat' 'Math-FastFourierTransform' 'ExtendedNumberParser' 'Math-Quantile' 'Math-Physics-Constants' 'Math-Polynomials' 'Math-TSNE'); + 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-RandomDistributionBased' '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-RandomDistributionBased'); + 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-RandomDistributionBased' 'Math-Tests-Core-Process'); group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] From 0e2cd54cfefb98d2f70c11e005260530f961eb14 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 11:04:16 +0100 Subject: [PATCH 099/161] Missing Math-Tests-Core package --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 08120b5e2..d1b4caf11 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -68,6 +68,7 @@ BaselineOfPolyMath >> baseline: spec [ 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') ]; @@ -94,7 +95,7 @@ BaselineOfPolyMath >> baseline: spec [ 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-RandomDistributionBased' '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-RandomDistributionBased' 'Math-Tests-Core-Process'); + 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-RandomDistributionBased' 'Math-Tests-Core-Process' 'Math-Tests-Core'); group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] From 39f4a46e0bf14f736acaee52bd5570a7619b32f8 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 11:09:06 +0100 Subject: [PATCH 100/161] Remove all DHB (even in comments) --- .../ManifestMathCoreDistribution.class.st | 2 +- src/Math-Tests-Matrix/PMAdditionalTest.class.st | 2 +- src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st b/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st index 92dfc92c2..e18f60f78 100644 --- a/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st +++ b/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st @@ -9,5 +9,5 @@ Class { { #category : #'code-critics' } ManifestMathCoreDistribution class >> ruleRBCodeCruftLeftInMethodsRuleV1FalsePositive [ - ^ #(#(#(#RGMethodDefinition #(#'DhbProbabilityDensity class' #fromHistogram: #true)) #'2016-03-02T09:06:24.499812+01:00') ) + ^ #(#(#(#RGMethodDefinition #(#'PMProbabilityDensity class' #fromHistogram: #true)) #'2016-03-02T09:06:24.499812+01:00') ) ] 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-Numerical/PMHistogramTestsAndBugs.class.st b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st index 30d5595b4..79ba75a55 100644 --- a/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st +++ b/src/Math-Tests-Numerical/PMHistogramTestsAndBugs.class.st @@ -9,7 +9,7 @@ Class { { #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 } From 1205f0550fa9bdb481d6ebfad4aa155063c22652 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 11:24:18 +0100 Subject: [PATCH 101/161] Remove copyright comments --- .../PMMahalanobisCenter.class.st | 2 - .../PMMitchellMooreGenerator.class.st | 2 - .../PMGammaDistribution.class.st | 4 +- src/Math-FunctionFit/PMFunctionFit.class.st | 3 -- .../PMJacobiTransformation.class.st | 1 - .../PMLargestEigenValueFinder.class.st | 24 +++-------- src/Math-Numerical/Integer.extension.st | 4 +- src/Math-Numerical/Number.extension.st | 28 +++---------- .../PMLinearRegression.class.st | 4 +- .../PMNewtonZeroFinder.class.st | 4 +- ...PMProbabilityDistributionFunction.class.st | 8 +--- .../PMProjectedOneVariableFunction.class.st | 17 +------- ...MScaledProbabilityDensityFunction.class.st | 33 +++------------ .../PMTrapezeIntegrator.class.st | 4 +- .../PMUniformDistribution.class.st | 14 ++----- .../PMVectorProjectedFunction.class.st | 13 +----- src/Math-Polynomials/PMPolynomial.class.st | 3 +- src/Math-Quaternion/PMQuaternion.class.st | 17 +------- src/Math-Quaternion/PMQuaternion.extension.st | 17 +------- src/Math-Series/PMContinuedFraction.class.st | 4 +- .../PMFastStatisticalMoments.class.st | 15 ------- .../PMFixedStatisticalMoments.class.st | 7 ---- .../PMHistogram.class.st | 40 +++++-------------- .../PMStatisticalMoments.class.st | 22 +--------- 24 files changed, 44 insertions(+), 246 deletions(-) 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-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-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-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-Matrix/PMJacobiTransformation.class.st b/src/Math-Matrix/PMJacobiTransformation.class.st index cc3db88a7..924355ac1 100644 --- a/src/Math-Matrix/PMJacobiTransformation.class.st +++ b/src/Math-Matrix/PMJacobiTransformation.class.st @@ -34,7 +34,6 @@ PMJacobiTransformation class >> new [ { #category : #operation } PMJacobiTransformation >> evaluateIteration [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved" | indices | indices := self largestOffDiagonalIndices. self transformAt: ( indices at: 1) and: ( indices at: 2). 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-Numerical/Integer.extension.st b/src/Math-Numerical/Integer.extension.st index 0d9781605..aa381d423 100644 --- a/src/Math-Numerical/Integer.extension.st +++ b/src/Math-Numerical/Integer.extension.st @@ -9,8 +9,6 @@ Integer >> gamma [ { #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 index 522f034d8..31ef61b6a 100644 --- a/src/Math-Numerical/Number.extension.st +++ b/src/Math-Numerical/Number.extension.st @@ -2,8 +2,6 @@ Extension { #name : #Number } { #category : #'*Math-Numerical' } Number >> addPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 19/4/99 " ^aPolynomial addNumber: self ] @@ -16,8 +14,6 @@ Number >> beta: aNumber [ { #category : #'*Math-Numerical' } Number >> dividingPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 17/4/99 " ^aPolynomial timesNumber: (1 / self) ] @@ -29,17 +25,13 @@ Number >> equalsTo: aNumber [ { #category : #'*Math-Numerical' } Number >> errorFunction [ - "Answer the error function for the receiver. - (c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 11/2/99 " + "Answer the error function for the receiver." ^ PMErfApproximation new value: self ] { #category : #'*Math-Numerical' } Number >> gamma [ - "Compute the Gamma function for the receiver. - (c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 11/2/99 " + "Compute the Gamma function for the receiver." ^ self > 1 ifTrue: [ ^ PMLanczosFormula new gamma: self] ifFalse:[ self < 0 @@ -73,25 +65,19 @@ Number >> productWithMatrix: aMatrix [ { #category : #'*Math-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 " + "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. - (c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 17/2/99 " + "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 - (c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 17/2/99 " + "Answers a random number between 0 and the receiver." ^ PMMitchellMooreGenerator new floatValue ] @@ -107,14 +93,10 @@ Number >> relativelyEqualsTo: aNumber upTo: aSmallNumber [ { #category : #'*Math-Numerical' } Number >> subtractToPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 19/4/99 " ^aPolynomial addNumber: self negated ] { #category : #'*Math-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-Numerical/PMLinearRegression.class.st b/src/Math-Numerical/PMLinearRegression.class.st index 7d0d77f2d..f8e9e3977 100644 --- a/src/Math-Numerical/PMLinearRegression.class.st +++ b/src/Math-Numerical/PMLinearRegression.class.st @@ -17,9 +17,7 @@ Class { { #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-Numerical/PMNewtonZeroFinder.class.st b/src/Math-Numerical/PMNewtonZeroFinder.class.st index 5fcc828fc..bcc248c61 100644 --- a/src/Math-Numerical/PMNewtonZeroFinder.class.st +++ b/src/Math-Numerical/PMNewtonZeroFinder.class.st @@ -35,9 +35,7 @@ Class { { #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-Numerical/PMProbabilityDistributionFunction.class.st b/src/Math-Numerical/PMProbabilityDistributionFunction.class.st index 6c6867759..5019ea3cd 100644 --- a/src/Math-Numerical/PMProbabilityDistributionFunction.class.st +++ b/src/Math-Numerical/PMProbabilityDistributionFunction.class.st @@ -9,23 +9,17 @@ Class { { #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-Numerical/PMProjectedOneVariableFunction.class.st b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st index 5e8593da2..fd22a81dc 100644 --- a/src/Math-Numerical/PMProjectedOneVariableFunction.class.st +++ b/src/Math-Numerical/PMProjectedOneVariableFunction.class.st @@ -11,22 +11,17 @@ Class { { #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-Numerical/PMScaledProbabilityDensityFunction.class.st b/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st index b67c8d77b..9dba69d0a 100644 --- a/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st +++ b/src/Math-Numerical/PMScaledProbabilityDensityFunction.class.st @@ -11,9 +11,7 @@ Class { { #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-Numerical/PMTrapezeIntegrator.class.st b/src/Math-Numerical/PMTrapezeIntegrator.class.st index f318c07fe..da842e5df 100644 --- a/src/Math-Numerical/PMTrapezeIntegrator.class.st +++ b/src/Math-Numerical/PMTrapezeIntegrator.class.st @@ -50,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-Numerical/PMUniformDistribution.class.st b/src/Math-Numerical/PMUniformDistribution.class.st index b0c1f9d59..69d59ed63 100644 --- a/src/Math-Numerical/PMUniformDistribution.class.st +++ b/src/Math-Numerical/PMUniformDistribution.class.st @@ -10,16 +10,12 @@ Class { { #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-Numerical/PMVectorProjectedFunction.class.st b/src/Math-Numerical/PMVectorProjectedFunction.class.st index 3f1754a3b..bd632efcf 100644 --- a/src/Math-Numerical/PMVectorProjectedFunction.class.st +++ b/src/Math-Numerical/PMVectorProjectedFunction.class.st @@ -6,43 +6,32 @@ Class { { #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-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-Quaternion/PMQuaternion.class.st b/src/Math-Quaternion/PMQuaternion.class.st index 9ac93fb99..4f3d1fee1 100644 --- a/src/Math-Quaternion/PMQuaternion.class.st +++ b/src/Math-Quaternion/PMQuaternion.class.st @@ -185,11 +185,6 @@ PMQuaternion >> adaptToInteger: rcvr andSend: selector [ { #category : #'*Math-Quaternion' } PMQuaternion >> 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 ] @@ -254,8 +249,6 @@ PMQuaternion >> cosh [ { #category : #'*Math-Quaternion' } PMQuaternion >> dividingPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 17/4/99 " ^aPolynomial timesNumber: (1 / self) ] @@ -398,9 +391,7 @@ PMQuaternion >> printOn: aStream [ { #category : #'*Math-Quaternion' } PMQuaternion >> 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 " + "Answers a new vector product of the receiver with aVector." ^aVector collect: [ :each | each * self] ] @@ -581,8 +572,6 @@ PMQuaternion >> storeOn: aStream [ { #category : #'*Math-Quaternion' } PMQuaternion >> subtractToPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 19/4/99 " ^aPolynomial addNumber: self negated ] @@ -605,10 +594,6 @@ PMQuaternion >> tanh [ { #category : #'*Math-Quaternion' } PMQuaternion >> 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-Quaternion/PMQuaternion.extension.st b/src/Math-Quaternion/PMQuaternion.extension.st index 890210c8c..8c26825d1 100644 --- a/src/Math-Quaternion/PMQuaternion.extension.st +++ b/src/Math-Quaternion/PMQuaternion.extension.st @@ -2,26 +2,17 @@ Extension { #name : #PMQuaternion } { #category : #'*Math-Quaternion' } PMQuaternion >> 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' } PMQuaternion >> dividingPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 17/4/99 " ^aPolynomial timesNumber: (1 / self) ] { #category : #'*Math-Quaternion' } PMQuaternion >> 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 " + "Answers a new vector product of the receiver with aVector." ^aVector collect: [ :each | each * self] ] @@ -43,16 +34,10 @@ PMQuaternion >> random [ { #category : #'*Math-Quaternion' } PMQuaternion >> subtractToPolynomial: aPolynomial [ - "(c) Copyrights Didier BESSET, 1999, all rights reserved. - Initial code: 19/4/99 " ^aPolynomial addNumber: self negated ] { #category : #'*Math-Quaternion' } PMQuaternion >> 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-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 From 6e725bf08da222b9e750f408724543c53b6157c8 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 13:40:58 +0100 Subject: [PATCH 102/161] Rename tests to use CamelCase --- .../PMKolmogorovSmirnov1sampleTest.class.st | 16 ++++++++-------- .../PMKolmogorovSmirnov2sampleTest.class.st | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st index eea342466..7fe1a7cfa 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st @@ -1,5 +1,5 @@ Class { - #name : #PMKolmogorovSmirnov1sampleTest, + #name : #PMKolmogorovSmirnov1SampleTest, #superclass : #TestCase, #instVars : [ 'nd', @@ -9,13 +9,13 @@ Class { } { #category : #initialization } -PMKolmogorovSmirnov1sampleTest >> initialize [ +PMKolmogorovSmirnov1SampleTest >> initialize [ nd := PMNormalDistribution new. ks := PMKolmogorovSmirnov1Sample new ] { #category : #running } -PMKolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [ +PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ | n | ks populationDistribution: aDistribution. n := 0. @@ -27,7 +27,7 @@ PMKolmogorovSmirnov1sampleTest >> numberOfRejectionsFor: aDistribution [ ] { #category : #tests } -PMKolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [ +PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" | d | @@ -36,7 +36,7 @@ PMKolmogorovSmirnov1sampleTest >> testCorrectPopulationProbabilistic [ ] { #category : #tests } -PMKolmogorovSmirnov1sampleTest >> testRejectOfEqualityHypothesesForSampleVersusDistribution [ +PMKolmogorovSmirnov1SampleTest >> 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))" @@ -44,7 +44,7 @@ PMKolmogorovSmirnov1sampleTest >> testRejectOfEqualityHypothesesForSampleVersusD ] { #category : #tests } -PMKolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [ +PMKolmogorovSmirnov1SampleTest >> testWrongAverageProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen not too often" | d | @@ -53,7 +53,7 @@ PMKolmogorovSmirnov1sampleTest >> testWrongAverageProbabilistic [ ] { #category : #tests } -PMKolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [ +PMKolmogorovSmirnov1SampleTest >> testWrongDistributionProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" | d | @@ -66,7 +66,7 @@ PMKolmogorovSmirnov1sampleTest >> testWrongDistributionProbabilistic [ ] { #category : #tests } -PMKolmogorovSmirnov1sampleTest >> testWrongStandardDeviationProbabilistic [ +PMKolmogorovSmirnov1SampleTest >> testWrongStandardDeviationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" | d | diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st index 8ef63f618..b8ba0f872 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st @@ -1,5 +1,5 @@ Class { - #name : #PMKolmogorovSmirnov2sampleTest, + #name : #PMKolmogorovSmirnov2SampleTest, #superclass : #TestCase, #instVars : [ 'k' @@ -8,12 +8,12 @@ Class { } { #category : #initialization } -PMKolmogorovSmirnov2sampleTest >> initialize [ +PMKolmogorovSmirnov2SampleTest >> initialize [ k := PMKolmogorovSmirnov2Sample new ] { #category : #tests } -PMKolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ +PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ | nd ks | nd := PMNormalDistribution new. ks := PMKolmogorovSmirnov2Sample @@ -27,7 +27,7 @@ PMKolmogorovSmirnov2sampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ ] { #category : #tests } -PMKolmogorovSmirnov2sampleTest >> 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 +49,7 @@ PMKolmogorovSmirnov2sampleTest >> testSecondSmallSample [ ] { #category : #tests } -PMKolmogorovSmirnov2sampleTest >> testSmallSample [ +PMKolmogorovSmirnov2SampleTest >> testSmallSample [ "sample from http://www.math.montana.edu/~jobo/st431/ho2b.pdf" | d1 d2 | @@ -64,7 +64,7 @@ PMKolmogorovSmirnov2sampleTest >> testSmallSample [ ] { #category : #tests } -PMKolmogorovSmirnov2sampleTest >> testkdStatistic [ +PMKolmogorovSmirnov2SampleTest >> testkdStatistic [ "extreme case" | d1 | From 06ebdf55c51def26ff9f805390d4f31abb04f5a6 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 30 Apr 2019 16:43:08 +0100 Subject: [PATCH 103/161] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c5e36856..66adbca42 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ PolyMath is a Pharo project, similar to existing scientific libraries like NumPy - random number generators, - fuzzy algorithms, - KDE-trees, -- Didier Besset's numerical methods, +- Numerical methods, - Ordinary Differential Equation (ODE) solvers. A book about PolyMath called "PolyMath book" is available online: https://github.com/SquareBracketAssociates/PolyMath-book From 2eff2d4db13638e1d4b77b2c51aa1a937999937a Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 14:40:03 +0100 Subject: [PATCH 104/161] Rename initialize to setUp in some tests --- .../PMKolmogorovSmirnov1sampleTest.class.st | 12 ++++++------ .../PMKolmogorovSmirnov2sampleTest.class.st | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st index 7fe1a7cfa..c1edd1c9a 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st @@ -8,12 +8,6 @@ Class { #category : #'Math-Tests-KolmogorovSmirnov' } -{ #category : #initialization } -PMKolmogorovSmirnov1SampleTest >> initialize [ - nd := PMNormalDistribution new. - ks := PMKolmogorovSmirnov1Sample new -] - { #category : #running } PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ | n | @@ -26,6 +20,12 @@ PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ ^ n ] +{ #category : #initialization } +PMKolmogorovSmirnov1SampleTest >> setUp [ + nd := PMNormalDistribution new. + ks := PMKolmogorovSmirnov1Sample new +] + { #category : #tests } PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [ "is a probabilistic test that occasionally fails, but it should happen rarely" diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st index b8ba0f872..8e0b8fe12 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st @@ -8,7 +8,7 @@ Class { } { #category : #initialization } -PMKolmogorovSmirnov2SampleTest >> initialize [ +PMKolmogorovSmirnov2SampleTest >> setUp [ k := PMKolmogorovSmirnov2Sample new ] From fe59169f0f0058265f84daa3c4cfed3cee205d2d Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:11:13 +0100 Subject: [PATCH 105/161] - Remove print1On: print2On: methods and use properly printOn: - Rename PMKolmogorovSmirnov to PMKolmogorovSmirnovSample --- .../PMKolmogorovSmirnov1Sample.class.st | 22 ++++++------ .../PMKolmogorovSmirnov2Sample.class.st | 14 ++++---- ....st => PMKolmogorovSmirnovSample.class.st} | 35 +++++++------------ 3 files changed, 32 insertions(+), 39 deletions(-) rename src/Math-KolmogorovSmirnov/{PMKolmogorovSmirnov.class.st => PMKolmogorovSmirnovSample.class.st} (50%) diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st index 5051acb76..3eeea2e17 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' } @@ -72,12 +72,14 @@ 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..d717e93c3 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' } @@ -126,9 +126,11 @@ ksStatistic ifNil: [self ksStatistic ]. ] { #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' ]. ] From 9c9819501481301ccbb149576c0544ca9510dfca Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:21:18 +0100 Subject: [PATCH 106/161] Working on #62 rename TSNE => PMSTE --- src/Math-TSNE/ManifestMathTNSE.class.st | 14 ------ .../{TSNE.class.st => PMTSNE.class.st} | 50 +++++++++---------- src/Math-Tests-TSNE/TSNETest.class.st | 6 +-- 3 files changed, 28 insertions(+), 42 deletions(-) delete mode 100644 src/Math-TSNE/ManifestMathTNSE.class.st rename src/Math-TSNE/{TSNE.class.st => PMTSNE.class.st} (86%) 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/TSNE.class.st b/src/Math-TSNE/PMTSNE.class.st similarity index 86% rename from src/Math-TSNE/TSNE.class.st rename to src/Math-TSNE/PMTSNE.class.st index d5a0e517a..251da7c2a 100644 --- a/src/Math-TSNE/TSNE.class.st +++ b/src/Math-TSNE/PMTSNE.class.st @@ -6,7 +6,7 @@ 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, + #name : #PMTSNE, #superclass : #Object, #instVars : [ 'ndims', @@ -22,11 +22,11 @@ Class { 'eta', 'minGain' ], - #category : 'Math-TSNE' + #category : #'Math-TSNE' } { #category : #examples } -TSNE class >> example1 [ +PMTSNE class >> example1 [ | points | points := self gridDataGeneratorOf: 10. ^ (self new) @@ -39,7 +39,7 @@ TSNE class >> example1 [ ] { #category : #'as yet unclassified' } -TSNE class >> gridDataGeneratorOf: size [ +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" @@ -53,7 +53,7 @@ TSNE class >> gridDataGeneratorOf: size [ ] { #category : #accessing } -TSNE >> computePValues [ +PMTSNE >> computePValues [ " #Compute P-values P = x2p(X, 1e-5, perplexity); @@ -72,7 +72,7 @@ p := p max: 1e-12. ] { #category : #'as yet unclassified' } -TSNE >> computePairwiseAffinities [ +PMTSNE >> 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)); @@ -90,7 +90,7 @@ TSNE >> computePairwiseAffinities [ ] { #category : #'as yet unclassified' } -TSNE >> computePairwiseDistances [ +PMTSNE >> computePairwiseDistances [ | sumX d tmp| sumX := (x dot: x) sum. tmp := (x * (x transpose)) * (-2). @@ -100,27 +100,27 @@ TSNE >> computePairwiseDistances [ ] { #category : #running } -TSNE >> epsilon: aFloat [ +PMTSNE >> epsilon: aFloat [ epsilon := aFloat ] { #category : #'as yet unclassified' } -TSNE >> initialDims [ +PMTSNE >> initialDims [ ^initialdims ] { #category : #'as yet unclassified' } -TSNE >> initialDims: aFloat [ +PMTSNE >> initialDims: aFloat [ initialdims := aFloat ] { #category : #'as yet unclassified' } -TSNE >> initialDimsDefaultValue [ +PMTSNE >> initialDimsDefaultValue [ ^ 50 ] { #category : #initialization } -TSNE >> initialize [ +PMTSNE >> initialize [ maxIter := 1000. initialMomentum := 0.5. finalMomentum := 0.8. @@ -130,14 +130,14 @@ TSNE >> initialize [ ] { #category : #initialization } -TSNE >> initializeUninitializedParameters [ +PMTSNE >> initializeUninitializedParameters [ perplexity ifNil: [ perplexity := self perplexityDefaultValue ]. ndims ifNil: [ ndims := self ndimsDefaultValue ]. initialdims ifNil: [ initialdims := self initialDimsDefaultValue ] ] { #category : #initialization } -TSNE >> initializeYWithRandomValues [ +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" @@ -154,32 +154,32 @@ TSNE >> initializeYWithRandomValues [ ] { #category : #accessing } -TSNE >> ndims [ +PMTSNE >> ndims [ ^ ndims ] { #category : #'as yet unclassified' } -TSNE >> ndimsDefaultValue [ +PMTSNE >> ndimsDefaultValue [ ^ 2 ] { #category : #accessing } -TSNE >> perplexity [ +PMTSNE >> perplexity [ ^ perplexity ] { #category : #accessing } -TSNE >> perplexity: aFloat [ +PMTSNE >> perplexity: aFloat [ perplexity := aFloat ] { #category : #'as yet unclassified' } -TSNE >> perplexityDefaultValue [ +PMTSNE >> perplexityDefaultValue [ ^ 30.0 ] { #category : #running } -TSNE >> runPcaOnX [ +PMTSNE >> runPcaOnX [ "Runs PCA on X in order to reduce its dimensionality to initialdims dimensions. print ""Preprocessing the data using PCA..."" @@ -200,7 +200,7 @@ TSNE >> runPcaOnX [ ] { #category : #accessing } -TSNE >> start [ +PMTSNE >> start [ self initializeUninitializedParameters. self runPcaOnX. self initializeYWithRandomValues. @@ -208,12 +208,12 @@ TSNE >> start [ ] { #category : #'stepping and presenter' } -TSNE >> step [ +PMTSNE >> step [ self computePairwiseAffinities ] { #category : #'as yet unclassified' } -TSNE >> x2p [ +PMTSNE >> x2p [ | p d beta logU n betaMin betaMax| n := x numberOfRows. d := self computePairwiseDistances. @@ -228,11 +228,11 @@ TSNE >> x2p [ ] { #category : #accessing } -TSNE >> x: aPMMatrix [ +PMTSNE >> x: aPMMatrix [ x := aPMMatrix ] { #category : #accessing } -TSNE >> y [ +PMTSNE >> y [ ^ y ] diff --git a/src/Math-Tests-TSNE/TSNETest.class.st b/src/Math-Tests-TSNE/TSNETest.class.st index e2de10199..c3223916f 100644 --- a/src/Math-Tests-TSNE/TSNETest.class.st +++ b/src/Math-Tests-TSNE/TSNETest.class.st @@ -7,7 +7,7 @@ Class { { #category : #tests } TSNETest >> testComputePairwiseDistances [ | t | - t := (TSNE + t := (PMTSNE new) x: (PMMatrix rows: #(#(1 2) #(3 4))). self assert: t computePairwiseDistances equals: (PMMatrix rows: #(#(0 8) #(8 0))) @@ -16,9 +16,9 @@ TSNETest >> testComputePairwiseDistances [ { #category : #tests } TSNETest >> testInitialDimsSetByDefaultWithFifty [ | t | - t := TSNE + t := PMTSNE new - x: (TSNE gridDataGeneratorOf: 5); + x: (PMTSNE gridDataGeneratorOf: 5); start. self assert: t initialDims equals: 50 ] From 6970cfb17db5154fbdacdbca927bcf5aa3a3404a Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:33:06 +0100 Subject: [PATCH 107/161] - Remove Manifest classes - work on #62 to rename classes with PM prefix --- .../ManifestMathCoreDistribution.class.st | 13 -- src/Math-Core/ManifestMathCore.class.st | 8 - ...ifestMathDistributionForHistogram.class.st | 8 - src/Math-Matrix/ManifestMathMatrix.class.st | 23 --- .../ManifestMathPermutation.class.st | 38 ----- ...estMathPrincipalComponentAnalysis.class.st | 8 - src/Math-Random/ManifestMathRandom.class.st | 8 - ...yTest.class.st => PMAccuracyTest.class.st} | 82 +++++----- ...lass.st => PMAccuracyTestExample.class.st} | 44 +++--- ...=> PMArbitraryPrecisionFloatTest.class.st} | 144 +++++++++--------- .../PMManifestMathTestMatrix.class.st | 8 - ...ass.st => PMNumberExtensionsTest.class.st} | 6 +- ...{TSNETest.class.st => PMTSNETest.class.st} | 6 +- 13 files changed, 141 insertions(+), 255 deletions(-) delete mode 100644 src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st delete mode 100644 src/Math-Core/ManifestMathCore.class.st delete mode 100644 src/Math-DistributionForHistogram/ManifestMathDistributionForHistogram.class.st delete mode 100644 src/Math-Matrix/ManifestMathMatrix.class.st delete mode 100644 src/Math-Permutation/ManifestMathPermutation.class.st delete mode 100644 src/Math-PrincipalComponentAnalysis/ManifestMathPrincipalComponentAnalysis.class.st delete mode 100644 src/Math-Random/ManifestMathRandom.class.st rename src/Math-Tests-Accuracy/{AccuracyTest.class.st => PMAccuracyTest.class.st} (83%) rename src/Math-Tests-Accuracy/{AccuracyTestExample.class.st => PMAccuracyTestExample.class.st} (74%) rename src/Math-Tests-ArbitraryPrecisionFloat/{ArbitraryPrecisionFloatTest.class.st => PMArbitraryPrecisionFloatTest.class.st} (86%) delete mode 100644 src/Math-Tests-Matrix/PMManifestMathTestMatrix.class.st rename src/Math-Tests-Number-Extensions/{NumberExtensionsTest.class.st => PMNumberExtensionsTest.class.st} (78%) rename src/Math-Tests-TSNE/{TSNETest.class.st => PMTSNETest.class.st} (76%) diff --git a/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st b/src/Math-Core-Distribution/ManifestMathCoreDistribution.class.st deleted file mode 100644 index e18f60f78..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 #(#'PMProbabilityDensity class' #fromHistogram: #true)) #'2016-03-02T09:06:24.499812+01:00') ) -] 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-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-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-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-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-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-Tests-Accuracy/AccuracyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st similarity index 83% rename from src/Math-Tests-Accuracy/AccuracyTest.class.st rename to src/Math-Tests-Accuracy/PMAccuracyTest.class.st index 9d697131e..d56b08d84 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,12 @@ AccuracyTest >> testArgumentAt [ ] { #category : #tests } -AccuracyTest >> testArgumentError [ +PMAccuracyTest >> 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 +53,7 @@ AccuracyTest >> testAsArray [ ] { #category : #tests } -AccuracyTest >> testCalcDeviationsInMax [ +PMAccuracyTest >> testCalcDeviationsInMax [ | r c | c := #(#(1 2 3) #(2 3 6)). r := {(3 / 2). @@ -74,7 +74,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 +88,7 @@ AccuracyTest >> testCalcErrorOfRealResult [ ] { #category : #tests } -AccuracyTest >> testDataTree [ +PMAccuracyTest >> testDataTree [ | s | a run. self assert: (a dataTree atPath: #('iterations')) equals: 1. @@ -126,14 +126,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 +145,7 @@ AccuracyTest >> testExtractFromResultsWhichOnlyOne [ ] { #category : #tests } -AccuracyTest >> testExtremeCollectionmax [ +PMAccuracyTest >> testExtremeCollectionmax [ | c | c := #(4 4 2). self @@ -163,7 +163,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 +175,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 +186,7 @@ AccuracyTest >> testFormatTypePostfix [ ] { #category : #tests } -AccuracyTest >> testFormatTypePostfixTree [ +PMAccuracyTest >> testFormatTypePostfixTree [ | t | t := KeyedTree new. self @@ -206,7 +206,7 @@ AccuracyTest >> testFormatTypePostfixTree [ ] { #category : #tests } -AccuracyTest >> testGetters [ +PMAccuracyTest >> testGetters [ | r | r := a testGetterAaa. self @@ -220,7 +220,7 @@ AccuracyTest >> testGetters [ ] { #category : #tests } -AccuracyTest >> testIfSeveralterations [ +PMAccuracyTest >> testIfSeveralterations [ a iterations: 2. self assert: (a ifSeveralterations: [ 1 ]) equals: 1. a iterations: 1. @@ -228,7 +228,7 @@ AccuracyTest >> testIfSeveralterations [ ] { #category : #tests } -AccuracyTest >> testIterations [ +PMAccuracyTest >> testIterations [ | s d | a iterations: 2; @@ -247,7 +247,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 +255,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 +264,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 +272,16 @@ AccuracyTest >> testParameterAt [ ] { #category : #tests } -AccuracyTest >> testParameterError [ +PMAccuracyTest >> 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 +289,24 @@ 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') + self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample') ] { #category : #tests } -AccuracyTest >> testResultError [ +PMAccuracyTest >> testResultError [ self should: [a testResultError ]raise: Error ] { #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 +337,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 +345,7 @@ AccuracyTest >> testRun [ assert: (a report beginsWith: - 'Report for: AccuracyTestExample + 'Report for: PMAccuracyTestExample test Bbb'). a run: #('Ccc' 'Eee'). self @@ -354,7 +354,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 +364,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 +378,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 74% rename from src/Math-Tests-Accuracy/AccuracyTestExample.class.st rename to src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st index 343304f04..f536164d0 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,36 @@ 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 [ +PMAccuracyTestExample >> 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 [ +PMAccuracyTestExample >> testParameterError [ self parameter: #(#(1) #(2)). ] { #category : #private } -AccuracyTestExample >> testResultError [ +PMAccuracyTestExample >> testResultError [ self result:#(1). ] diff --git a/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st b/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st similarity index 86% rename from src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st rename to src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st index c92a8b8f4..76afd69fc 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,13 +152,13 @@ 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 [ | badArcCos | badArcCos := self checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie forFunction: #arcCos. @@ -166,13 +166,13 @@ ArbitraryPrecisionFloatTest >> testArcCos [ ] { #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 [ | badArcSin | badArcSin := self checkDoublePrecisionSerieVsFloat: self inverseTrigonometricSerie forFunction: #arcSin. @@ -180,13 +180,13 @@ ArbitraryPrecisionFloatTest >> testArcSin [ ] { #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 [ | badArcTan serie | serie := ((-50 to: 50) collect: [:e | (e / 10) asFloat]). @@ -195,7 +195,7 @@ ArbitraryPrecisionFloatTest >> testArcTan [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> testArcTan2 [ +PMArbitraryPrecisionFloatTest >> testArcTan2 [ -5 to: 5 by: 4/10 do: [:y | | yf yd | @@ -209,13 +209,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 +224,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 +246,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 +264,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 +287,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 +318,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 +336,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 +354,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,7 +372,7 @@ ArbitraryPrecisionFloatTest >> testCoercingSum [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> testCos [ +PMArbitraryPrecisionFloatTest >> testCos [ | badCos | badCos := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #cos. @@ -380,13 +380,13 @@ ArbitraryPrecisionFloatTest >> testCos [ ] { #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 +403,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 +427,7 @@ ArbitraryPrecisionFloatTest >> testEqual [ ] { #category : #'testing-functions' } -ArbitraryPrecisionFloatTest >> testExp [ +PMArbitraryPrecisionFloatTest >> testExp [ | badExp serie | serie := ((-20 to: 20) collect: [:e |e asFloat]). @@ -436,7 +436,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 +449,7 @@ ArbitraryPrecisionFloatTest >> testExpLn [ ] { #category : #'testing-compare' } -ArbitraryPrecisionFloatTest >> testGreaterThan [ +PMArbitraryPrecisionFloatTest >> testGreaterThan [ self assert: zero < one. self deny: one > two. @@ -466,7 +466,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 +482,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 +530,7 @@ ArbitraryPrecisionFloatTest >> testIEEEArithmeticVersusIntegerAndFraction [ ] { #category : #'testing-coercing' } -ArbitraryPrecisionFloatTest >> testInfinityAndNaN [ +PMArbitraryPrecisionFloatTest >> testInfinityAndNaN [ | inf nan | inf := Float infinity. nan := Float nan. @@ -562,14 +562,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 +586,7 @@ ArbitraryPrecisionFloatTest >> testLessThan [ ] { #category : #'testing-functions' } -ArbitraryPrecisionFloatTest >> testLn [ +PMArbitraryPrecisionFloatTest >> testLn [ | badLn serie | serie := ((1 to: 100) collect: [:e |e asFloat]). @@ -595,12 +595,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 +617,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 +626,7 @@ ArbitraryPrecisionFloatTest >> testNegated [ ] { #category : #'testing-compare' } -ArbitraryPrecisionFloatTest >> testNegative [ +PMArbitraryPrecisionFloatTest >> testNegative [ self deny: zero negative. self deny: two negative. @@ -634,14 +634,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 +649,7 @@ ArbitraryPrecisionFloatTest >> testPositive [ ] { #category : #'testing-converting' } -ArbitraryPrecisionFloatTest >> testPrintAndEvaluate [ +PMArbitraryPrecisionFloatTest >> testPrintAndEvaluate [ "seconds" @@ -684,7 +684,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 +714,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 +727,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,7 +739,7 @@ ArbitraryPrecisionFloatTest >> testRoundToNearestEvenAgainstIEEEDouble [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> testSin [ +PMArbitraryPrecisionFloatTest >> testSin [ | badSin | badSin := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #sin. @@ -747,7 +747,7 @@ ArbitraryPrecisionFloatTest >> testSin [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> testSincos [ +PMArbitraryPrecisionFloatTest >> testSincos [ self trigonometricSerie do: [:aFloat | | x sc s c | @@ -762,13 +762,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 +780,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 +800,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,7 +815,7 @@ ArbitraryPrecisionFloatTest >> testSum [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> testTan [ +PMArbitraryPrecisionFloatTest >> testTan [ | badTan | badTan := self checkDoublePrecisionSerieVsFloat: self trigonometricSerie forFunction: #tan. @@ -823,31 +823,31 @@ ArbitraryPrecisionFloatTest >> testTan [ ] { #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 +857,6 @@ ArbitraryPrecisionFloatTest >> testZeroOne [ ] { #category : #'testing-trigonometry' } -ArbitraryPrecisionFloatTest >> trigonometricSerie [ +PMArbitraryPrecisionFloatTest >> trigonometricSerie [ ^(-720 to: 720) collect: [:i | i asFloat degreesToRadians] ] 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-Number-Extensions/NumberExtensionsTest.class.st b/src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st similarity index 78% rename from src/Math-Tests-Number-Extensions/NumberExtensionsTest.class.st rename to src/Math-Tests-Number-Extensions/PMNumberExtensionsTest.class.st index 3d09246f8..029ddc183 100644 --- a/src/Math-Tests-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-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-TSNE/TSNETest.class.st b/src/Math-Tests-TSNE/PMTSNETest.class.st similarity index 76% rename from src/Math-Tests-TSNE/TSNETest.class.st rename to src/Math-Tests-TSNE/PMTSNETest.class.st index c3223916f..c76c1cdd3 100644 --- a/src/Math-Tests-TSNE/TSNETest.class.st +++ b/src/Math-Tests-TSNE/PMTSNETest.class.st @@ -1,11 +1,11 @@ Class { - #name : #TSNETest, + #name : #PMTSNETest, #superclass : #TestCase, #category : #'Math-Tests-TSNE' } { #category : #tests } -TSNETest >> testComputePairwiseDistances [ +PMTSNETest >> testComputePairwiseDistances [ | t | t := (PMTSNE new) @@ -14,7 +14,7 @@ TSNETest >> testComputePairwiseDistances [ ] { #category : #tests } -TSNETest >> testInitialDimsSetByDefaultWithFifty [ +PMTSNETest >> testInitialDimsSetByDefaultWithFifty [ | t | t := PMTSNE new From fe07afebaecf286bf7c00e9075578fee45348194 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:45:15 +0100 Subject: [PATCH 108/161] Close #62 --- src/Math-Accuracy-ODE/PMODEAccuracy.class.st | 78 +++++++++--------- .../PMExplicitBenchmark.class.st | 18 ++-- .../PMExplicitMultiBenchmark.class.st | 14 ++-- .../PMImplicitBenchmark.class.st | 10 +-- .../PMImplicitMultiBenchmark.class.st | 26 +++--- src/Math-ODE/ExplicitSolver.class.st | 21 ----- src/Math-ODE/ImplicitSolver.class.st | 22 ----- ...B2Solver.class.st => PMAB2Solver.class.st} | 24 +++--- ...Stepper.class.st => PMAB2Stepper.class.st} | 16 ++-- ...B3Solver.class.st => PMAB3Solver.class.st} | 24 +++--- ...Stepper.class.st => PMAB3Stepper.class.st} | 16 ++-- ...B4Solver.class.st => PMAB4Solver.class.st} | 24 +++--- ...Stepper.class.st => PMAB4Stepper.class.st} | 16 ++-- ...M3Solver.class.st => PMAM3Solver.class.st} | 24 +++--- ...Stepper.class.st => PMAM3Stepper.class.st} | 16 ++-- ...M4Solver.class.st => PMAM4Solver.class.st} | 24 +++--- ...Stepper.class.st => PMAM4Stepper.class.st} | 16 ++-- ...2Solver.class.st => PMBDF2Solver.class.st} | 24 +++--- ...tepper.class.st => PMBDF2Stepper.class.st} | 12 +-- ...3Solver.class.st => PMBDF3Solver.class.st} | 24 +++--- ...tepper.class.st => PMBDF3Stepper.class.st} | 12 +-- ...4Solver.class.st => PMBDF4Solver.class.st} | 24 +++--- ...tepper.class.st => PMBDF4Stepper.class.st} | 12 +-- ...ss.st => PMButcherTableauStepper.class.st} | 36 ++++---- ....class.st => PMExplicitAnnouncer.class.st} | 4 +- ...ass.st => PMExplicitMultiStepper.class.st} | 6 +- src/Math-ODE/PMExplicitSolver.class.st | 21 +++++ ... => PMExplicitSolverAnnouncement.class.st} | 12 +-- ...st => PMExplicitSolverSubscriber.class.st} | 28 +++---- ...er.class.st => PMExplicitStepper.class.st} | 16 ++-- ...tem.class.st => PMExplicitSystem.class.st} | 6 +- ...tepper.class.st => PMHeunStepper.class.st} | 12 +-- ....class.st => PMImplicitAnnouncer.class.st} | 4 +- ...s.st => PMImplicitMidpointSolver.class.st} | 12 +-- ....st => PMImplicitMidpointStepper.class.st} | 12 +-- ...ass.st => PMImplicitMultiStepper.class.st} | 6 +- src/Math-ODE/PMImplicitSolver.class.st | 22 +++++ ... => PMImplicitSolverAnnouncement.class.st} | 12 +-- ...er.class.st => PMImplicitStepper.class.st} | Bin 2659 -> 2692 bytes ...tem.class.st => PMImplicitSystem.class.st} | 8 +- ...er.class.st => PMMidpointStepper.class.st} | 12 +-- ...epper.class.st => PMMultiStepper.class.st} | 6 +- ...DESolver.class.st => PMODESolver.class.st} | 38 ++++----- ...DESystem.class.st => PMODESystem.class.st} | 12 +-- ....class.st => PMRungeKuttaStepper.class.st} | 12 +-- ...s.st => PMSimpleSymplecticSystem.class.st} | 6 +- ...rder.class.st => PMStateRecorder.class.st} | 24 +++--- ...tateTime.class.st => PMStateTime.class.st} | 16 ++-- .../{Stepper.class.st => PMStepper.class.st} | 20 ++--- ...m.class.st => PMSymplecticSystem.class.st} | 26 +++--- ...class.st => PMTranscriptRecorder.class.st} | 16 ++-- ...r.class.st => PMTrapezoidStepper.class.st} | 16 ++-- src/Math-Tests-ODE/PMAB2SolverTest.class.st | 24 +++--- src/Math-Tests-ODE/PMAB2StepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMAB3SolverTest.class.st | 24 +++--- src/Math-Tests-ODE/PMAB3StepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMAB4SolverTest.class.st | 18 ++-- src/Math-Tests-ODE/PMAB4StepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMAM3SolverTest.class.st | 18 ++-- src/Math-Tests-ODE/PMAM3StepperTest.class.st | 26 +++--- src/Math-Tests-ODE/PMAM4SolverTest.class.st | 18 ++-- src/Math-Tests-ODE/PMAM4StepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMBDF2SolverTest.class.st | 24 +++--- src/Math-Tests-ODE/PMBDF2StepperTest.class.st | 26 +++--- src/Math-Tests-ODE/PMBDF3SolverTest.class.st | 18 ++-- src/Math-Tests-ODE/PMBDF3StepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMBDF4SolverTest.class.st | 18 ++-- src/Math-Tests-ODE/PMBDF4StepperTest.class.st | 20 ++--- .../PMBeckwardEulerSolverTest.class.st | 18 ++-- .../PMBeckwardEulerStepperTest.class.st | 20 ++--- src/Math-Tests-ODE/PMEulerSolverTest.class.st | 18 ++-- .../PMEulerStepperTest.class.st | 16 ++-- src/Math-Tests-ODE/PMHeunStepperTest.class.st | 26 +++--- .../PMImplicitMidpointSolverTest.class.st | 6 +- .../PMImplicitMidpointStepperTest.class.st | 26 +++--- .../PMMidpointSolverTest.class.st | 30 +++---- .../PMMidpointStepperTest.class.st | 32 +++---- src/Math-Tests-ODE/PMODESystemTest.class.st | 2 +- .../PMRungeKuttaSolverTest.class.st | 30 +++---- .../PMRungeKuttaStepperTest.class.st | 28 +++---- src/Math-Tests-ODE/PMStepperTest.class.st | 10 +-- .../PMTrapezoidSolverTest.class.st | 18 ++-- .../PMTrapezoidStepperTest.class.st | 20 ++--- 83 files changed, 776 insertions(+), 776 deletions(-) delete mode 100644 src/Math-ODE/ExplicitSolver.class.st delete mode 100644 src/Math-ODE/ImplicitSolver.class.st rename src/Math-ODE/{AB2Solver.class.st => PMAB2Solver.class.st} (82%) rename src/Math-ODE/{AB2Stepper.class.st => PMAB2Stepper.class.st} (68%) rename src/Math-ODE/{AB3Solver.class.st => PMAB3Solver.class.st} (86%) rename src/Math-ODE/{AB3Stepper.class.st => PMAB3Stepper.class.st} (69%) rename src/Math-ODE/{AB4Solver.class.st => PMAB4Solver.class.st} (88%) rename src/Math-ODE/{AB4Stepper.class.st => PMAB4Stepper.class.st} (67%) rename src/Math-ODE/{AM3Solver.class.st => PMAM3Solver.class.st} (82%) rename src/Math-ODE/{AM3Stepper.class.st => PMAM3Stepper.class.st} (83%) rename src/Math-ODE/{AM4Solver.class.st => PMAM4Solver.class.st} (86%) rename src/Math-ODE/{AM4Stepper.class.st => PMAM4Stepper.class.st} (81%) rename src/Math-ODE/{BDF2Solver.class.st => PMBDF2Solver.class.st} (81%) rename src/Math-ODE/{BDF2Stepper.class.st => PMBDF2Stepper.class.st} (73%) rename src/Math-ODE/{BDF3Solver.class.st => PMBDF3Solver.class.st} (86%) rename src/Math-ODE/{BDF3Stepper.class.st => PMBDF3Stepper.class.st} (70%) rename src/Math-ODE/{BDF4Solver.class.st => PMBDF4Solver.class.st} (88%) rename src/Math-ODE/{BDF4Stepper.class.st => PMBDF4Stepper.class.st} (72%) rename src/Math-ODE/{ButcherTableauStepper.class.st => PMButcherTableauStepper.class.st} (72%) rename src/Math-ODE/{ExplicitAnnouncer.class.st => PMExplicitAnnouncer.class.st} (71%) rename src/Math-ODE/{ExplicitMultiStepper.class.st => PMExplicitMultiStepper.class.st} (70%) create mode 100644 src/Math-ODE/PMExplicitSolver.class.st rename src/Math-ODE/{ExplicitSolverAnnouncement.class.st => PMExplicitSolverAnnouncement.class.st} (59%) rename src/Math-ODE/{ExplicitSolverSubscriber.class.st => PMExplicitSolverSubscriber.class.st} (63%) rename src/Math-ODE/{ExplicitStepper.class.st => PMExplicitStepper.class.st} (83%) rename src/Math-ODE/{ExplicitSystem.class.st => PMExplicitSystem.class.st} (92%) rename src/Math-ODE/{HeunStepper.class.st => PMHeunStepper.class.st} (80%) rename src/Math-ODE/{ImplicitAnnouncer.class.st => PMImplicitAnnouncer.class.st} (71%) rename src/Math-ODE/{ImplicitMidpointSolver.class.st => PMImplicitMidpointSolver.class.st} (71%) rename src/Math-ODE/{ImplicitMidpointStepper.class.st => PMImplicitMidpointStepper.class.st} (76%) rename src/Math-ODE/{ImplicitMultiStepper.class.st => PMImplicitMultiStepper.class.st} (70%) create mode 100644 src/Math-ODE/PMImplicitSolver.class.st rename src/Math-ODE/{ImplicitSolverAnnouncement.class.st => PMImplicitSolverAnnouncement.class.st} (60%) rename src/Math-ODE/{ImplicitStepper.class.st => PMImplicitStepper.class.st} (82%) rename src/Math-ODE/{ImplicitSystem.class.st => PMImplicitSystem.class.st} (75%) rename src/Math-ODE/{MidpointStepper.class.st => PMMidpointStepper.class.st} (74%) rename src/Math-ODE/{MultiStepper.class.st => PMMultiStepper.class.st} (94%) rename src/Math-ODE/{ODESolver.class.st => PMODESolver.class.st} (77%) rename src/Math-ODE/{ODESystem.class.st => PMODESystem.class.st} (73%) rename src/Math-ODE/{RungeKuttaStepper.class.st => PMRungeKuttaStepper.class.st} (82%) rename src/Math-ODE/{SimpleSymplecticSystem.class.st => PMSimpleSymplecticSystem.class.st} (83%) rename src/Math-ODE/{StateRecorder.class.st => PMStateRecorder.class.st} (63%) rename src/Math-ODE/{StateTime.class.st => PMStateTime.class.st} (76%) rename src/Math-ODE/{Stepper.class.st => PMStepper.class.st} (80%) rename src/Math-ODE/{SymplecticSystem.class.st => PMSymplecticSystem.class.st} (73%) rename src/Math-ODE/{TranscriptRecorder.class.st => PMTranscriptRecorder.class.st} (73%) rename src/Math-ODE/{TrapezoidStepper.class.st => PMTrapezoidStepper.class.st} (81%) 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-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-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 82% rename from src/Math-ODE/ImplicitStepper.class.st rename to src/Math-ODE/PMImplicitStepper.class.st index eeb0e8f41e749f090f20e95aa35f7d45d83e9e1e..6d0e0f53d62fc35f381508150d42f39fb1994710 100644 GIT binary patch delta 134 zcmaDX(jvM+he@yb(4xalhZ=ymJ2OkcRv{(rFtU(>zCua`LS(WB(-Nit-^p*76eRIvd6h$z%0jbURm=7?5=y|MZV48*f0hoTm HQO^hfb8R%K delta 102 zcmZn>eJrv;he>A9p@u`pV!G?&K3RVh}t(Z+G7c#d^-p#7DS(#-T% 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-Tests-ODE/PMAB2SolverTest.class.st b/src/Math-Tests-ODE/PMAB2SolverTest.class.st index 0eb7f29cc..972ba657b 100644 --- a/src/Math-Tests-ODE/PMAB2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB2SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -20,9 +20,9 @@ PMAB2SolverTest >> testSimpleSystem2 [ 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). @@ -32,10 +32,10 @@ PMAB2SolverTest >> testSimpleSystem3 [ 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). @@ -45,14 +45,14 @@ PMAB2SolverTest >> testSimpleSystem4 [ 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/PMAB2StepperTest.class.st b/src/Math-Tests-ODE/PMAB2StepperTest.class.st index 1424df3bc..2e9053056 100644 --- a/src/Math-Tests-ODE/PMAB2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB2StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMAB2StepperTest >> testOrderIsTwo [ - self assert: AB2Stepper order equals: 2 + self assert: PMAB2Stepper order equals: 2 ] { #category : #'tests-stepping' } 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. @@ -32,10 +32,10 @@ PMAB2StepperTest >> testSimpleSystem [ 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. @@ -59,9 +59,9 @@ PMAB2StepperTest >> testSimpleSystem2 [ 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/PMAB3SolverTest.class.st b/src/Math-Tests-ODE/PMAB3SolverTest.class.st index 782d0510f..02c96ab29 100644 --- a/src/Math-Tests-ODE/PMAB3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB3SolverTest.class.st @@ -8,10 +8,10 @@ Class { 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. @@ -35,9 +35,9 @@ PMAB3SolverTest >> testSimpleSystem2 [ 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. @@ -61,11 +61,11 @@ PMAB3SolverTest >> testSimpleSystem3 [ 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. @@ -82,15 +82,15 @@ PMAB3SolverTest >> testSimpleSystem4 [ 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/PMAB3StepperTest.class.st b/src/Math-Tests-ODE/PMAB3StepperTest.class.st index b46b9a416..ae66d20cd 100644 --- a/src/Math-Tests-ODE/PMAB3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB3StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMAB3StepperTest >> testOrderIsThree [ - self assert: AB3Stepper order equals: 3 + self assert: PMAB3Stepper order equals: 3 ] { #category : #'tests-stepping' } 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. @@ -32,10 +32,10 @@ PMAB3StepperTest >> testSimpleSystem [ 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. @@ -59,9 +59,9 @@ PMAB3StepperTest >> testSimpleSystem2 [ 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/PMAB4SolverTest.class.st b/src/Math-Tests-ODE/PMAB4SolverTest.class.st index b2f4df603..b360760f9 100644 --- a/src/Math-Tests-ODE/PMAB4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAB4SolverTest.class.st @@ -8,10 +8,10 @@ Class { 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. @@ -35,9 +35,9 @@ PMAB4SolverTest >> testSimpleSystem2 [ 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. @@ -82,15 +82,15 @@ PMAB4SolverTest >> testSimpleSystem3 [ 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/PMAB4StepperTest.class.st b/src/Math-Tests-ODE/PMAB4StepperTest.class.st index 9b46697f7..f766fcd79 100644 --- a/src/Math-Tests-ODE/PMAB4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAB4StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMAB4StepperTest >> testOrderIsFour [ - self assert: AB4Stepper order equals: 4 + self assert: PMAB4Stepper order equals: 4 ] { #category : #'tests-stepping' } 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. @@ -32,10 +32,10 @@ PMAB4StepperTest >> testSimpleSystem [ 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. @@ -59,9 +59,9 @@ PMAB4StepperTest >> testSimpleSystem2 [ 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/PMAM3SolverTest.class.st b/src/Math-Tests-ODE/PMAM3SolverTest.class.st index 527c6067a..3b8f7d4d8 100644 --- a/src/Math-Tests-ODE/PMAM3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM3SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -20,9 +20,9 @@ PMAM3SolverTest >> testSimpleSystem2 [ 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. @@ -60,15 +60,15 @@ PMAM3SolverTest >> testSimpleSystem3 [ 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/PMAM3StepperTest.class.st b/src/Math-Tests-ODE/PMAM3StepperTest.class.st index 8734e3277..e01071de6 100644 --- a/src/Math-Tests-ODE/PMAM3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM3StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMAM3StepperTest >> testOrderIsThree [ - self assert: AM3Stepper order equals: 3 + self assert: PMAM3Stepper order equals: 3 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMAM3StepperTest >> testSimpleSystem [ 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). @@ -45,9 +45,9 @@ PMAM3StepperTest >> testSimpleSystem2 [ 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. @@ -85,15 +85,15 @@ PMAM3StepperTest >> testSimpleSystem3 [ 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/PMAM4SolverTest.class.st b/src/Math-Tests-ODE/PMAM4SolverTest.class.st index a7b22a852..4c09c9bfc 100644 --- a/src/Math-Tests-ODE/PMAM4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMAM4SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -20,9 +20,9 @@ PMAM4SolverTest >> testSimpleSystem2 [ 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. @@ -60,15 +60,15 @@ PMAM4SolverTest >> testSimpleSystem3 [ 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/PMAM4StepperTest.class.st b/src/Math-Tests-ODE/PMAM4StepperTest.class.st index 46507b18e..8e53d4073 100644 --- a/src/Math-Tests-ODE/PMAM4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMAM4StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMAM4StepperTest >> testOrderIsFour [ - self assert: AM4Stepper order equals: 4 + self assert: PMAM4Stepper order equals: 4 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMAM4StepperTest >> testSimpleSystem [ 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). @@ -45,9 +45,9 @@ PMAM4StepperTest >> testSimpleSystem2 [ 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/PMBDF2SolverTest.class.st b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st index b544590c8..1de642a64 100644 --- a/src/Math-Tests-ODE/PMBDF2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -20,9 +20,9 @@ PMBDF2SolverTest >> testSimpleSystem2 [ 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. @@ -60,10 +60,10 @@ PMBDF2SolverTest >> testSimpleSystem3 [ 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 @@ -91,10 +91,10 @@ PMBDF2SolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ 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. diff --git a/src/Math-Tests-ODE/PMBDF2StepperTest.class.st b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st index cc96df244..3025f1063 100644 --- a/src/Math-Tests-ODE/PMBDF2StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMBDF2StepperTest >> testOrderIsTwo [ - self assert: BDF2Stepper order equals: 2 + self assert: PMBDF2Stepper order equals: 2 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMBDF2StepperTest >> testSimpleSystem [ 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). @@ -46,9 +46,9 @@ PMBDF2StepperTest >> testSimpleSystem2 [ 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. @@ -86,15 +86,15 @@ PMBDF2StepperTest >> testSimpleSystem3 [ 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/PMBDF3SolverTest.class.st b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st index 0f0dfd351..f8a0ac823 100644 --- a/src/Math-Tests-ODE/PMBDF3SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -20,9 +20,9 @@ PMBDF3SolverTest >> testSimpleSystem2 [ 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. @@ -60,15 +60,15 @@ PMBDF3SolverTest >> testSimpleSystem3 [ 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/PMBDF3StepperTest.class.st b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st index 7724eddec..2e6d075db 100644 --- a/src/Math-Tests-ODE/PMBDF3StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF3StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMBDF3StepperTest >> testOrderIsThree [ - self assert: BDF3Stepper order equals: 3 + self assert: PMBDF3Stepper order equals: 3 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMBDF3StepperTest >> testSimpleSystem [ 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). @@ -45,9 +45,9 @@ PMBDF3StepperTest >> testSimpleSystem2 [ 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/PMBDF4SolverTest.class.st b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st index e3056dc7d..19a735170 100644 --- a/src/Math-Tests-ODE/PMBDF4SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4SolverTest.class.st @@ -8,9 +8,9 @@ Class { 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). @@ -21,9 +21,9 @@ PMBDF4SolverTest >> testSimpleSystem2 [ 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. @@ -68,15 +68,15 @@ PMBDF4SolverTest >> testSimpleSystem3 [ 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/PMBDF4StepperTest.class.st b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st index a0b0881a9..a3cfb94da 100644 --- a/src/Math-Tests-ODE/PMBDF4StepperTest.class.st +++ b/src/Math-Tests-ODE/PMBDF4StepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMBDF4StepperTest >> testOrderIsFour [ - self assert: BDF4Stepper order equals: 4 + self assert: PMBDF4Stepper order equals: 4 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMBDF4StepperTest >> testSimpleSystem [ 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). @@ -46,9 +46,9 @@ PMBDF4StepperTest >> testSimpleSystem2 [ 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/PMBeckwardEulerSolverTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st index 2ff16eda2..f399e0874 100644 --- a/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerSolverTest.class.st @@ -8,9 +8,9 @@ Class { 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. @@ -27,9 +27,9 @@ PMBeckwardEulerSolverTest >> testSimpleSystem [ 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). ] @@ -38,15 +38,15 @@ PMBeckwardEulerSolverTest >> testSimpleSystem2 [ 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/PMBeckwardEulerStepperTest.class.st b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st index 9d94eeaf2..f15d31a35 100644 --- a/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMBeckwardEulerStepperTest.class.st @@ -9,8 +9,8 @@ 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. @@ -28,8 +28,8 @@ PMBeckwardEulerStepperTest >> testDoStepTime [ { #category : #'tests-stepping' } 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. @@ -41,9 +41,9 @@ PMBeckwardEulerStepperTest >> testDoStepTimeStepSize [ 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). ] @@ -52,9 +52,9 @@ PMBeckwardEulerStepperTest >> testSimpleSystem2 [ 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 index d8d1be1ba..e08f35354 100644 --- a/src/Math-Tests-ODE/PMEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMEulerSolverTest.class.st @@ -11,10 +11,10 @@ Class { PMEulerSolverTest >> testSimpleSystem2 [ | solver stepper system dt | dt := 1.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. @@ -38,10 +38,10 @@ PMEulerSolverTest >> testSimpleSystem2 [ PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ | solver stepper system dt finalState | dt := 0.2. - system := ExplicitSystem block: [ :x :t | (t * x) exp ]. - stepper := ExplicitStepper onSystem: system. + system := PMExplicitSystem block: [ :x :t | (t * x) exp ]. + stepper := PMExplicitStepper onSystem: system. stepper stepSize: dt. - solver := ExplicitSolver new + solver := PMExplicitSolver new system: system; stepper: stepper. finalState := solver @@ -69,10 +69,10 @@ PMEulerSolverTest >> testSolveStartStateStartTimeEndTimeStepSize [ PMEulerSolverTest >> testSolveX0T0T1 [ | solver stepper system dt finalState | dt := 0.1. - system := ExplicitSystem block: [ :x :t | (t * x) exp ]. - stepper := ExplicitStepper onSystem: system. + system := PMExplicitSystem block: [ :x :t | (t * x) exp ]. + stepper := PMExplicitStepper onSystem: system. stepper stepSize: dt. - solver := ExplicitSolver new + solver := PMExplicitSolver new system: system; stepper: stepper; dt: dt. diff --git a/src/Math-Tests-ODE/PMEulerStepperTest.class.st b/src/Math-Tests-ODE/PMEulerStepperTest.class.st index 3a65e5f4d..cda9ab668 100644 --- a/src/Math-Tests-ODE/PMEulerStepperTest.class.st +++ b/src/Math-Tests-ODE/PMEulerStepperTest.class.st @@ -12,8 +12,8 @@ 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. @@ -29,8 +29,8 @@ PMEulerStepperTest >> testDoStepTime [ { #category : #'tests-stepping' } 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. @@ -41,7 +41,7 @@ PMEulerStepperTest >> testDoStepTimeStepSize [ { #category : #'tests-stepping' } PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ | order | - order := ExplicitStepper new order. + order := PMExplicitStepper new order. self assert: order notNil. self assert: order equals: 1 ] @@ -50,15 +50,15 @@ PMEulerStepperTest >> testOrderOfBaseExplicitStepperIsOne [ 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/PMHeunStepperTest.class.st b/src/Math-Tests-ODE/PMHeunStepperTest.class.st index 90d9d9cc6..74777b16b 100644 --- a/src/Math-Tests-ODE/PMHeunStepperTest.class.st +++ b/src/Math-Tests-ODE/PMHeunStepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #tests } PMHeunStepperTest >> testOrderIsTwo [ - self assert: HeunStepper order equals: 2 + self assert: PMHeunStepper order equals: 2 ] { #category : #tests } 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. @@ -32,10 +32,10 @@ PMHeunStepperTest >> testSimpleSystem [ 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. @@ -59,9 +59,9 @@ PMHeunStepperTest >> testSimpleSystem2 [ 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. @@ -85,15 +85,15 @@ PMHeunStepperTest >> testSimpleSystem3 [ 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 index 7cff177b9..5322796d8 100644 --- a/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointSolverTest.class.st @@ -8,9 +8,9 @@ Class { PMImplicitMidpointSolverTest >> 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: 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/PMImplicitMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st index 602710202..6c51b73a0 100644 --- a/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMImplicitMidpointStepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMImplicitMidpointStepperTest >> testOrderIsTwo [ - self assert: ImplicitMidpointStepper order equals: 2 + self assert: PMImplicitMidpointStepper order equals: 2 ] { #category : #'tests-stepping' } 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. @@ -32,9 +32,9 @@ PMImplicitMidpointStepperTest >> testSimpleSystem [ 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). ] @@ -43,9 +43,9 @@ PMImplicitMidpointStepperTest >> testSimpleSystem2 [ 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. @@ -62,15 +62,15 @@ PMImplicitMidpointStepperTest >> testSimpleSystem3 [ 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/PMMidpointSolverTest.class.st b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st index 3bf9a3d1d..cf22ef05f 100644 --- a/src/Math-Tests-ODE/PMMidpointSolverTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointSolverTest.class.st @@ -8,9 +8,9 @@ Class { 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. @@ -27,9 +27,9 @@ PMMidpointSolverTest >> testSimpleSystem [ 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. @@ -60,10 +60,10 @@ PMMidpointSolverTest >> testSimpleSystem1 [ 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. @@ -94,9 +94,9 @@ PMMidpointSolverTest >> testSimpleSystem2 [ 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. @@ -134,15 +134,15 @@ PMMidpointSolverTest >> testSimpleSystem3 [ 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/PMMidpointStepperTest.class.st b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st index bf99258d8..271a113e9 100644 --- a/src/Math-Tests-ODE/PMMidpointStepperTest.class.st +++ b/src/Math-Tests-ODE/PMMidpointStepperTest.class.st @@ -6,16 +6,16 @@ Class { { #category : #'tests-stepping' } PMMidpointStepperTest >> testOrderIsTwo [ - self assert: MidpointStepper order equals: 2 + self assert: PMMidpointStepper order equals: 2 ] { #category : #'tests-stepping' } 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. @@ -32,10 +32,10 @@ PMMidpointStepperTest >> testSimpleSystem [ 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. @@ -59,9 +59,9 @@ PMMidpointStepperTest >> testSimpleSystem2 [ 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. @@ -92,10 +92,10 @@ PMMidpointStepperTest >> testSimpleSystem3 [ 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. @@ -112,15 +112,15 @@ PMMidpointStepperTest >> testSimpleSystem4 [ 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/PMODESystemTest.class.st b/src/Math-Tests-ODE/PMODESystemTest.class.st index 4ce88164d..3075495b8 100644 --- a/src/Math-Tests-ODE/PMODESystemTest.class.st +++ b/src/Math-Tests-ODE/PMODESystemTest.class.st @@ -13,7 +13,7 @@ Class { { #category : #initialization } PMODESystemTest >> setUp [ "create a dummy system" - sys := ODESystem new + sys := PMODESystem new ] { #category : #tests } diff --git a/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st index 865627d2d..cc310e1ba 100644 --- a/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaSolverTest.class.st @@ -8,9 +8,9 @@ Class { 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. @@ -27,9 +27,9 @@ PMRungeKuttaSolverTest >> testSimpleSystem [ 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. @@ -60,10 +60,10 @@ PMRungeKuttaSolverTest >> testSimpleSystem1 [ 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. @@ -94,9 +94,9 @@ PMRungeKuttaSolverTest >> testSimpleSystem2 [ 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. @@ -134,15 +134,15 @@ PMRungeKuttaSolverTest >> testSimpleSystem3 [ 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/PMRungeKuttaStepperTest.class.st b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st index 3537c6d31..d88ddf34e 100644 --- a/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st +++ b/src/Math-Tests-ODE/PMRungeKuttaStepperTest.class.st @@ -7,8 +7,8 @@ Class { { #category : #'tests-stepping' } 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 @@ -22,9 +22,9 @@ PMRungeKuttaStepperTest >> testDoStepTimeStepSize1 [ { #category : #'tests-stepping' } 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). @@ -34,16 +34,16 @@ PMRungeKuttaStepperTest >> testDoStepTimeStepSize2 [ { #category : #'tests-stepping' } PMRungeKuttaStepperTest >> testOrderIsFour [ - self assert: RungeKuttaStepper order equals: 4 + self assert: PMRungeKuttaStepper order equals: 4 ] { #category : #'tests-stepping' } 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. @@ -60,10 +60,10 @@ PMRungeKuttaStepperTest >> testSimpleSystem [ 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. @@ -87,15 +87,15 @@ PMRungeKuttaStepperTest >> testSimpleSystem2 [ 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 index 8126c1ae8..7d494ca31 100644 --- a/src/Math-Tests-ODE/PMStepperTest.class.st +++ b/src/Math-Tests-ODE/PMStepperTest.class.st @@ -9,21 +9,21 @@ Class { { #category : #tests } PMStepperTest >> testOrderIsNilForBaseClass [ - self assert: Stepper order isNil + self assert: PMStepper order isNil ] { #category : #tests } PMStepperTest >> testOrderIsNilForInstanceOfBaseClass [ - self assert: Stepper new order isNil + self assert: PMStepper new order isNil ] { #category : #tests } PMStepperTest >> testSystem [ | stepper sys | - sys := ExplicitSystem new. + sys := PMExplicitSystem new. sys block: [ :x :t | t ]. - stepper := Stepper onSystem: sys. + stepper := PMStepper onSystem: sys. self assert: stepper system equals: sys. - sys := ExplicitSystem new. + sys := PMExplicitSystem new. self shouldnt: [ stepper system = sys ] ] diff --git a/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st index 47673f908..de9e1ed56 100644 --- a/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidSolverTest.class.st @@ -8,9 +8,9 @@ Class { 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) @@ -20,9 +20,9 @@ PMTrapezoidSolverTest >> testSimpleSystem2 [ 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. @@ -60,15 +60,15 @@ PMTrapezoidSolverTest >> testSimpleSystem3 [ 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/PMTrapezoidStepperTest.class.st b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st index 3bee704ad..0c78ebd33 100644 --- a/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st +++ b/src/Math-Tests-ODE/PMTrapezoidStepperTest.class.st @@ -9,8 +9,8 @@ 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. @@ -27,8 +27,8 @@ PMTrapezoidStepperTest >> testDoStepTime [ { #category : #'tests-stepping' } 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 @@ -42,9 +42,9 @@ PMTrapezoidStepperTest >> testDoStepTimeStepSize1 [ { #category : #'tests-stepping' } 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). @@ -54,22 +54,22 @@ PMTrapezoidStepperTest >> testDoStepTimeStepSize2 [ { #category : #'tests-stepping' } PMTrapezoidStepperTest >> testOrderIsTwo [ - self assert: TrapezoidStepper order equals: 2 + self assert: PMTrapezoidStepper order equals: 2 ] { #category : #'tests-stepping' } 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. From a168191c3b34dc5bb473aa60123ea7d403b941b7 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:45:25 +0100 Subject: [PATCH 109/161] Close #62 From 79962653998221eeca7ff750078ad9e1735ce0c7 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 15:46:57 +0100 Subject: [PATCH 110/161] Close #62 --- src/Math-ODE/PMImplicitStepper.class.st | Bin 2692 -> 2640 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/Math-ODE/PMImplicitStepper.class.st b/src/Math-ODE/PMImplicitStepper.class.st index 6d0e0f53d62fc35f381508150d42f39fb1994710..7cd5e2ccd97018b64131fa1eed60079b8febc3e5 100644 GIT binary patch delta 12 TcmZn>y&$qdlWB7-lR5_g8}S30 delta 65 ycmca0(jvM+lgUKE>u~d-MTeUXH2`sUW|o4jLP{Enkb=HKN(Hh=)@Ds6bq)Xq=pTgu From 2e8f1f306172405ab87d4626f12801b78e70e0af Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 17:02:11 +0100 Subject: [PATCH 111/161] fix typo. --- .../PMErrorMinimizerTest.class.st | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st index 12c8b812b..cbf078a0e 100644 --- a/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st +++ b/src/Math-Tests-FunctionFit/PMErrorMinimizerTest.class.st @@ -8,15 +8,15 @@ Class { } { #category : #tests } -PMErrorMinimizerTest >> 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)) +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)) ] From bec50aa825c13c9e0dd7f4c37461316394e51f5e Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 17:11:56 +0100 Subject: [PATCH 112/161] Don't test if a package has been loaded or not, this is manage by Baseline. --- src/Math-Tests-KDTree/PMKDTreeTest.class.st | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Math-Tests-KDTree/PMKDTreeTest.class.st b/src/Math-Tests-KDTree/PMKDTreeTest.class.st index 935ae35d0..88e92915e 100644 --- a/src/Math-Tests-KDTree/PMKDTreeTest.class.st +++ b/src/Math-Tests-KDTree/PMKDTreeTest.class.st @@ -33,8 +33,6 @@ PMKDTreeTest >> setUp [ { #category : #tests } 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. From 860739d5f64e98345fb62ceff96b6552ea13199f Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 17:41:13 +0100 Subject: [PATCH 113/161] Clean comments --- src/Math-Random/PMBernoulliGenerator.class.st | 4 ++-- src/Math-Random/PMBinomialGenerator.class.st | 4 ++-- src/Math-Random/PMConstantGenerator.class.st | 4 ++-- .../PMExplicitInverseCongruentialRandomGenerator.class.st | 8 ++++---- src/Math-Random/PMExponentialGenerator.class.st | 4 ++-- src/Math-Random/PMGaussianGenerator.class.st | 4 ++-- src/Math-Random/PMLehmerRandomGenerator.class.st | 4 ++-- .../PMLinearCongruentialRandomGenerator.class.st | 4 ++-- src/Math-Random/PMMarsagliaKissRandom.class.st | 4 ++-- src/Math-Random/PMNumberGenerator.class.st | 4 ++-- .../PMParkMillerMinimumRandomGenerator.class.st | 4 ++-- src/Math-Random/PMPoissonGenerator.class.st | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) 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..44d4ce551 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 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..76d920c1d 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' } 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-Random/PMLehmerRandomGenerator.class.st b/src/Math-Random/PMLehmerRandomGenerator.class.st index e6b2a47f7..3659ff66c 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' + #category : #'Math-Random' } { #category : #'stream access' } diff --git a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st index a39fd0a3e..c8b99c60a 100644 --- a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st +++ b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st @@ -1,12 +1,12 @@ " I use a quick and dirty Linear Congruential generator. -LCRandom new next. +PMLinearCongruentialRandomGenerator new next. " Class { #name : #PMLinearCongruentialRandomGenerator, #superclass : #PMRandomGenerator, - #category : 'Math-Random' + #category : #'Math-Random' } { #category : #accessing } diff --git a/src/Math-Random/PMMarsagliaKissRandom.class.st b/src/Math-Random/PMMarsagliaKissRandom.class.st index 33b08b6a2..d5ca4c425 100644 --- a/src/Math-Random/PMMarsagliaKissRandom.class.st +++ b/src/Math-Random/PMMarsagliaKissRandom.class.st @@ -1,5 +1,5 @@ " -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]. @@ -16,7 +16,7 @@ Class { 'kernelRand1', 'kernelRand2' ], - #category : 'Math-Random' + #category : #'Math-Random' } { #category : #'instance creation' } 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..b67d468d9 100644 --- a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st +++ b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st @@ -1,12 +1,12 @@ " 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' + #category : #'Math-Random' } { #category : #accessing } diff --git a/src/Math-Random/PMPoissonGenerator.class.st b/src/Math-Random/PMPoissonGenerator.class.st index 554bf6dbe..6f36edac9 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' } From a692de31610b67c25f641765ff0459f7750dc83c Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 17:50:37 +0100 Subject: [PATCH 114/161] Still comments fixes --- src/Math-Random/PMMarsagliaKissRandom.class.st | 4 ++-- src/Math-Random/PMMarsagliaKissRandomKernel.class.st | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Math-Random/PMMarsagliaKissRandom.class.st b/src/Math-Random/PMMarsagliaKissRandom.class.st index d5ca4c425..cfa6fd571 100644 --- a/src/Math-Random/PMMarsagliaKissRandom.class.st +++ b/src/Math-Random/PMMarsagliaKissRandom.class.st @@ -5,8 +5,8 @@ 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 { 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' } From b341989c55d8a8fb9c4732f31d4fd5f26baba549 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 18:08:02 +0100 Subject: [PATCH 115/161] Clean some tests --- src/Math-Tests-Random/PMExponentialGeneratorTest.class.st | 4 ++-- src/Math-Tests-Random/PMGaussianGeneratorTest.class.st | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st index 3cb2101ac..a951ef334 100644 --- a/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st @@ -1,5 +1,5 @@ " -An ExponentialGeneratorTest is a test class for testing the behavior of ExponentialGenerator +A PMExponentialGeneratorTest is a test class for testing the behavior of PMExponentialGenerator " Class { #name : #PMExponentialGeneratorTest, @@ -34,7 +34,7 @@ PMExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [ | eg arr | eg := PMExponentialGenerator mean: 10. arr := Array new: 10000. - (1 to: 10000) do: [ :index | arr at: index put: eg next ]. + arr := arr collect: [ :each | eg next ]. self assert: (arr average between: eg mean * 0.95 and: eg mean * 1.05) ] diff --git a/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st index 8b1c7613e..f452f5b82 100644 --- a/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st @@ -4,7 +4,7 @@ Class { #category : #'Math-Tests-Random' } -{ #category : #utils } +{ #category : #utilities } PMGaussianGeneratorTest >> checkDistributionOf: aGenerator withExpectedMeans: e andExpectedStandardDeviation: sd [ "fixme: this test ignores the standard deviation and occasionally fails" | data m | From 7bff444f62821d930fe9e06afc9999166eca89de Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 18:16:50 +0100 Subject: [PATCH 116/161] More tests cleaning --- src/Math-Tests-Random/PMPoissonGeneratorTest.class.st | 2 +- src/Math-Tests-Random/PMRandomGeneratorTest.class.st | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st index d324cbc6d..7f1607863 100644 --- a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st @@ -24,7 +24,7 @@ PMPoissonGeneratorTest >> testPeekReturnsSameTwice [ PMPoissonGeneratorTest >> testPeekWorksAfterSampling [ | poisson random | poisson := PMPoissonGenerator lambda: 0.1. - (1 to: 100) do: [ :ea | poisson next ]. + 1 to: 100 do: [ :ea | poisson next ]. random := poisson peek. self assert: random equals: poisson peek. self assert: random equals: poisson next diff --git a/src/Math-Tests-Random/PMRandomGeneratorTest.class.st b/src/Math-Tests-Random/PMRandomGeneratorTest.class.st index 41f41c575..ca33218ce 100644 --- a/src/Math-Tests-Random/PMRandomGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMRandomGeneratorTest.class.st @@ -6,10 +6,11 @@ Class { { #category : #tests } PMRandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [ - PMRandomGenerator subclasses do: - [:cls | | gen value | - gen := cls new. - self should: [gen contents] raise: Error]. + PMRandomGenerator subclasses + do: [ :cls | + | gen | + gen := cls new. + self should: [ gen contents ] raise: Error ] ] { #category : #tests } From 32936e0f76d1c7105f768bfabdda0f0af2b5b0c3 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 21:27:27 +0100 Subject: [PATCH 117/161] Remove dependancy between PM-RandomDistributionBased and PM-Polynomials --- .../BaselineOfPolyMath.class.st | 176 ++++++++++++------ 1 file changed, 124 insertions(+), 52 deletions(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index d1b4caf11..45ea7cf8e 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -29,74 +29,146 @@ 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-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-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-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-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-Numerical' 'Math-Polynomials') ]; - package: 'Math-KolmogorovSmirnov' with: [ spec requires: #('Math-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-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-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-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-Numerical' 'Math-Polynomials') ]; + package: 'Math-RandomDistributionBased' + with: [ spec requires: #('Math-Numerical') ]; 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-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-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-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-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-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-RandomDistributionBased' with: [ spec requires: #('Math-RandomDistributionBased') ]; - package:'Math-Tests-TSNE' with: [ spec requires: #('Math-TSNE') ]; + 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-RandomDistributionBased' + with: [ spec requires: #('Math-RandomDistributionBased') ]; + 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-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-RandomDistributionBased' '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-RandomDistributionBased' 'Math-Tests-Core-Process' 'Math-Tests-Core'); - 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-RandomDistributionBased' '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-RandomDistributionBased' 'Math-Tests-Core-Process' 'Math-Tests-Core'); + group: 'default' + with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ] ] { #category : #accessing } From eb874f14c09f01c74a0fd9aeed179f75306b53c5 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 1 May 2019 22:11:20 +0100 Subject: [PATCH 118/161] Ongoing work on #105. Remove Math-RandomDistributionBased package and merge classes with Math-Random. --- .../BaselineOfPolyMath.class.st | 8 +--- src/Math-Random/PMLaplaceGenerator.class.st | 41 +++++++++++++++++++ .../PMLaplaceGeneratorTest.class.st | 17 ++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 src/Math-Random/PMLaplaceGenerator.class.st create mode 100644 src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 45ea7cf8e..170622d77 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -92,8 +92,6 @@ BaselineOfPolyMath >> baseline: spec [ with: [ spec requires: #('Math-Complex' 'Math-Numerical' 'Math-Polynomials') ]; package: 'Math-Random'; - package: 'Math-RandomDistributionBased' - with: [ spec requires: #('Math-Numerical') ]; package: 'Math-Series'; package: 'Math-StatisticalMoments' with: [ spec requires: #('Math-Core' 'Math-DistributionForHistogram') ]; @@ -146,8 +144,6 @@ BaselineOfPolyMath >> baseline: spec [ with: [ spec requires: #('Math-Quaternion') ]; package: 'Math-Tests-Random' with: [ spec requires: #('Math-Random') ]; - package: 'Math-Tests-RandomDistributionBased' - with: [ spec requires: #('Math-RandomDistributionBased') ]; package: 'Math-Tests-TSNE' with: [ spec requires: #('Math-TSNE') ]; package: 'Math-UtilsDataServer'. @@ -163,10 +159,10 @@ BaselineOfPolyMath >> baseline: spec [ #('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-RandomDistributionBased' 'Math-KolmogorovSmirnov'); + #('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-RandomDistributionBased' 'Math-Tests-Core-Process' 'Math-Tests-Core'); + #('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') ] ] diff --git a/src/Math-Random/PMLaplaceGenerator.class.st b/src/Math-Random/PMLaplaceGenerator.class.st new file mode 100644 index 000000000..738e7634f --- /dev/null +++ b/src/Math-Random/PMLaplaceGenerator.class.st @@ -0,0 +1,41 @@ +" +I'm a random number generator whose values are distributed according to Laplace distribution. + +Ideally this class should be a subclass of RandomGenerator +however it is unclear how to implement peek. +" +Class { + #name : #PMLaplaceGenerator, + #superclass : #Object, + #instVars : [ + 'laplaceDistribution', + 'next' + ], + #category : #'Math-Random' +} + +{ #category : #'instance creation' } +PMLaplaceGenerator class >> shape: peakValue scale: falloffValue [ + + ^ self new shape: peakValue scale: falloffValue +] + +{ #category : #accessing } +PMLaplaceGenerator >> next [ + + next := laplaceDistribution random. + ^ next +] + +{ #category : #accessing } +PMLaplaceGenerator >> peek [ + + next ifNil: [ self next. ]. + ^ next +] + +{ #category : #creation } +PMLaplaceGenerator >> shape: peakValue scale: falloffValue [ + + laplaceDistribution := PMLaplaceDistribution shape: peakValue scale: falloffValue +] diff --git a/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st new file mode 100644 index 000000000..1b1cb51d8 --- /dev/null +++ b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st @@ -0,0 +1,17 @@ +Class { + #name : #PMLaplaceGeneratorTest, + #superclass : #TestCase, + #category : #'Math-Tests-Random' +} + +{ #category : #'as yet unclassified' } +PMLaplaceGeneratorTest >> classToTest [ + ^ PMLaplaceGenerator +] + +{ #category : #accessing } +PMLaplaceGeneratorTest >> testPeekAlwaysReplyTheSameValue [ + | g | + g := self classToTest shape: 0.5 scale: 0.3. + self assert: g peek equals: g peek +] From a7faa79ea9947076c199a9dfef450705cad899df Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:21:33 +0100 Subject: [PATCH 119/161] Update .travis.yml --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1133a18c..5d323d1f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,6 @@ os: smalltalk: - Pharo-6.1 - - Pharo64-6.1 - - Pharo-7.0 - Pharo64-7.0 matrix: From 660a4af42ee7d70b20bacbdc4143d6ef741a2fa5 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:21:55 +0100 Subject: [PATCH 120/161] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5d323d1f3..896d023f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ os: smalltalk: - Pharo-6.1 + - Pharo32-7.0 - Pharo64-7.0 matrix: From 9af1a14c25a1f3604fe6b5015e4c963e83d894e1 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:22:31 +0100 Subject: [PATCH 121/161] Update appveyor.yml --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 400219bd2..c4063f13d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,7 +8,7 @@ environment: matrix: - SMALLTALK: Pharo-6.1 - SMALLTALK: Pharo-7.0 - + platform: - x86 From 10a324112be51aea61c60a946239bd23305ac580 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:32:43 +0100 Subject: [PATCH 122/161] Remove all Transcript show from tests. --- .../PMArbitraryPrecisionFloatTest.class.st | 86 +++++++++++++++---- src/Math-Tests-Complex/PMComplexTest.class.st | 8 -- .../PMFloatingPointMachineTestCase.class.st | 10 --- src/Math-Tests-ODE/PMBDF2SolverTest.class.st | 28 +----- src/Math-Tests-ODE/PMEulerSolverTest.class.st | 28 +----- 5 files changed, 71 insertions(+), 89 deletions(-) diff --git a/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st b/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st index 76afd69fc..7ad66bc09 100644 --- a/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st +++ b/src/Math-Tests-ArbitraryPrecisionFloat/PMArbitraryPrecisionFloatTest.class.st @@ -159,10 +159,17 @@ PMArbitraryPrecisionFloatTest >> testArTanhDomainError [ { #category : #'testing-trigonometry' } 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' } @@ -173,10 +180,17 @@ PMArbitraryPrecisionFloatTest >> testArcCosDomainError [ { #category : #'testing-trigonometry' } 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' } @@ -187,11 +201,18 @@ PMArbitraryPrecisionFloatTest >> testArcSinDomainError [ { #category : #'testing-trigonometry' } 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' } @@ -373,10 +394,19 @@ PMArbitraryPrecisionFloatTest >> testCoercingSum [ { #category : #'testing-trigonometry' } 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' } @@ -740,10 +770,19 @@ PMArbitraryPrecisionFloatTest >> testRoundToNearestEvenAgainstIEEEDouble [ { #category : #'testing-trigonometry' } 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' } @@ -816,10 +855,19 @@ PMArbitraryPrecisionFloatTest >> testSum [ { #category : #'testing-trigonometry' } 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' } 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-Numerical/PMFloatingPointMachineTestCase.class.st b/src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st index 506b9410c..c6f885e87 100644 --- a/src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st +++ b/src/Math-Tests-Numerical/PMFloatingPointMachineTestCase.class.st @@ -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-ODE/PMBDF2SolverTest.class.st b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st index 1de642a64..5ff9aa6bc 100644 --- a/src/Math-Tests-ODE/PMBDF2SolverTest.class.st +++ b/src/Math-Tests-ODE/PMBDF2SolverTest.class.st @@ -72,19 +72,7 @@ PMBDF2SolverTest >> 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' } @@ -103,17 +91,5 @@ PMBDF2SolverTest >> 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/PMEulerSolverTest.class.st b/src/Math-Tests-ODE/PMEulerSolverTest.class.st index e08f35354..92cb286a0 100644 --- a/src/Math-Tests-ODE/PMEulerSolverTest.class.st +++ b/src/Math-Tests-ODE/PMEulerSolverTest.class.st @@ -50,19 +50,7 @@ PMEulerSolverTest >> 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' } @@ -81,17 +69,5 @@ PMEulerSolverTest >> 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 ] From 6be7faeb717a2c96cebbc4718f3761ac82c43f37 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:47:43 +0100 Subject: [PATCH 123/161] Update .smalltalk.ston --- .smalltalk.ston | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index 7abde374f..e846b12eb 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -7,6 +7,8 @@ SmalltalkCISpec { } ], #testing : { - #categories : [ 'Math-*' ] - } + #coverage : { + #packages : [ 'Math-*' ] + } + } } From ae199ee0df043bd060b51368fcee6cb3f52ed83f Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:49:45 +0100 Subject: [PATCH 124/161] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 66adbca42..6f67a8908 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) [![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea) +[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg)](https://coveralls.io/github/PolyMathOrg/PolyMath) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE) Screenshot 2019-04-24 at 11 12 57 From 7cd52b355b7f17a5c8803370d0dd5a1aecc45c90 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:50:19 +0100 Subject: [PATCH 125/161] Update appveyor.yml --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c4063f13d..bce180177 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,6 @@ 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: From 7a88e1645e8980df3d6eb57785075f9195914a88 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 3 May 2019 08:58:51 +0100 Subject: [PATCH 126/161] Update .smalltalk.ston --- .smalltalk.ston | 2 -- 1 file changed, 2 deletions(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index e846b12eb..bd5d0c25d 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -7,8 +7,6 @@ SmalltalkCISpec { } ], #testing : { - #coverage : { #packages : [ 'Math-*' ] } - } } From a6fdca96b9dbe1e58dbf5198b39e02fa5249d989 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 7 May 2019 08:54:07 +0100 Subject: [PATCH 127/161] [issue-104] Set the seed to zero for more certainty. (#107) --- .../PMBinomialGeneratorTest.class.st | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st index 5c8791ce5..42196e9af 100644 --- a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st @@ -6,16 +6,22 @@ Class { { #category : #tests } PMBinomialGeneratorTest >> 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))" + "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. + | gen nums mean probabilityOfSuccess numberOfTrials | + probabilityOfSuccess := (Random seed: 0.0) next sqrt. + numberOfTrials := 1000. + gen := PMBinomialGenerator + numberOfTrials: numberOfTrials + probabilityOfSuccess: probabilityOfSuccess. + 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). + (1 to: numberOfTrials) do: [ :ea | nums add: gen next ]. + + mean := numberOfTrials * probabilityOfSuccess. + self assert: nums min > (mean * (1 - 0.2)). + self assert: nums max < (mean * (1 + 0.2)). self assert: (nums average - mean) abs < 5 ] From 26d1f9878b20636545e8152094f4906fef8890a3 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 13 May 2019 10:44:15 +0100 Subject: [PATCH 128/161] [Issue 104] Some tests methods fail randomly (#111) * [issue-104] Removed obselete code. * [issue-104] Corrected the method category, improved the formatting of the code in the test method. * [issue-104] Removed unnecessary code. * [issue-104] Improved code formatting. * [issue-104] Extracted the computation to an intention-revealing variable. * [issue-104] Improved code formatting, used data from a series from slides from QMUL * [issue-104] Separated the assert from the arrange. * [issue-104] Improved code formatting. * [issue-104] Removed obselete method. * [issue-104] We need to call the super class method according to the Pharo style guide. * [issue-104] Corrected the category of the method. * [issue-104] Removed obselete code - here I removed them and re-ran the tests. They remained green. * [issue-104] Corrected formatting. * [issue-104] Improved formatting, used data from the Oxford University Statistics Dept lecture notes. * [issue-104] Corrected the link to the data source --- .../PMKolmogorovSmirnov1Sample.class.st | 40 +++--- .../PMKolmogorovSmirnov2Sample.class.st | 129 +++++++++++------- .../PMKolmogorovsDistribution.class.st | 2 +- ...> PMKolmogorovSmirnov1SampleTest.class.st} | 17 ++- ...> PMKolmogorovSmirnov2SampleTest.class.st} | 19 +-- 5 files changed, 125 insertions(+), 82 deletions(-) rename src/Math-Tests-KolmogorovSmirnov/{PMKolmogorovSmirnov1sampleTest.class.st => PMKolmogorovSmirnov1SampleTest.class.st} (84%) rename src/Math-Tests-KolmogorovSmirnov/{PMKolmogorovSmirnov2sampleTest.class.st => PMKolmogorovSmirnov2SampleTest.class.st} (85%) diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st index 3eeea2e17..d174563b4 100644 --- a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st +++ b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov1Sample.class.st @@ -32,43 +32,41 @@ 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 } diff --git a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st index d717e93c3..0791765c8 100644 --- a/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st +++ b/src/Math-KolmogorovSmirnov/PMKolmogorovSmirnov2Sample.class.st @@ -38,91 +38,126 @@ 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 } 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-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st similarity index 84% rename from src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st index c1edd1c9a..245ef271b 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov1SampleTest.class.st @@ -20,8 +20,9 @@ PMKolmogorovSmirnov1SampleTest >> numberOfRejectionsFor: aDistribution [ ^ n ] -{ #category : #initialization } +{ #category : #running } PMKolmogorovSmirnov1SampleTest >> setUp [ + super setUp . nd := PMNormalDistribution new. ks := PMKolmogorovSmirnov1Sample new ] @@ -37,10 +38,16 @@ PMKolmogorovSmirnov1SampleTest >> testCorrectPopulationProbabilistic [ { #category : #tests } PMKolmogorovSmirnov1SampleTest >> 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 + | 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 } diff --git a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st similarity index 85% rename from src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st rename to src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st index 8e0b8fe12..81e1bff62 100644 --- a/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2sampleTest.class.st +++ b/src/Math-Tests-KolmogorovSmirnov/PMKolmogorovSmirnov2SampleTest.class.st @@ -7,23 +7,26 @@ Class { #category : #'Math-Tests-KolmogorovSmirnov' } -{ #category : #initialization } +{ #category : #running } PMKolmogorovSmirnov2SampleTest >> setUp [ + super setUp . k := PMKolmogorovSmirnov2Sample new ] { #category : #tests } PMKolmogorovSmirnov2SampleTest >> testRejectOfEqualityHypothesesForTwoSamples [ - | nd ks | - nd := PMNormalDistribution new. + "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 } From 8e663a8f998375e657596a33c9d3b97a530bb0f6 Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Mon, 13 May 2019 15:20:37 +0530 Subject: [PATCH 129/161] Removed == operator from PMVector (#108) The == operator should not be overridden. Removed that block entirely due to no it having no real application. --- src/Math-Core/PMVector.class.st | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index a501fef1b..2786e4288 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -89,12 +89,6 @@ PMVector >> < aNumber [ 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]. -] - { #category : #operation } PMVector >> > aNumber [ "Apply > function to every element of a vector" From 463560e7954d1c29ce4ef63cd05eb3acbb9acbb2 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 22 May 2019 15:49:48 +0100 Subject: [PATCH 130/161] Issue 29 - PMVector/PMMatrix >> #dot: does not compute a dot product. (#119) * [issue-29] Marked PMMatrix's dot message as deprecated and introduced the hadamard product in its place. Replaced calls to dot in places where we can be confident nothing breaks. * [issue-29] Introduce the new and better-named elementwiseTimes message. * [issue-29] Marked the PMVector dot message as deprecated. * [issue-29] Added a separate test for the Hadamard product and reverted the element-wise multiply test to its original state. * [issue-29] Improved the name of the method. --- src/Math-Core/PMVector.class.st | 19 ++++++++++++++++-- src/Math-Core/PMWeightedPoint.class.st | 2 +- .../PMJacobiTransformationHelper.class.st | 2 +- src/Math-Matrix/PMLUPDecomposition.class.st | 2 +- .../PMLargestEigenValueFinder.class.st | 2 +- .../PMLinearEquationSystem.class.st | 2 +- src/Math-Matrix/PMMatrix.class.st | 11 +++++++--- .../PMSingularMatrixError.class.st | 2 +- .../PMSingularValueDecomposition.class.st | 2 +- src/Math-Matrix/PMSymmetricMatrix.class.st | 2 +- .../PMSciKitLearnSVDFlipAlgorithm.class.st | 4 ++-- src/Math-Tests-Core/PMVectorTest.class.st | 14 +++++++++++++ .../PMAdditionalTest.class.st | 2 +- src/Math-Tests-Matrix/PMMatrixTest.class.st | 20 +++++++++++++++++-- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- src/Math-Tests-Matrix/PMRestTest.class.st | 2 +- .../PMSingularValueDecompositionTest.class.st | 2 +- .../PMSymmetricMatrixTest.class.st | 2 +- 18 files changed, 72 insertions(+), 22 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 2786e4288..9a015f0ee 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -20,7 +20,7 @@ Class { #name : #PMVector, #superclass : #Array, #type : #variable, - #category : 'Math-Core' + #category : #'Math-Core' } { #category : #'instance creation' } @@ -167,7 +167,7 @@ PMVector >> cumsum [ ] -{ #category : #operation } +{ #category : #deprecated } PMVector >> dot: aVector [ "Answers the elementwise product of the receiver with aVector." | answer n | @@ -182,6 +182,21 @@ PMVector >> dot: aVector [ ] +{ #category : #operation } +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 +] + { #category : #'as yet unclassified' } PMVector >> householder [ "returns a collection of the skalar beta and the housholder vector" diff --git a/src/Math-Core/PMWeightedPoint.class.st b/src/Math-Core/PMWeightedPoint.class.st index a7beea989..68a6f6146 100644 --- a/src/Math-Core/PMWeightedPoint.class.st +++ b/src/Math-Core/PMWeightedPoint.class.st @@ -12,7 +12,7 @@ Class { 'weight', 'error' ], - #category : 'Math-Core' + #category : #'Math-Core' } { #category : #creation } diff --git a/src/Math-Matrix/PMJacobiTransformationHelper.class.st b/src/Math-Matrix/PMJacobiTransformationHelper.class.st index be6f6f9ce..7675cc075 100644 --- a/src/Math-Matrix/PMJacobiTransformationHelper.class.st +++ b/src/Math-Matrix/PMJacobiTransformationHelper.class.st @@ -8,7 +8,7 @@ Class { 'eigenvalues', 'eigenvectors' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMLUPDecomposition.class.st b/src/Math-Matrix/PMLUPDecomposition.class.st index 75dbe790d..fe6392d72 100644 --- a/src/Math-Matrix/PMLUPDecomposition.class.st +++ b/src/Math-Matrix/PMLUPDecomposition.class.st @@ -26,7 +26,7 @@ Class { 'permutation', 'parity' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMLargestEigenValueFinder.class.st b/src/Math-Matrix/PMLargestEigenValueFinder.class.st index 06dfac388..81478c9ab 100644 --- a/src/Math-Matrix/PMLargestEigenValueFinder.class.st +++ b/src/Math-Matrix/PMLargestEigenValueFinder.class.st @@ -20,7 +20,7 @@ Class { 'eigenvector', 'transposeEigenvector' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #information } diff --git a/src/Math-Matrix/PMLinearEquationSystem.class.st b/src/Math-Matrix/PMLinearEquationSystem.class.st index 8b021c459..3e5b8e3b6 100644 --- a/src/Math-Matrix/PMLinearEquationSystem.class.st +++ b/src/Math-Matrix/PMLinearEquationSystem.class.st @@ -22,7 +22,7 @@ Class { 'rows', 'solutions' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index c3547d753..900d3f209 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -15,7 +15,7 @@ Class { 'rows', 'lupDecomposition' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #example } @@ -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. @@ -407,7 +407,7 @@ PMMatrix >> dimension [ ^ self rows size @ (self rows at: 1) size ] -{ #category : #operation } +{ #category : #deprecated } PMMatrix >> dot: aMatrix [ "Answers the elementwise product of the receiver with aMatrix." ^ aMatrix elementwiseProductWithMatrix: self @@ -458,6 +458,11 @@ PMMatrix >> flattenRows [ ^ answer asPMVector ] +{ #category : #operation } +PMMatrix >> hadamardProduct: aMatrix [ + ^ aMatrix elementwiseProductWithMatrix: self +] + { #category : #comparing } PMMatrix >> hash [ ^ rows hash diff --git a/src/Math-Matrix/PMSingularMatrixError.class.st b/src/Math-Matrix/PMSingularMatrixError.class.st index 6bf7cc4d7..6aa9392a8 100644 --- a/src/Math-Matrix/PMSingularMatrixError.class.st +++ b/src/Math-Matrix/PMSingularMatrixError.class.st @@ -5,7 +5,7 @@ some calculations dont work with singular matrices and result eg with errors lik Class { #name : #PMSingularMatrixError, #superclass : #ArithmeticError, - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #accessing } diff --git a/src/Math-Matrix/PMSingularValueDecomposition.class.st b/src/Math-Matrix/PMSingularValueDecomposition.class.st index 9753ef804..65a2723e3 100644 --- a/src/Math-Matrix/PMSingularValueDecomposition.class.st +++ b/src/Math-Matrix/PMSingularValueDecomposition.class.st @@ -40,7 +40,7 @@ Class { 'signU', 'signV' ], - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #'instance creation' } diff --git a/src/Math-Matrix/PMSymmetricMatrix.class.st b/src/Math-Matrix/PMSymmetricMatrix.class.st index fbfce867b..2e8a34764 100644 --- a/src/Math-Matrix/PMSymmetricMatrix.class.st +++ b/src/Math-Matrix/PMSymmetricMatrix.class.st @@ -4,7 +4,7 @@ This class can be instantiated like DhbMatrix via #rows:, but the user has to ma Class { #name : #PMSymmetricMatrix, #superclass : #PMMatrix, - #category : 'Math-Matrix' + #category : #'Math-Matrix' } { #category : #'instance creation' } diff --git a/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st index 44f7ceeeb..1edaf980a 100644 --- a/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMSciKitLearnSVDFlipAlgorithm.class.st @@ -78,10 +78,10 @@ PMSciKitLearnSVDFlipAlgorithm >> signs [ { #category : #accessing } PMSciKitLearnSVDFlipAlgorithm >> uFlipped [ - ^ u dot: (self signMatrixForU). + ^ u hadamardProduct: (self signMatrixForU). ] { #category : #accessing } PMSciKitLearnSVDFlipAlgorithm >> vFlipped [ - ^ v dot: (self signMatrixForV) . + ^ v hadamardProduct: (self signMatrixForV) . ] diff --git a/src/Math-Tests-Core/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st index 84afe11c0..082e82fe0 100644 --- a/src/Math-Tests-Core/PMVectorTest.class.st +++ b/src/Math-Tests-Core/PMVectorTest.class.st @@ -164,6 +164,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 [ diff --git a/src/Math-Tests-Matrix/PMAdditionalTest.class.st b/src/Math-Tests-Matrix/PMAdditionalTest.class.st index eea0c4266..8b32fa46b 100644 --- a/src/Math-Tests-Matrix/PMAdditionalTest.class.st +++ b/src/Math-Tests-Matrix/PMAdditionalTest.class.st @@ -5,7 +5,7 @@ here are tests that would be in Math-Tests-DHB-Numerical, if it could construct Class { #name : #PMAdditionalTest, #superclass : #TestCase, - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #tests } diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 2c065d7bd..b27b24464 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMMatrixTest, #superclass : #TestCase, - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #tests } @@ -352,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 | @@ -428,7 +444,7 @@ PMMatrixTest >> testMatrixMultiplyElementwise [ | 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. + 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. diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 6f8a23303..930267b70 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMQRTest, #superclass : #TestCase, - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #running } diff --git a/src/Math-Tests-Matrix/PMRestTest.class.st b/src/Math-Tests-Matrix/PMRestTest.class.st index d4db439f1..667530dd8 100644 --- a/src/Math-Tests-Matrix/PMRestTest.class.st +++ b/src/Math-Tests-Matrix/PMRestTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMRestTest, #superclass : #TestCase, - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #tests } diff --git a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st index d3f6d1b79..43e06794e 100644 --- a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st +++ b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st @@ -35,7 +35,7 @@ Class { 'actualV', 'actualS' ], - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #'as yet unclassified' } diff --git a/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st b/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st index 0d6ad00be..f0a1e2870 100644 --- a/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMSymmetricMatrixTest, #superclass : #TestCase, - #category : 'Math-Tests-Matrix' + #category : #'Math-Tests-Matrix' } { #category : #tests } From e63cc43ddeb904b740ce592d4c77f21521196f62 Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Sun, 26 May 2019 22:30:10 +0530 Subject: [PATCH 131/161] Removed PMVector sum for speedup (#126) --- src/Math-Core/PMVector.class.st | 11 +---------- src/Math-Core/PMWeightedPoint.class.st | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 9a015f0ee..9185fd96e 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -20,7 +20,7 @@ Class { #name : #PMVector, #superclass : #Array, #type : #variable, - #category : #'Math-Core' + #category : 'Math-Core' } { #category : #'instance creation' } @@ -308,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-Core/PMWeightedPoint.class.st b/src/Math-Core/PMWeightedPoint.class.st index 68a6f6146..a7beea989 100644 --- a/src/Math-Core/PMWeightedPoint.class.st +++ b/src/Math-Core/PMWeightedPoint.class.st @@ -12,7 +12,7 @@ Class { 'weight', 'error' ], - #category : #'Math-Core' + #category : 'Math-Core' } { #category : #creation } From 7f3a8121300b90b97956931d7e0ac4294001a66e Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Sun, 26 May 2019 22:35:17 +0530 Subject: [PATCH 132/161] Implementing the t-SNE algorithm (#117) * Added "Hbeta" function for PMTSNE with test It is named as `entropyOf: andPRow: withBeta:`. Added a test for the method ensuring: - Original pVector reference is maintained - entropy is calculated correctly - pVector is calculated correctly * Added `reduceXToInputDims:` method for PMTSNE - Added corresponding test for new method. - Renamed `ndims` to `outputDims` - Renamed `initialdims` to `initialDims` - Added accessor `x` * Added method to get pairwise affinities in PMTSNE - The new function is called `computePairwiseAffinities` (as in original paper) - The old one is renamed to `computeLowDimentionalAffinities` - Removed x2p function (translated it's code to `computePairwiseAffinities`) - Also added tests * Added progress bar(Job) for PMTSNE Moved contents of the `start` method to `initializeJob`. * Added gradient descent in PMTSNE - Also added various accessors and instance vars - Classified existing methods - Added a test for `computePValues` --- src/Math-TSNE/PMTSNE.class.st | 451 +++++++++++++++++++----- src/Math-Tests-TSNE/PMTSNETest.class.st | 59 ++++ 2 files changed, 415 insertions(+), 95 deletions(-) diff --git a/src/Math-TSNE/PMTSNE.class.st b/src/Math-TSNE/PMTSNE.class.st index 251da7c2a..92f183245 100644 --- a/src/Math-TSNE/PMTSNE.class.st +++ b/src/Math-TSNE/PMTSNE.class.st @@ -3,28 +3,47 @@ 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. +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 : [ - 'ndims', - 'initialdims', + 'outputDims', + 'initialDims', 'perplexity', 'x', 'y', 'maxIter', - 'epsilon', 'sumY', 'initialMomentum', 'finalMomentum', - 'eta', - 'minGain' + 'learningRate', + 'minGain', + 'job', + 'computeErrorEvery' ], #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 | @@ -33,7 +52,6 @@ PMTSNE class >> example1 [ perplexity: 10; x: points; initialDims: 2; - epsilon: 5; start; y ] @@ -52,88 +70,296 @@ PMTSNE class >> gridDataGeneratorOf: size [ ^ PMMatrix rows: array ] +{ #category : #accessing } +PMTSNE >> computeErrorEvery [ + ^ computeErrorEvery +] + +{ #category : #accessing } +PMTSNE >> computeErrorEvery: aNumber [ + computeErrorEvery := aNumber +] + +{ #category : #accessing } +PMTSNE >> computeErrorEveryDefaultValue [ + ^ 10 +] + +{ #category : #'stepping and presenter' } +PMTSNE >> computeGradient: p withProgressUpdate: iteration [ + "Computes gradient of KL divergence" + + | num sumNum q pq dY tmp yiDiff error | + "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. + + (iteration % computeErrorEvery = 0) 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 '. iteration. '/'. maxIter.' error = '. error }). + job progress: (iteration/maxIter). + ]. + + ^ 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 [ -" -#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 + "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 : #'as yet unclassified' } +{ #category : #running } PMTSNE >> 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])) ). + "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 : #'as yet unclassified' } +{ #category : #running } PMTSNE >> computePairwiseDistances [ | sumX d tmp| - sumX := (x dot: x) sum. + 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 >> epsilon: aFloat [ - epsilon := aFloat +PMTSNE >> gradientDescent [ + "Tries to minimize the cost, which is KL divergence" + + | p gains iY momentum dY yMeanAccumulator | + job title: 'Step 3/3: Performing gradient descent'. + p := self computePValues. + gains := PMMatrix onesRows: x dimension x cols: outputDims. + iY := PMMatrix zerosRows: x dimension x cols: outputDims. + momentum := initialMomentum. + 1 to: maxIter do: [ :iteration | + dY := self computeGradient: p withProgressUpdate: iteration. + momentum := iteration < 20 + ifTrue: [ initialMomentum ] + ifFalse: [ finalMomentum ]. + 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 ]. + ] + ]. + iY := iY * momentum - ((dY hadamardProduct: gains) * learningRate). + y := y + iY. + yMeanAccumulator := PMVectorAccumulator new: outputDims. + y rowsDo: [ :row | + yMeanAccumulator accumulate: row. + ]. + y := PMMatrix rows: (y rowsCollect: [ :row | + row - (yMeanAccumulator average) + ]). + "Stop exaggeration" + (iteration = 100) ifTrue: [ p := p * (1/4) ]. + ]. ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PMTSNE >> initialDims [ - ^initialdims + ^ initialDims ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PMTSNE >> initialDims: aFloat [ - initialdims := aFloat + initialDims := aFloat ] -{ #category : #'as yet unclassified' } +{ #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 [ - maxIter := 1000. - initialMomentum := 0.5. - finalMomentum := 0.8. - eta := 500. - minGain := 0.01. + "These parameters rarely need to be modified" + maxIter := self maxIterDefaultValue. + initialMomentum := self initialMomentumDefaultValue. + finalMomentum := self finalMomentumDefaultValue. + learningRate := self learningRateDefaultValue. + minGain := self minGainDefaultValue. + computeErrorEvery := self computeErrorEveryDefaultValue. + 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 >> initializeUninitializedParameters [ perplexity ifNil: [ perplexity := self perplexityDefaultValue ]. - ndims ifNil: [ ndims := self ndimsDefaultValue ]. - initialdims ifNil: [ initialdims := self initialDimsDefaultValue ] + outputDims ifNil: [ outputDims := self outputDimsDefaultValue ]. + initialDims ifNil: [ initialDims := self initialDimsDefaultValue ] ] { #category : #initialization } @@ -143,7 +369,7 @@ PMTSNE >> initializeYWithRandomValues [ | a b rows columns d | rows := x dimension x. - columns := ndims. + columns := outputDims. d := PMNormalDistribution new:0 sigma: 1. a := (1 to: rows) collect: [ :row | @@ -154,12 +380,62 @@ PMTSNE >> initializeYWithRandomValues [ ] { #category : #accessing } -PMTSNE >> ndims [ - ^ ndims +PMTSNE >> learningRate [ + ^ learningRate ] -{ #category : #'as yet unclassified' } -PMTSNE >> ndimsDefaultValue [ +{ #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 ] @@ -173,58 +449,38 @@ PMTSNE >> perplexity: aFloat [ perplexity := aFloat ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PMTSNE >> perplexityDefaultValue [ ^ 30.0 ] { #category : #running } -PMTSNE >> 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; -" +PMTSNE >> reduceXToInputDims [ + "Runs PCA on X in order to reduce its dimensionality to initialDims dimensions." - "| analyzer i | - analyzer := PMPrincipalComponentAnalyser new: initialdims. - i := 1. - x dimension x - timesRepeat: [ analyzer accumulate: (x rowAt: i). - i := i + 1 ]. - ^ analyzer components" + self reduceXToInputDimsUsing: PMPrincipalComponentAnalyserJacobiTransformation. ] -{ #category : #accessing } -PMTSNE >> start [ - self initializeUninitializedParameters. - self runPcaOnX. - self initializeYWithRandomValues. - self x2p +{ #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 : #'stepping and presenter' } -PMTSNE >> step [ - self computePairwiseAffinities +{ #category : #running } +PMTSNE >> start [ + job run. ] -{ #category : #'as yet unclassified' } -PMTSNE >> 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 } +PMTSNE >> x [ + ^ x ] { #category : #accessing } @@ -236,3 +492,8 @@ PMTSNE >> x: aPMMatrix [ PMTSNE >> y [ ^ y ] + +{ #category : #accessing } +PMTSNE >> y: aNumber [ + y:= aNumber +] diff --git a/src/Math-Tests-TSNE/PMTSNETest.class.st b/src/Math-Tests-TSNE/PMTSNETest.class.st index c76c1cdd3..322b5cc15 100644 --- a/src/Math-Tests-TSNE/PMTSNETest.class.st +++ b/src/Math-Tests-TSNE/PMTSNETest.class.st @@ -1,9 +1,47 @@ +" +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 | @@ -13,6 +51,18 @@ PMTSNETest >> testComputePairwiseDistances [ 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 | @@ -22,3 +72,12 @@ PMTSNETest >> testInitialDimsSetByDefaultWithFifty [ 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))). +] From 7f241b834803c73ee983791d1fe65af421ae5b86 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 29 May 2019 09:01:59 +0100 Subject: [PATCH 133/161] [Issue 29] PMVector/PMMatrix >> #dot: does not compute a dot product. (#127) * [issue-29] Removed test for a deprecated message. * [issue-29] Replaced a call to a deprecated message, corrected a style violation. * [issue-29] Removed deprecated messages. --- src/Math-Core/PMVector.class.st | 17 +---------------- src/Math-Core/PMWeightedPoint.class.st | 2 +- src/Math-Matrix/PMMatrix.class.st | 8 +------- src/Math-Tests-Core/PMVectorTest.class.st | 14 -------------- src/Math-Tests-Matrix/PMMatrixTest.class.st | 18 ------------------ 5 files changed, 3 insertions(+), 56 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 9185fd96e..4370b0313 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -20,7 +20,7 @@ Class { #name : #PMVector, #superclass : #Array, #type : #variable, - #category : 'Math-Core' + #category : #'Math-Core' } { #category : #'instance creation' } @@ -167,21 +167,6 @@ PMVector >> cumsum [ ] -{ #category : #deprecated } -PMVector >> dot: 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 - -] - { #category : #operation } PMVector >> hadamardProduct: aVector [ "Answers the elementwise product of the receiver with aVector." diff --git a/src/Math-Core/PMWeightedPoint.class.st b/src/Math-Core/PMWeightedPoint.class.st index a7beea989..68a6f6146 100644 --- a/src/Math-Core/PMWeightedPoint.class.st +++ b/src/Math-Core/PMWeightedPoint.class.st @@ -12,7 +12,7 @@ Class { 'weight', 'error' ], - #category : 'Math-Core' + #category : #'Math-Core' } { #category : #creation } diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 900d3f209..597b1158c 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -407,12 +407,6 @@ PMMatrix >> dimension [ ^ self rows size @ (self rows at: 1) size ] -{ #category : #deprecated } -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. @@ -430,7 +424,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)]) ] diff --git a/src/Math-Tests-Core/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st index 082e82fe0..497f8a795 100644 --- a/src/Math-Tests-Core/PMVectorTest.class.st +++ b/src/Math-Tests-Core/PMVectorTest.class.st @@ -137,20 +137,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 [ diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index b27b24464..3b277e0f6 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -437,24 +437,6 @@ PMMatrixTest >> testMatrixMultiply [ self assert: ((c rowAt: 2) at: 3) equals: 4 ] -{ #category : #'linear algebra' } -PMMatrixTest >> testMatrixMultiplyElementwise [ - "Code Example 8.1" - - | 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 : #'linear algebra' } PMMatrixTest >> testMatrixPrincipalDiagonal [ | a | From aaad4b29501b6a56d7a81a9dab8cba73221521ab Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 29 May 2019 09:37:04 +0100 Subject: [PATCH 134/161] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f67a8908..b4372a983 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Metacello new load ``` -We have **797** green tests ! At the moment, all the development happens in the development branch. +We have **799** 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, From 7d2ef9f0eccaeb305e71c5f7c57d4c9fae8613bc Mon Sep 17 00:00:00 2001 From: nikhilpinnaparaju Date: Wed, 29 May 2019 19:26:21 +0530 Subject: [PATCH 135/161] Added test cases for subtraction between scalars and vectors and suggested quickfix (#121) * Added Basic Scalar subtraction test * added test for subtract PMVector from a Number * QuickFix of the scalar subtraction with PMVector Issue --- src/Math-Core/PMVector.class.st | 16 +++--------- src/Math-Core/PMWeightedPoint.class.st | 2 +- src/Math-Tests-Core/PMVectorTest.class.st | 30 +++++++++++++++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 4370b0313..7515f4613 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -20,7 +20,7 @@ Class { #name : #PMVector, #superclass : #Array, #type : #variable, - #category : #'Math-Core' + #category : 'Math-Core' } { #category : #'instance creation' } @@ -70,17 +70,9 @@ 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 } diff --git a/src/Math-Core/PMWeightedPoint.class.st b/src/Math-Core/PMWeightedPoint.class.st index 68a6f6146..a7beea989 100644 --- a/src/Math-Core/PMWeightedPoint.class.st +++ b/src/Math-Core/PMWeightedPoint.class.st @@ -12,7 +12,7 @@ Class { 'weight', 'error' ], - #category : #'Math-Core' + #category : 'Math-Core' } { #category : #creation } diff --git a/src/Math-Tests-Core/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st index 497f8a795..80fb47bc2 100644 --- a/src/Math-Tests-Core/PMVectorTest.class.st +++ b/src/Math-Tests-Core/PMVectorTest.class.st @@ -93,6 +93,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 | From 4e82ce3dd9d1fe8cf6413a4ea4109c4a2e61479f Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Thu, 30 May 2019 14:08:06 +0530 Subject: [PATCH 136/161] Fixed ZeroDivideError in PMStandardizationScaler (#128) This happened when one of the input features was constant. - Set scale to 1 for the feature which is constant - Added two tests for this case --- .../PMStandardizationScaler.class.st | 6 +++++- .../PMStandardizationScalerTest.class.st | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st index 51cfa51f4..78241d614 100644 --- a/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st +++ b/src/Math-PrincipalComponentAnalysis/PMStandardizationScaler.class.st @@ -22,7 +22,11 @@ PMStandardizationScaler >> mean [ { #category : #accessing } PMStandardizationScaler >> scale [ - ^ self variance sqrt + ^ self variance collect: [ :element | + | root | + root := element sqrt. + (root ~= 0) ifTrue: [ root ] ifFalse: [ 1.0 ] + ] ] { #category : #transforming } diff --git a/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st index 0f7e56d36..03c4a34fa 100644 --- a/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st +++ b/src/Math-Tests-PrincipalComponentAnalysis/PMStandardizationScalerTest.class.st @@ -40,6 +40,14 @@ PMStandardizationScalerTest >> testTransformAnotherMatrix [ 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 | @@ -48,3 +56,15 @@ PMStandardizationScalerTest >> testVariance [ 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) +] From 6bff4a15a1127720578a7fd32c9763318e26376b Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Fri, 31 May 2019 10:47:32 +0100 Subject: [PATCH 137/161] Remove old Math-RandomDistributionBased package from repo --- .../PMLaplaceGenerator.class.st | 41 ------------------- src/Math-RandomDistributionBased/package.st | 1 - 2 files changed, 42 deletions(-) delete mode 100644 src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st delete mode 100644 src/Math-RandomDistributionBased/package.st diff --git a/src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st b/src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st deleted file mode 100644 index 1b5c0bfe6..000000000 --- a/src/Math-RandomDistributionBased/PMLaplaceGenerator.class.st +++ /dev/null @@ -1,41 +0,0 @@ -" -I'm a random number generator whose values are distributed according to Laplace distribution. - -Ideally this class should be a subclass of RandomGenerator -however it is unclear how to implement peek. -" -Class { - #name : #PMLaplaceGenerator, - #superclass : #Object, - #instVars : [ - 'laplaceDistribution', - 'next' - ], - #category : 'Math-RandomDistributionBased' -} - -{ #category : #'instance creation' } -PMLaplaceGenerator class >> shape: peakValue scale: falloffValue [ - - ^ self new shape: peakValue scale: falloffValue -] - -{ #category : #accessing } -PMLaplaceGenerator >> next [ - - next := laplaceDistribution random. - ^ next -] - -{ #category : #accessing } -PMLaplaceGenerator >> peek [ - - next ifNil: [ self next. ]. - ^ next -] - -{ #category : #creation } -PMLaplaceGenerator >> shape: peakValue scale: falloffValue [ - - laplaceDistribution := PMLaplaceDistribution shape: peakValue scale: falloffValue -] 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' } From d1175d6a726eda9fed5f704109e064db45f162c2 Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Fri, 31 May 2019 21:20:51 +0530 Subject: [PATCH 138/161] Refactored PMTSNE to include steps (#131) New methods `step` and `postStep` have been added. `postStep` will contain all viz and debug methods. A new `stateVariables` contains required variables for the steps. --- src/Math-TSNE/PMTSNE.class.st | 136 +++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 44 deletions(-) diff --git a/src/Math-TSNE/PMTSNE.class.st b/src/Math-TSNE/PMTSNE.class.st index 92f183245..54fa41db3 100644 --- a/src/Math-TSNE/PMTSNE.class.st +++ b/src/Math-TSNE/PMTSNE.class.st @@ -21,7 +21,8 @@ Class { 'learningRate', 'minGain', 'job', - 'computeErrorEvery' + 'computeErrorEvery', + 'stateVariables' ], #category : #'Math-TSNE' } @@ -86,17 +87,21 @@ PMTSNE >> computeErrorEveryDefaultValue [ ] { #category : #'stepping and presenter' } -PMTSNE >> computeGradient: p withProgressUpdate: iteration [ +PMTSNE >> computeGradient [ "Computes gradient of KL divergence" - | num sumNum q pq dY tmp yiDiff error | + | num sumNum p q 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) ]. + stateVariables add: 'q'->q. + + p := stateVariables at: 'p'. pq := p - q. + dY := OrderedCollection new. 1 to: (x dimension x) do: [ :i | tmp := (pq rowAt: i) hadamardProduct: (num rowAt: i). @@ -106,20 +111,6 @@ PMTSNE >> computeGradient: p withProgressUpdate: iteration [ dY add: (tmp hadamardProduct: yiDiff) sum ]. dY := PMMatrix rows: dY. - - (iteration % computeErrorEvery = 0) 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 '. iteration. '/'. maxIter.' error = '. error }). - job progress: (iteration/maxIter). - ]. ^ dY ] @@ -269,35 +260,15 @@ PMTSNE >> finalMomentumDefaultValue [ PMTSNE >> gradientDescent [ "Tries to minimize the cost, which is KL divergence" - | p gains iY momentum dY yMeanAccumulator | job title: 'Step 3/3: Performing gradient descent'. - p := self computePValues. - gains := PMMatrix onesRows: x dimension x cols: outputDims. - iY := PMMatrix zerosRows: x dimension x cols: outputDims. - momentum := initialMomentum. + job progress: 0.0. + stateVariables add: 'p'->(self computePValues). + stateVariables add: 'gains'->(PMMatrix onesRows: x dimension x cols: outputDims). + stateVariables add: 'iY'->(PMMatrix zerosRows: x dimension x cols: outputDims). 1 to: maxIter do: [ :iteration | - dY := self computeGradient: p withProgressUpdate: iteration. - momentum := iteration < 20 - ifTrue: [ initialMomentum ] - ifFalse: [ finalMomentum ]. - 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 ]. - ] - ]. - iY := iY * momentum - ((dY hadamardProduct: gains) * learningRate). - y := y + iY. - yMeanAccumulator := PMVectorAccumulator new: outputDims. - y rowsDo: [ :row | - yMeanAccumulator accumulate: row. - ]. - y := PMMatrix rows: (y rowsCollect: [ :row | - row - (yMeanAccumulator average) - ]). - "Stop exaggeration" - (iteration = 100) ifTrue: [ p := p * (1/4) ]. + stateVariables add: 'iteration'->iteration. + self step. + self postStep. ]. ] @@ -340,6 +311,7 @@ PMTSNE >> initialize [ learningRate := self learningRateDefaultValue. minGain := self minGainDefaultValue. computeErrorEvery := self computeErrorEveryDefaultValue. + stateVariables := Dictionary new. self initializeJob. ] @@ -454,6 +426,12 @@ 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." @@ -478,6 +456,76 @@ PMTSNE >> start [ job run. ] +{ #category : #'stepping and presenter' } +PMTSNE >> step [ + | iteration gains iY dY momentum yMeanAccumulator p | + iteration := stateVariables at: 'iteration'. + gains := stateVariables at: 'gains'. + iY := stateVariables at: 'iY'. + p := stateVariables at: 'p'. + + dY := self computeGradient. + + "Momentum accelerates gradient descent by dampening one direction" + momentum := iteration < 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 ]). + + "Update state variables for the next step" + stateVariables add: 'gains'->gains. + stateVariables add: 'iY'->iY. + + "Stop early exaggeration on 100th iteration" + iteration = 100 + ifFalse: [ ^ self ]. + p := p * (1 / 4). + stateVariables add: 'p' -> p +] + +{ #category : #'stepping and presenter' } +PMTSNE >> updateProgressWithError [ + | error p q iteration | + iteration := stateVariables at: 'iteration'. + p := stateVariables at: 'p'. + q := stateVariables at: 'q'. + + iteration % computeErrorEvery = 0 + ifFalse: [ ^ self ]. + + 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 '. iteration. '/'. maxIter. ' error = '. error} + ). + job progress: iteration / maxIter. +] + { #category : #accessing } PMTSNE >> x [ ^ x From 1ea70f5c95d1e4fddfa6589a96f6e209a33aa5d8 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 3 Jun 2019 18:31:11 +0100 Subject: [PATCH 139/161] [Issue 105] Math-Random Package Is Messy - Improve Naming, Refactor Tests (#132) * [issue-105] Removed an obselete test. * [issue-105] Improved the name of the class. The class comment says it is a generator. * [issue-105] Improved the name of the class. * [issue-105] Extracted duplicate code to an intention-revealing method. * [issue-105] Extracted duplicate code to a helper method. * [issue-105] Inlined the method as it's only used in one place. * [issue-105] Improved the name of the method. * [issue-105] Corrected code style. * [issue-105] Improved the name of the method. * [issue-105] Removed obselete code. * [issue-105] Corrected the category. * [issue-105] Improved the names of the methods. * [issue-105] Improved the names of the method. * [issue-105] Removed obselete test. * [issue-105] Brought back a test deleted accidentally. * [issue-105] Made similar code even more similar. * [issue-105] Moved the code to a better place, an intention-revealing method. * [issue-105] Made the code consistent with that of the other tests. This reads a little better now. * [issue-105] Made similar code look the same, improved the name of a test method by using domain language. --- src/Math-Random/PMBinomialGenerator.class.st | 5 ++ .../PMLehmerRandomGenerator.class.st | 2 +- ...LinearCongruentialRandomGenerator.class.st | 2 +- ...> PMMarsagliaKissRandomGenerator.class.st} | 18 ++--- .../PMMersenneTwisterRandomGenerator.class.st | 4 +- ...MParkMillerMinimumRandomGenerator.class.st | 2 +- ...=> PMPseudoRandomNumberGenerator.class.st} | 28 +++---- .../PMBernoulliGeneratorTest.class.st | 11 --- .../PMBinomialGeneratorTest.class.st | 41 +++++----- .../PMExponentialGeneratorTest.class.st | 15 ++-- .../PMLaplaceGeneratorTest.class.st | 11 +-- .../PMLehmerRandomTest.class.st | 8 +- .../PMLinearCongruentialRandomTest.class.st | 8 +- .../PMNumberGeneratorTest.class.st | 2 +- .../PMPoissonGeneratorTest.class.st | 32 ++++---- ...PMPseudoRandomNumberGeneratorTest.class.st | 75 +++++++++++++++++++ .../PMRandomGeneratorTest.class.st | 74 ------------------ 17 files changed, 164 insertions(+), 174 deletions(-) rename src/Math-Random/{PMMarsagliaKissRandom.class.st => PMMarsagliaKissRandomGenerator.class.st} (79%) rename src/Math-Random/{PMRandomGenerator.class.st => PMPseudoRandomNumberGenerator.class.st} (84%) create mode 100644 src/Math-Tests-Random/PMPseudoRandomNumberGeneratorTest.class.st delete mode 100644 src/Math-Tests-Random/PMRandomGeneratorTest.class.st diff --git a/src/Math-Random/PMBinomialGenerator.class.st b/src/Math-Random/PMBinomialGenerator.class.st index 44d4ce551..fa3537ed3 100644 --- a/src/Math-Random/PMBinomialGenerator.class.st +++ b/src/Math-Random/PMBinomialGenerator.class.st @@ -21,6 +21,11 @@ PMBinomialGenerator class >> numberOfTrials: numberOfTrials probabilityOfSuccess yourself ] +{ #category : #accessing } +PMBinomialGenerator >> expectedValue [ + ^ numberOfTrials * probability . +] + { #category : #initialization } PMBinomialGenerator >> initialize [ self generator: PMParkMillerMinimumRandomGenerator new. diff --git a/src/Math-Random/PMLehmerRandomGenerator.class.st b/src/Math-Random/PMLehmerRandomGenerator.class.st index 3659ff66c..3dc1ba7a6 100644 --- a/src/Math-Random/PMLehmerRandomGenerator.class.st +++ b/src/Math-Random/PMLehmerRandomGenerator.class.st @@ -5,7 +5,7 @@ PMLehmerRandomGenerator new next " Class { #name : #PMLehmerRandomGenerator, - #superclass : #PMRandomGenerator, + #superclass : #PMPseudoRandomNumberGenerator, #category : #'Math-Random' } diff --git a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st index c8b99c60a..543ad6704 100644 --- a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st +++ b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st @@ -5,7 +5,7 @@ PMLinearCongruentialRandomGenerator new next. " Class { #name : #PMLinearCongruentialRandomGenerator, - #superclass : #PMRandomGenerator, + #superclass : #PMPseudoRandomNumberGenerator, #category : #'Math-Random' } diff --git a/src/Math-Random/PMMarsagliaKissRandom.class.st b/src/Math-Random/PMMarsagliaKissRandomGenerator.class.st similarity index 79% rename from src/Math-Random/PMMarsagliaKissRandom.class.st rename to src/Math-Random/PMMarsagliaKissRandomGenerator.class.st index cfa6fd571..1660910c9 100644 --- a/src/Math-Random/PMMarsagliaKissRandom.class.st +++ b/src/Math-Random/PMMarsagliaKissRandomGenerator.class.st @@ -10,8 +10,8 @@ Instance Variables " Class { - #name : #PMMarsagliaKissRandom, - #superclass : #PMRandomGenerator, + #name : #PMMarsagliaKissRandomGenerator, + #superclass : #PMPseudoRandomNumberGenerator, #instVars : [ 'kernelRand1', 'kernelRand2' @@ -20,20 +20,20 @@ Class { } { #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/PMMersenneTwisterRandomGenerator.class.st b/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st index 616aa72fb..dd16ed7f7 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' } diff --git a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st index b67d468d9..53c0653c0 100644 --- a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st +++ b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st @@ -5,7 +5,7 @@ PMParkMillerMinimumRandomGenerator new next " Class { #name : #PMParkMillerMinimumRandomGenerator, - #superclass : #PMRandomGenerator, + #superclass : #PMPseudoRandomNumberGenerator, #category : #'Math-Random' } 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-Tests-Random/PMBernoulliGeneratorTest.class.st b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st index 2ff085cdb..ec209a95a 100644 --- a/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBernoulliGeneratorTest.class.st @@ -7,17 +7,6 @@ Class { #category : #'Math-Tests-Random' } -{ #category : #tests } -PMBernoulliGeneratorTest >> 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 } PMBernoulliGeneratorTest >> testNextYieldsOneOrZero [ | gen | diff --git a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st index 42196e9af..0b5adaf46 100644 --- a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st @@ -4,27 +4,6 @@ Class { #category : #'Math-Tests-Random' } -{ #category : #tests } -PMBinomialGeneratorTest >> testBinomialGeneratorConvergesToMean [ - "Its purpose is to verify correct convergence of the binomial distribution, - should be Normal (np, np(1-p))" - - | gen nums mean probabilityOfSuccess numberOfTrials | - probabilityOfSuccess := (Random seed: 0.0) next sqrt. - numberOfTrials := 1000. - gen := PMBinomialGenerator - numberOfTrials: numberOfTrials - probabilityOfSuccess: probabilityOfSuccess. - - nums := OrderedCollection new. - (1 to: numberOfTrials) do: [ :ea | nums add: gen next ]. - - mean := numberOfTrials * probabilityOfSuccess. - self assert: nums min > (mean * (1 - 0.2)). - self assert: nums max < (mean * (1 + 0.2)). - self assert: (nums average - mean) abs < 5 -] - { #category : #tests } PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfOneAlwaysReturnNumberOfTrials [ | g numberOfTrials | @@ -56,3 +35,23 @@ PMBinomialGeneratorTest >> testBinomialGeneratorWithSuccessProbabilityOfZeroAlwa 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 := OrderedCollection new. + numberOfTrials timesRepeat: [ sample add: gen next ]. + + 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/PMExponentialGeneratorTest.class.st b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st index a951ef334..c18e39354 100644 --- a/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st @@ -13,14 +13,14 @@ PMExponentialGeneratorTest >> testGenerator [ eg := PMExponentialGenerator new. self assert: (eg generator isKindOf: PMExponentialGenerator defaultGeneratorClass). - self assert: (eg generator isKindOf: PMRandomGenerator). + 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 >> testPeekAlwaysAnswersTheSame [ +PMExponentialGeneratorTest >> testPeekIsIdempotent [ | eg | eg := PMExponentialGenerator new. self assert: eg peek equals: eg peek. @@ -31,10 +31,11 @@ PMExponentialGeneratorTest >> testPeekAlwaysAnswersTheSame [ PMExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [ "testing a random sample seems suspect. We use a 5% interval here" - | eg arr | - eg := PMExponentialGenerator mean: 10. - arr := Array new: 10000. - arr := arr collect: [ :each | eg next ]. + | gen sample | + gen := PMExponentialGenerator mean: 10. + sample := Array new: 10000. + sample := sample collect: [ :each | gen next ]. + self - assert: (arr average between: eg mean * 0.95 and: eg mean * 1.05) + assert: (sample average between: gen mean * 0.95 and: gen mean * 1.05) ] diff --git a/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st index 1b1cb51d8..2573b654e 100644 --- a/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMLaplaceGeneratorTest.class.st @@ -4,14 +4,9 @@ Class { #category : #'Math-Tests-Random' } -{ #category : #'as yet unclassified' } -PMLaplaceGeneratorTest >> classToTest [ - ^ PMLaplaceGenerator -] - -{ #category : #accessing } -PMLaplaceGeneratorTest >> testPeekAlwaysReplyTheSameValue [ +{ #category : #tests } +PMLaplaceGeneratorTest >> testPeekIsIdempotent [ | g | - g := self classToTest shape: 0.5 scale: 0.3. + g := PMLaplaceGenerator shape: 0.5 scale: 0.3. self assert: g peek equals: g peek ] diff --git a/src/Math-Tests-Random/PMLehmerRandomTest.class.st b/src/Math-Tests-Random/PMLehmerRandomTest.class.st index 21f3ce4a4..55740df49 100644 --- a/src/Math-Tests-Random/PMLehmerRandomTest.class.st +++ b/src/Math-Tests-Random/PMLehmerRandomTest.class.st @@ -14,15 +14,15 @@ PMLehmerRandomTest >> testNextBetweenZeroAndOne [ ] { #category : #tests } -PMLehmerRandomTest >> testPeekAlwaysReplyTheSameValue [ +PMLehmerRandomTest >> testPeekAnswersSameAsNext [ | g | g := PMLehmerRandomGenerator new. - self assert: g peek equals: g peek + self assert: g peek equals: g next ] { #category : #tests } -PMLehmerRandomTest >> 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/PMLinearCongruentialRandomTest.class.st b/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st index d1dafadb4..08ae003cb 100644 --- a/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st +++ b/src/Math-Tests-Random/PMLinearCongruentialRandomTest.class.st @@ -14,15 +14,15 @@ PMLinearCongruentialRandomTest >> testNextBetweenZeroAndOne [ ] { #category : #tests } -PMLinearCongruentialRandomTest >> testPeekAlwaysReplyTheSameValue [ +PMLinearCongruentialRandomTest >> testPeekAnswersSameAsNext [ | g | g := PMLinearCongruentialRandomGenerator new. - self assert: g peek equals: g peek + self assert: g peek equals: g next ] { #category : #tests } -PMLinearCongruentialRandomTest >> 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/PMNumberGeneratorTest.class.st b/src/Math-Tests-Random/PMNumberGeneratorTest.class.st index cd37c918c..82c45070b 100644 --- a/src/Math-Tests-Random/PMNumberGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMNumberGeneratorTest.class.st @@ -5,7 +5,7 @@ Class { } { #category : #tests } -PMNumberGeneratorTest >> 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 index 7f1607863..c8e399e1d 100644 --- a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st @@ -5,19 +5,17 @@ Class { } { #category : #tests } -PMPoissonGeneratorTest >> testPeekReturnsSameAsNext [ - | poisson random | +PMPoissonGeneratorTest >> testPeekIsIdempotent [ + | poisson | poisson := PMPoissonGenerator lambda: 0.1. - random := poisson peek. - self assert: random equals: poisson next + self assert: poisson peek equals: poisson peek ] { #category : #tests } -PMPoissonGeneratorTest >> testPeekReturnsSameTwice [ - | poisson random | +PMPoissonGeneratorTest >> testPeekReturnsSameAsNext [ + | poisson | poisson := PMPoissonGenerator lambda: 0.1. - random := poisson peek. - self assert: random equals: poisson peek + self assert: poisson peek equals: poisson next ] { #category : #tests } @@ -31,16 +29,18 @@ PMPoissonGeneratorTest >> testPeekWorksAfterSampling [ ] { #category : #tests } -PMPoissonGeneratorTest >> testSampleAverageConvergesToLambda [ +PMPoissonGeneratorTest >> testSampleMeanConvergesToLambda [ "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) + | gen sample | + gen := PMPoissonGenerator lambda: 5. "((1000 atRandom: Random new) -1)" + gen generator seed: 42. "added for non-randomness" + + sample := OrderedCollection new. + 1000 timesRepeat: [ sample add: gen next ]. + + self assert: sample average >= (gen lambda * 0.8). + self assert: sample average <= (gen lambda * 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/PMRandomGeneratorTest.class.st b/src/Math-Tests-Random/PMRandomGeneratorTest.class.st deleted file mode 100644 index ca33218ce..000000000 --- a/src/Math-Tests-Random/PMRandomGeneratorTest.class.st +++ /dev/null @@ -1,74 +0,0 @@ -Class { - #name : #PMRandomGeneratorTest, - #superclass : #TestCase, - #category : #'Math-Tests-Random' -} - -{ #category : #tests } -PMRandomGeneratorTest >> testGeneratorStreamDoesntRespondToContents [ - PMRandomGenerator subclasses - do: [ :cls | - | gen | - gen := cls new. - self should: [ gen contents ] raise: Error ] -] - -{ #category : #tests } -PMRandomGeneratorTest >> testGeneratorStreamIsReadOnly [ - PMRandomGenerator subclasses - do: [ :cls | - | gen | - gen := cls new. - self shouldnt: [ gen isWriteable ]. - self assert: gen isReadable ] -] - -{ #category : #tests } -PMRandomGeneratorTest >> testGeneratorStreamNeverEnds [ - PMRandomGenerator subclasses do: - [:cls | | gen | - gen := cls new. - self shouldnt: [gen atEnd]]. -] - -{ #category : #tests } -PMRandomGeneratorTest >> 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 } -PMRandomGeneratorTest >> testGeneratorStreamProducesNumbers [ - PMRandomGenerator subclasses - do: [ :cls | - | gen | - gen := cls new. - self assert: gen next isNumber. - self assert: gen next isFloat ] -] - -{ #category : #tests } -PMRandomGeneratorTest >> testGeneratorStreamProducesRandomNumbers [ - PMRandomGenerator subclasses do: - [:cls | | gen value | - gen := cls new. - value := gen next. - self shouldnt: [gen next = value]]. -] - -{ #category : #tests } -PMRandomGeneratorTest >> 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 ] -] From 54c495917d49105d52024b86b65c9a57ec0e07c5 Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Tue, 4 Jun 2019 13:10:50 +0530 Subject: [PATCH 140/161] Added vizualization examples for PMTSNE (#133) - Renamed variable `computeErrorEvery` to `updateErrorEvery` - Added `updateError` variable which calculates error only when true - Added grid vizualization example - Added linked-rings vizualization and generator --- src/Math-TSNE/PMTSNE.class.st | 239 ++++++++++++++++++++++++++-------- 1 file changed, 186 insertions(+), 53 deletions(-) diff --git a/src/Math-TSNE/PMTSNE.class.st b/src/Math-TSNE/PMTSNE.class.st index 54fa41db3..ddeaaea0c 100644 --- a/src/Math-TSNE/PMTSNE.class.st +++ b/src/Math-TSNE/PMTSNE.class.st @@ -21,8 +21,13 @@ Class { 'learningRate', 'minGain', 'job', - 'computeErrorEvery', - 'stateVariables' + 'updateProgressEvery', + 'updateError', + 'iterations', + 'p', + 'q', + 'gains', + 'iY' ], #category : #'Math-TSNE' } @@ -57,7 +62,89 @@ PMTSNE class >> example1 [ y ] -{ #category : #'as yet unclassified' } +{ #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." @@ -71,35 +158,42 @@ PMTSNE class >> gridDataGeneratorOf: size [ ^ PMMatrix rows: array ] -{ #category : #accessing } -PMTSNE >> computeErrorEvery [ - ^ computeErrorEvery -] +{ #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" -{ #category : #accessing } -PMTSNE >> computeErrorEvery: aNumber [ - computeErrorEvery := aNumber -] - -{ #category : #accessing } -PMTSNE >> computeErrorEveryDefaultValue [ - ^ 10 + | 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 p q pq dY tmp yiDiff | + | 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) ]. - stateVariables add: 'q'->q. - - p := stateVariables at: 'p'. + pq := p - q. dY := OrderedCollection new. @@ -262,11 +356,8 @@ PMTSNE >> gradientDescent [ job title: 'Step 3/3: Performing gradient descent'. job progress: 0.0. - stateVariables add: 'p'->(self computePValues). - stateVariables add: 'gains'->(PMMatrix onesRows: x dimension x cols: outputDims). - stateVariables add: 'iY'->(PMMatrix zerosRows: x dimension x cols: outputDims). - 1 to: maxIter do: [ :iteration | - stateVariables add: 'iteration'->iteration. + self initializeStateVariables. + 1 to: maxIter do: [ :i | self step. self postStep. ]. @@ -310,8 +401,9 @@ PMTSNE >> initialize [ finalMomentum := self finalMomentumDefaultValue. learningRate := self learningRateDefaultValue. minGain := self minGainDefaultValue. - computeErrorEvery := self computeErrorEveryDefaultValue. - stateVariables := Dictionary new. + updateProgressEvery := self updateProgressEveryDefaultValue. + updateError := self updateErrorDefaultValue. + iterations := 0. self initializeJob. ] @@ -327,6 +419,13 @@ PMTSNE >> initializeJob [ ] 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 ]. @@ -351,6 +450,11 @@ PMTSNE >> initializeYWithRandomValues [ y := PMMatrix rows: a ] +{ #category : #accessing } +PMTSNE >> iterations [ + ^ iterations +] + { #category : #accessing } PMTSNE >> learningRate [ ^ learningRate @@ -458,16 +562,12 @@ PMTSNE >> start [ { #category : #'stepping and presenter' } PMTSNE >> step [ - | iteration gains iY dY momentum yMeanAccumulator p | - iteration := stateVariables at: 'iteration'. - gains := stateVariables at: 'gains'. - iY := stateVariables at: 'iY'. - p := stateVariables at: 'p'. + | dY momentum yMeanAccumulator | dY := self computeGradient. "Momentum accelerates gradient descent by dampening one direction" - momentum := iteration < 20 + momentum := iterations < 20 ifTrue: [ initialMomentum ] ifFalse: [ finalMomentum ]. @@ -490,40 +590,73 @@ PMTSNE >> step [ y rowsDo: [ :row | yMeanAccumulator accumulate: row ]. y := PMMatrix rows: (y rowsCollect: [ :row | row - yMeanAccumulator average ]). - - "Update state variables for the next step" - stateVariables add: 'gains'->gains. - stateVariables add: 'iY'->iY. + iterations := iterations + 1. "Stop early exaggeration on 100th iteration" - iteration = 100 + iterations = 100 ifFalse: [ ^ self ]. p := p * (1 / 4). - stateVariables add: 'p' -> p +] + +{ #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 p q iteration | - iteration := stateVariables at: 'iteration'. - p := stateVariables at: 'p'. - q := stateVariables at: 'q'. + | error | - iteration % computeErrorEvery = 0 + (iterations % updateProgressEvery = 0) ifFalse: [ ^ self ]. - - 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. + + "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 '. iteration. '/'. maxIter. ' error = '. error} + {'Step 3/3: Performing gradient descent '. iterations. '/'. maxIter. ' error = '. error} ). - job progress: iteration / maxIter. + job progress: iterations / maxIter. ] { #category : #accessing } From d65800e0ab1d5dc67dc0043aa028ae87e9fb1307 Mon Sep 17 00:00:00 2001 From: nikhilpinnaparaju Date: Thu, 6 Jun 2019 00:42:34 +0530 Subject: [PATCH 141/161] Ability to convert vectors to matrices and vice versa (#129) * Added Basic Scalar subtraction test * added test for subtract PMVector from a Number * QuickFix of the scalar subtraction with PMVector Issue * Added methods for intuitive conversion between vectors and matrices * Tests for matrix <-> vector interconversions * Fixed implementation of reshape --- src/Math-Core/PMVector.class.st | 23 +++++++++++++++++++ .../PMJacobiTransformationHelper.class.st | 2 +- src/Math-Matrix/PMLUPDecomposition.class.st | 2 +- .../PMLargestEigenValueFinder.class.st | 2 +- .../PMLinearEquationSystem.class.st | 2 +- src/Math-Matrix/PMMatrix.class.st | 7 +++++- .../PMSingularMatrixError.class.st | 2 +- .../PMSingularValueDecomposition.class.st | 2 +- src/Math-Matrix/PMSymmetricMatrix.class.st | 2 +- src/Math-Tests-Core/PMVectorTest.class.st | 22 ++++++++++++++++++ .../PMAdditionalTest.class.st | 2 +- src/Math-Tests-Matrix/PMMatrixTest.class.st | 9 +++++++- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- src/Math-Tests-Matrix/PMRestTest.class.st | 2 +- .../PMSingularValueDecompositionTest.class.st | 2 +- .../PMSymmetricMatrixTest.class.st | 2 +- 16 files changed, 71 insertions(+), 14 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 7515f4613..1bc96b8e6 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -122,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:." @@ -237,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 [ diff --git a/src/Math-Matrix/PMJacobiTransformationHelper.class.st b/src/Math-Matrix/PMJacobiTransformationHelper.class.st index 7675cc075..be6f6f9ce 100644 --- a/src/Math-Matrix/PMJacobiTransformationHelper.class.st +++ b/src/Math-Matrix/PMJacobiTransformationHelper.class.st @@ -8,7 +8,7 @@ Class { 'eigenvalues', 'eigenvectors' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMLUPDecomposition.class.st b/src/Math-Matrix/PMLUPDecomposition.class.st index fe6392d72..75dbe790d 100644 --- a/src/Math-Matrix/PMLUPDecomposition.class.st +++ b/src/Math-Matrix/PMLUPDecomposition.class.st @@ -26,7 +26,7 @@ Class { 'permutation', 'parity' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMLargestEigenValueFinder.class.st b/src/Math-Matrix/PMLargestEigenValueFinder.class.st index 81478c9ab..06dfac388 100644 --- a/src/Math-Matrix/PMLargestEigenValueFinder.class.st +++ b/src/Math-Matrix/PMLargestEigenValueFinder.class.st @@ -20,7 +20,7 @@ Class { 'eigenvector', 'transposeEigenvector' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #information } diff --git a/src/Math-Matrix/PMLinearEquationSystem.class.st b/src/Math-Matrix/PMLinearEquationSystem.class.st index 3e5b8e3b6..8b021c459 100644 --- a/src/Math-Matrix/PMLinearEquationSystem.class.st +++ b/src/Math-Matrix/PMLinearEquationSystem.class.st @@ -22,7 +22,7 @@ Class { 'rows', 'solutions' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #creation } diff --git a/src/Math-Matrix/PMMatrix.class.st b/src/Math-Matrix/PMMatrix.class.st index 597b1158c..c4042dd64 100644 --- a/src/Math-Matrix/PMMatrix.class.st +++ b/src/Math-Matrix/PMMatrix.class.st @@ -15,7 +15,7 @@ Class { 'rows', 'lupDecomposition' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #example } @@ -243,6 +243,11 @@ PMMatrix >> asSymmetricMatrix [ ^ 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." diff --git a/src/Math-Matrix/PMSingularMatrixError.class.st b/src/Math-Matrix/PMSingularMatrixError.class.st index 6aa9392a8..6bf7cc4d7 100644 --- a/src/Math-Matrix/PMSingularMatrixError.class.st +++ b/src/Math-Matrix/PMSingularMatrixError.class.st @@ -5,7 +5,7 @@ some calculations dont work with singular matrices and result eg with errors lik Class { #name : #PMSingularMatrixError, #superclass : #ArithmeticError, - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #accessing } diff --git a/src/Math-Matrix/PMSingularValueDecomposition.class.st b/src/Math-Matrix/PMSingularValueDecomposition.class.st index 65a2723e3..9753ef804 100644 --- a/src/Math-Matrix/PMSingularValueDecomposition.class.st +++ b/src/Math-Matrix/PMSingularValueDecomposition.class.st @@ -40,7 +40,7 @@ Class { 'signU', 'signV' ], - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #'instance creation' } diff --git a/src/Math-Matrix/PMSymmetricMatrix.class.st b/src/Math-Matrix/PMSymmetricMatrix.class.st index 2e8a34764..fbfce867b 100644 --- a/src/Math-Matrix/PMSymmetricMatrix.class.st +++ b/src/Math-Matrix/PMSymmetricMatrix.class.st @@ -4,7 +4,7 @@ This class can be instantiated like DhbMatrix via #rows:, but the user has to ma Class { #name : #PMSymmetricMatrix, #superclass : #PMMatrix, - #category : #'Math-Matrix' + #category : 'Math-Matrix' } { #category : #'instance creation' } diff --git a/src/Math-Tests-Core/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st index 80fb47bc2..6624f6f8b 100644 --- a/src/Math-Tests-Core/PMVectorTest.class.st +++ b/src/Math-Tests-Core/PMVectorTest.class.st @@ -59,6 +59,17 @@ PMVectorTest >> testAsArray [ self assert: #(1 2 3 4) asPMVector asArray equals: #(1 2 3 4) ] +{ #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 | @@ -299,6 +310,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-Matrix/PMAdditionalTest.class.st b/src/Math-Tests-Matrix/PMAdditionalTest.class.st index 8b32fa46b..eea0c4266 100644 --- a/src/Math-Tests-Matrix/PMAdditionalTest.class.st +++ b/src/Math-Tests-Matrix/PMAdditionalTest.class.st @@ -5,7 +5,7 @@ here are tests that would be in Math-Tests-DHB-Numerical, if it could construct Class { #name : #PMAdditionalTest, #superclass : #TestCase, - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #tests } diff --git a/src/Math-Tests-Matrix/PMMatrixTest.class.st b/src/Math-Tests-Matrix/PMMatrixTest.class.st index 3b277e0f6..32a26fd66 100644 --- a/src/Math-Tests-Matrix/PMMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMMatrixTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMMatrixTest, #superclass : #TestCase, - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #tests } @@ -672,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" diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 930267b70..6f8a23303 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMQRTest, #superclass : #TestCase, - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #running } diff --git a/src/Math-Tests-Matrix/PMRestTest.class.st b/src/Math-Tests-Matrix/PMRestTest.class.st index 667530dd8..d4db439f1 100644 --- a/src/Math-Tests-Matrix/PMRestTest.class.st +++ b/src/Math-Tests-Matrix/PMRestTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMRestTest, #superclass : #TestCase, - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #tests } diff --git a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st index 43e06794e..d3f6d1b79 100644 --- a/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st +++ b/src/Math-Tests-Matrix/PMSingularValueDecompositionTest.class.st @@ -35,7 +35,7 @@ Class { 'actualV', 'actualS' ], - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #'as yet unclassified' } diff --git a/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st b/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st index f0a1e2870..0d6ad00be 100644 --- a/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st +++ b/src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st @@ -1,7 +1,7 @@ Class { #name : #PMSymmetricMatrixTest, #superclass : #TestCase, - #category : #'Math-Tests-Matrix' + #category : 'Math-Tests-Matrix' } { #category : #tests } From 1c683ecc38397fd14b3a36eb2113d2dbfcf43da9 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Fri, 14 Jun 2019 19:08:57 +0100 Subject: [PATCH 142/161] [Issue 105] Refactor Math-Random Tests Package (#134) * [issue-105] Removed unnecessary dot. * [issue-105] The code is doing the same thing differently, so I have made it look exactly the same in order that we can extract the duplication elsewhere later. * [issue-105] Extracted code to an intention-revealing method. * [issue-105] Improved the name of the test method and extracted generation of a sample to an intention revealing variable. * [issue-105] Extracted the generation of a sample to an intention-revealing method. * [issue-105] In the case of the Poisson generator I understand that lambda is the mean/expected value (cf. wikipedia). * [issue-105] Introduced the expectedValue message for consistency, in view of removing the mean message completely. * [issue-105] Corrected the message name to conform to the Pharo style. * [issue-105] Extracted duplicate code to a test helper class. * [issue-105] Removed obselete comment. * [issue-105] Made the assertion the same as used in the exponential generator test in hopes of moving it to a super class. * [issue-105] Corrected and improved the name of the class and the method therein. * [issue-105] Improved code formatting, replaced implicitly duplicate code with the random sample generator class. * [issue-105] Improved the names of the temporary variables. * [issue-105] Improved the name of the assertion. * [issue-105] Removed an obselete comment. * [issue-105] Improved the name of the assertion. * [issue-105] Made the name of the test clearer. * [issue-105] Inlined the temp variable as it does not enhance understandability. --- src/Math-Random/PMBinomialGenerator.class.st | 2 +- .../PMExponentialGenerator.class.st | 7 ++++ src/Math-Random/PMPoissonGenerator.class.st | 6 ++++ .../PMBinomialGeneratorTest.class.st | 6 ++-- .../PMExponentialGeneratorTest.class.st | 8 ++--- .../PMGaussianGeneratorTest.class.st | 35 +++++++++++-------- .../PMPoissonGeneratorTest.class.st | 16 ++++----- src/Math-Tests-Random/PMRandomSample.class.st | 21 +++++++++++ 8 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 src/Math-Tests-Random/PMRandomSample.class.st diff --git a/src/Math-Random/PMBinomialGenerator.class.st b/src/Math-Random/PMBinomialGenerator.class.st index fa3537ed3..7bead9d2d 100644 --- a/src/Math-Random/PMBinomialGenerator.class.st +++ b/src/Math-Random/PMBinomialGenerator.class.st @@ -23,7 +23,7 @@ PMBinomialGenerator class >> numberOfTrials: numberOfTrials probabilityOfSuccess { #category : #accessing } PMBinomialGenerator >> expectedValue [ - ^ numberOfTrials * probability . + ^ numberOfTrials * probability ] { #category : #initialization } diff --git a/src/Math-Random/PMExponentialGenerator.class.st b/src/Math-Random/PMExponentialGenerator.class.st index 76d920c1d..f20112889 100644 --- a/src/Math-Random/PMExponentialGenerator.class.st +++ b/src/Math-Random/PMExponentialGenerator.class.st @@ -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/PMPoissonGenerator.class.st b/src/Math-Random/PMPoissonGenerator.class.st index 6f36edac9..6ab07568f 100644 --- a/src/Math-Random/PMPoissonGenerator.class.st +++ b/src/Math-Random/PMPoissonGenerator.class.st @@ -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-Tests-Random/PMBinomialGeneratorTest.class.st b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st index 0b5adaf46..07bfb2814 100644 --- a/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMBinomialGeneratorTest.class.st @@ -48,9 +48,9 @@ PMBinomialGeneratorTest >> testSampleMeanConvergesToExpectedValue [ numberOfTrials: numberOfTrials probabilityOfSuccess: probabilityOfSuccess. - sample := OrderedCollection new. - numberOfTrials timesRepeat: [ sample add: gen next ]. - + 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/PMExponentialGeneratorTest.class.st b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st index c18e39354..855788f63 100644 --- a/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMExponentialGeneratorTest.class.st @@ -28,14 +28,14 @@ PMExponentialGeneratorTest >> testPeekIsIdempotent [ ] { #category : #tests } -PMExponentialGeneratorTest >> testSampleMeanConvergesToDistributionMean [ +PMExponentialGeneratorTest >> testSampleMeanConvergesToExpectedValue [ "testing a random sample seems suspect. We use a 5% interval here" | gen sample | gen := PMExponentialGenerator mean: 10. - sample := Array new: 10000. - sample := sample collect: [ :each | gen next ]. + + sample := PMRandomSample ofSize: 10000 usingGenerator: gen. self - assert: (sample average between: gen mean * 0.95 and: gen mean * 1.05) + 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 index f452f5b82..e919251f9 100644 --- a/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMGaussianGeneratorTest.class.st @@ -5,32 +5,37 @@ Class { } { #category : #utilities } -PMGaussianGeneratorTest >> 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 +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 >> testDistribution [ +PMGaussianGeneratorTest >> testSampleMeanAndStandardDeviationConvergeToDistributionValues [ | mean standardDeviation g | mean := 147. standardDeviation := 17. - g := (PMGaussianGenerator new). + g := PMGaussianGenerator new. g mean: mean; standardDeviation: standardDeviation; generator: PMLinearCongruentialRandomGenerator new. g generator seed: 42. - self checkDistributionOf: g withExpectedMeans: mean andExpectedStandardDeviation: standardDeviation. + + self + assertSampleGeneratedBy: g + convergesToExpectedValue: mean + andStandardDeviation: standardDeviation. "Replicated test in a different place" mean := 0. - standardDeviation := 10 . - g mean: mean; - standardDeviation: standardDeviation. - self checkDistributionOf: g withExpectedMeans: mean andExpectedStandardDeviation: standardDeviation. + standardDeviation := 10. + g + mean: mean; + standardDeviation: standardDeviation. + self + assertSampleGeneratedBy: g + convergesToExpectedValue: mean + andStandardDeviation: standardDeviation ] diff --git a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st index c8e399e1d..d4d89644b 100644 --- a/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st +++ b/src/Math-Tests-Random/PMPoissonGeneratorTest.class.st @@ -29,18 +29,16 @@ PMPoissonGeneratorTest >> testPeekWorksAfterSampling [ ] { #category : #tests } -PMPoissonGeneratorTest >> testSampleMeanConvergesToLambda [ +PMPoissonGeneratorTest >> testSampleMeanConvergesToExpectedValue [ "law of large numbers" "made non-random, old random version in comments" | gen sample | - gen := PMPoissonGenerator lambda: 5. "((1000 atRandom: Random new) -1)" - gen generator seed: 42. "added for non-randomness" - - sample := OrderedCollection new. - 1000 timesRepeat: [ sample add: gen next ]. - - self assert: sample average >= (gen lambda * 0.8). - self assert: sample average <= (gen lambda * 1.2) + 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/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 + +] From 7d2197fe0281bc50541a7e2f55b7b67ad41085ac Mon Sep 17 00:00:00 2001 From: Atharva Khare Date: Mon, 24 Jun 2019 20:44:17 +0530 Subject: [PATCH 143/161] [#122] Fix PMVector comparison operators (#123) - Also added relevant tests for the operators --- src/Math-Core/PMVector.class.st | 8 ++++---- src/Math-Tests-Core/PMVectorTest.class.st | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Math-Core/PMVector.class.st b/src/Math-Core/PMVector.class.st index 1bc96b8e6..4820c79d1 100644 --- a/src/Math-Core/PMVector.class.st +++ b/src/Math-Core/PMVector.class.st @@ -77,14 +77,14 @@ PMVector >> - aVectorOrNumber [ { #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]. + "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 } diff --git a/src/Math-Tests-Core/PMVectorTest.class.st b/src/Math-Tests-Core/PMVectorTest.class.st index 6624f6f8b..5ee2228ee 100644 --- a/src/Math-Tests-Core/PMVectorTest.class.st +++ b/src/Math-Tests-Core/PMVectorTest.class.st @@ -60,6 +60,26 @@ PMVectorTest >> testAsArray [ ] { #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 . From 5b86b2fd597010853ffb441f5763032e904ac611 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Thu, 27 Jun 2019 09:16:23 +0100 Subject: [PATCH 144/161] [Issue 105] Math-Random package is messy (#135) * [issue-105] Moved the incrementing to the bottom so we can extract the tempering to a method in the next refactor. * [issue-105] Extracted the tempering section to an intention-revealing method. * [issue-105] Corrected the categorisation to match the super class's. * [issue-105] Corrected the categorisation to match the super class's. * [issue-105] Corrected the initialisation. --- ...LinearCongruentialRandomGenerator.class.st | 4 +- .../PMMersenneTwisterRandomGenerator.class.st | 47 ++++++++++++------- ...MParkMillerMinimumRandomGenerator.class.st | 4 +- 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st index 543ad6704..1ad21e0f9 100644 --- a/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st +++ b/src/Math-Random/PMLinearCongruentialRandomGenerator.class.st @@ -9,7 +9,7 @@ Class { #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/PMMersenneTwisterRandomGenerator.class.st b/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st index dd16ed7f7..5a3906bd0 100644 --- a/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st +++ b/src/Math-Random/PMMersenneTwisterRandomGenerator.class.st @@ -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/PMParkMillerMinimumRandomGenerator.class.st b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st index 53c0653c0..429b57b8f 100644 --- a/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st +++ b/src/Math-Random/PMParkMillerMinimumRandomGenerator.class.st @@ -9,7 +9,7 @@ Class { #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." From 62f7ad7dbd77730fad9dabf0912ab0ed505c367c Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Mon, 1 Jul 2019 18:33:41 +0100 Subject: [PATCH 145/161] [Issue 106] Support For coveralls.io (#137) * [issue-106] Fake it til we make it - just test the random package for now. * [issue-106] Corrected structure. * [issue-106] Added another package to track. * [issue-106] Added another two packages. * [issue-106] Added the benchmark packages. * [issue-106] Added the Chromosome, Clustering, Complex and Core packages. * [issue-106] Added the Distribution packages. * [issue-106] Added the FFT and FunctionFit packages. * [issue-106] The FFT and FunctionFit packages seem broken so we replace it with the K-packages. * [issue-106] Added the Math-Matrix (and any Math-M*) package. * [issue-106] Added all Math-N* packages. * [issue-106] Added the Math-O* packages. * [issue-106] The Math-ODE packages seems to cause the CI job to run out of memory, so let's proceed to the Math-P* packages. * [issue-106] Added the Math-Q* packages. * [issue-106] Added the coverage status to the README. * [issue-106] Replaced hard-coded package name with something that keeps overage open to additional R-packages. * [issue-106] Added the TNSE package. --- .smalltalk.ston | 19 +++++++++++++++++-- README.md | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index bd5d0c25d..5c38fa7b4 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -6,7 +6,22 @@ SmalltalkCISpec { #platforms : [ #pharo ] } ], - #testing : { - #packages : [ 'Math-*' ] + #testing : { + #coverage : { + #packages : [ + 'Math-Accuracy-ODE', + 'Math-ArbitraryPrecisionFloat', + 'Math-AutomaticDifferenciation', + 'Math-B*', + 'Math-C*', + 'Math-D*', + 'Math-K*', + 'Math-M*', + 'Math-N*', + 'Math-P*', + 'Math-Q*', + 'Math-R*', + 'Math-TNSE' ] } + } } diff --git a/README.md b/README.md index b4372a983..3a93c2167 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) [![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea) -[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg)](https://coveralls.io/github/PolyMathOrg/PolyMath) +[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg?branch=issue-106)](https://coveralls.io/github/PolyMathOrg/PolyMath?branch=issue-106) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE) Screenshot 2019-04-24 at 11 12 57 From fe58eeffe95aa1facb28387b28c66944cde0f3ac Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 2 Jul 2019 09:07:46 +0100 Subject: [PATCH 146/161] [issue-106] Support For coveralls.io (#138) * [issue-106] The link to the badge should point to the development branch. * [issue-106] We can at least cover the FunctionFit package. --- .smalltalk.ston | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.smalltalk.ston b/.smalltalk.ston index 5c38fa7b4..8cf3b0c76 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -15,6 +15,7 @@ SmalltalkCISpec { 'Math-B*', 'Math-C*', 'Math-D*', + 'Math-FunctionFit', 'Math-K*', 'Math-M*', 'Math-N*', diff --git a/README.md b/README.md index 3a93c2167..074be636c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) [![Build status](https://ci.appveyor.com/api/projects/status/3tvarh2xi22max8h?svg=true)](https://ci.appveyor.com/project/SergeStinckwich/polymath-88bea) -[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg?branch=issue-106)](https://coveralls.io/github/PolyMathOrg/PolyMath?branch=issue-106) +[![Coverage Status](https://coveralls.io/repos/github/PolyMathOrg/PolyMath/badge.svg?branch=development)](https://coveralls.io/github/PolyMathOrg/PolyMath?branch=development) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/LICENSE) Screenshot 2019-04-24 at 11 12 57 From f661415c392ba4be633768aff0f24a16808e5cb5 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Wed, 17 Jul 2019 08:59:38 +0100 Subject: [PATCH 147/161] [Issue 106] Refactor Math-Accuracy (#139) * [issue-106] Improved message names. * [issue-106] The happy path should not be the guard clause; normally the subclass should respond to the message. * [issue-106] Improved the name of the block variable. * [issue-106] Moved related code closer together. initRest goes on to populate parameters, arguments and results. * [issue-106] The asString message send is redundant. * [issue-106] Improved the name of the temp variable. * [issue-106] Improved the names of the block variables. * [issue-106] The asString is redundant as the tests remain green. * [issue-106] Extracted code to an intention-revealing method. * [issue-106] Simplified the calculation of the occurence of a key. * [issue-106] Inlined the temporary variable as it is now redundant. * [issue-106] Extracted an code to an intention-revealing local temp and improved ormatting. * [issue-106] Inlined the variable as it over wrote the earlier assignment. * [issue-106] The initialize call looks like a special case, so transformed it into a guard clause. * [issue-106] Improved code formatting. * [issue-106] The check is redundant now because we have got passed the guard clause. * [issue-106] The nil check is unnecessary now given the ifNone: call. The call to join: is for efficiency (O(n) vs O(n^2) for concatenation). This was recommended by Pharo. * [issue-106] Reverted the change as we are only concatenating two strings which is not super inefficient. * [issue-106] Removed obselete code. --- src/Math-Accuracy-Core/PMAccuracy.class.st | 58 ++++++++++--------- .../PMAccuracyTest.class.st | 15 ----- .../PMAccuracyTestExample.class.st | 15 ----- 3 files changed, 30 insertions(+), 58 deletions(-) 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-Tests-Accuracy/PMAccuracyTest.class.st b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st index d56b08d84..cb68ab31c 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyTest.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyTest.class.st @@ -38,11 +38,6 @@ PMAccuracyTest >> testArgumentAt [ self assert: (a argumentAt: 'Ccc') equals: #(#(1) #(1.1) #(0.9)) ] -{ #category : #tests } -PMAccuracyTest >> testArgumentError [ - self should: [ a testArgumentError ] raise: Error -] - { #category : #tests } PMAccuracyTest >> testAsArray [ self assert: (a asArray: 'bla') equals: #('bla'). @@ -271,11 +266,6 @@ PMAccuracyTest >> testParameterAt [ self assert: (a parameterAt: 'Fff') isNil ] -{ #category : #tests } -PMAccuracyTest >> testParameterError [ -self should: [a testParameterError ]raise: Error -] - { #category : #tests } PMAccuracyTest >> testPrintOn [ | s | @@ -300,11 +290,6 @@ PMAccuracyTest >> testReport [ self assert: (a report beginsWith: 'Report for: PMAccuracyTestExample') ] -{ #category : #tests } -PMAccuracyTest >> testResultError [ -self should: [a testResultError ]raise: Error -] - { #category : #tests } PMAccuracyTest >> testResultsKeyForAtPosition [ self assert: (a resultsKeyFor: 'Aaa' AtPosition: 2) equals: #(4 4). diff --git a/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st index f536164d0..70c90e4a5 100644 --- a/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st +++ b/src/Math-Tests-Accuracy/PMAccuracyTestExample.class.st @@ -110,11 +110,6 @@ PMAccuracyTestExample >> tearDown [ count :=count-(1/5). ] -{ #category : #private } -PMAccuracyTestExample >> testArgumentError [ -self argument: #(#(1) #(2)). -] - { #category : #private } PMAccuracyTestExample >> testGetterAaa [ ^{ self parameter .self argument.self resultsAt: 'Aaa'.self numberOfDifferentParametersAt: 'Aaa'.self numberOfDifferentResultsAt:'Aaa'} @@ -124,13 +119,3 @@ PMAccuracyTestExample >> testGetterAaa [ PMAccuracyTestExample >> testGetterBbb [ ^{ self parameter .self argument.self resultsAt: 'Bbb'.self numberOfDifferentParametersAt: 'Bbb'.self numberOfDifferentResultsAt:'Bbb'} ] - -{ #category : #private } -PMAccuracyTestExample >> testParameterError [ -self parameter: #(#(1) #(2)). -] - -{ #category : #private } -PMAccuracyTestExample >> testResultError [ -self result:#(1). -] From ed6d93f32c76e26e5beb50f320bca144f2dca8f6 Mon Sep 17 00:00:00 2001 From: Hemal Varambhia Date: Tue, 23 Jul 2019 11:00:46 +0100 Subject: [PATCH 148/161] [Issue 106] Get Math-ODE Covered By Coveralls.io (#140) * [issue-106] Cover all packages starting with Math-O. * [issue-106] Back to hard-coding the package name (Travis ran out of memory). --- .smalltalk.ston | 1 + 1 file changed, 1 insertion(+) diff --git a/.smalltalk.ston b/.smalltalk.ston index 8cf3b0c76..32951b60a 100644 --- a/.smalltalk.ston +++ b/.smalltalk.ston @@ -19,6 +19,7 @@ SmalltalkCISpec { 'Math-K*', 'Math-M*', 'Math-N*', + 'Math-ODE', 'Math-P*', 'Math-Q*', 'Math-R*', From a64c247c7190d8a182e504aa4b1ac9b99d3281a0 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Mon, 5 Aug 2019 19:43:33 +0100 Subject: [PATCH 149/161] Use double dispatch for PMDualNumber (#142) * Clean tests of AutomaticDifferenciation * Use double dispatch for + * Double dispatch for * in DualNumber * Use double dispatch for *,+ and /. Now all tests are green again * Add a test about derivatives * PMDualNumber is now a subclass of Number and not Magnitude. * Add conjugated and real method (to support dual numbers with complex numbers). Add support in PMComplex classes also. Add green tests. * Use absSquared instead of abs2 * Remove constant comments * Fix formatting * Reformat correctly PMHyperDualNumber --- .../Number.extension.st | 15 + .../PMDualNumber.class.st | 104 +++-- .../PMGradient.class.st | 6 +- .../PMHyperDualNumber.class.st | 207 +++++---- src/Math-Complex/PMComplex.class.st | 8 +- src/Math-Complex/PMComplex.extension.st | 14 +- .../PMDualNumberTest.class.st | 309 +++++++------ .../PMGradientAndHessianTest.class.st | 26 +- .../PMHyperDualNumberTest.class.st | 435 ++++++++++++------ 9 files changed, 707 insertions(+), 417 deletions(-) create mode 100644 src/Math-AutomaticDifferenciation/Number.extension.st 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-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-Complex/PMComplex.extension.st b/src/Math-Complex/PMComplex.extension.st index 5cf918b4d..efe456833 100644 --- a/src/Math-Complex/PMComplex.extension.st +++ b/src/Math-Complex/PMComplex.extension.st @@ -17,13 +17,6 @@ PMComplex >> productWithVector: aVector [ ^ aVector collect: [ :each | each * self ] ] -{ #category : #'*Math-Complex' } -PMComplex >> random [ - "analog to Number>>random. However, the only bound is that the abs of the produced complex is less than the length of the receive. The receiver effectively defines a disc within which the random element can be produced." - ^ self class random * self - -] - { #category : #'*Math-Complex' } PMComplex class >> random [ "Answers a random number with abs between 0 and 1." @@ -31,6 +24,13 @@ PMComplex class >> random [ ^ self abs: 1.0 random arg: 2 * Float pi random ] +{ #category : #'*Math-Complex' } +PMComplex >> random [ + "analog to Number>>random. However, the only bound is that the abs of the produced complex is less than the length of the receive. The receiver effectively defines a disc within which the random element can be produced." + ^ self class random * self + +] + { #category : #'*Math-Complex' } PMComplex >> subtractToPolynomial: aPolynomial [ ^ aPolynomial addNumber: self negated diff --git a/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st index 29f213b28..3809029b6 100644 --- a/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMDualNumberTest.class.st @@ -19,18 +19,16 @@ PMDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ { #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. - + 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 . - + self assertEquality: three negated abs and: three ] { #category : #tests } @@ -45,18 +43,21 @@ PMDualNumberTest >> testAccessing [ { #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). + 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). + | 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' } @@ -73,9 +74,22 @@ PMDualNumberTest >> testArcSin [ { #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). + 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 } @@ -94,21 +108,42 @@ PMDualNumberTest >> testConverting [ { #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). + 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). + 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' } @@ -125,14 +160,17 @@ PMDualNumberTest >> testEqual [ { #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) ). - + 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' } @@ -170,11 +208,13 @@ PMDualNumberTest >> testLn [ { #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). + 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' } @@ -185,97 +225,100 @@ PMDualNumberTest >> testNegated [ { #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. - - - - - + 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') . + | 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)). - - - + | 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. + 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). + 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. + 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: oneone. -self deny: three 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' } @@ -291,15 +334,17 @@ PMDualNumberTest >> testSqrt [ { #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. + 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. + 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' } @@ -316,23 +361,19 @@ PMDualNumberTest >> testTan [ { #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. - - - - - + 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 index 52f3c6021..33b7ca7be 100644 --- a/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMGradientAndHessianTest.class.st @@ -32,15 +32,19 @@ PMGradientAndHessianTest >> test [ { #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)))) . + | 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 index f54bd3d84..087ca9158 100644 --- a/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st +++ b/src/Math-Tests-AutomaticDifferenciation/PMHyperDualNumberTest.class.st @@ -21,18 +21,29 @@ PMHyperDualNumberTest >> assertEquality: aDualNumber and: anotherDualNumber [ { #category : #running } PMHyperDualNumberTest >> 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. - +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 . - + self assertEquality: three negated abs and: three ] { #category : #tests } @@ -49,22 +60,40 @@ PMHyperDualNumberTest >> testAccessing [ { #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). + 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: 1eps1eps2:0)arcCos. -self assert:(a value closeTo: 0). -self assert:(a eps< -1e6). -self assert:(a eps2< -1e6). -self assert:(a eps1eps2< -1e6). - + | 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' } @@ -113,21 +142,48 @@ PMHyperDualNumberTest >> testConverting [ { #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). + 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). + 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' } @@ -151,13 +207,36 @@ PMHyperDualNumberTest >> testEqual [ { #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)). - + 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' } @@ -211,11 +290,25 @@ PMHyperDualNumberTest >> testLn [ { #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). + 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' } @@ -229,103 +322,150 @@ PMHyperDualNumberTest >> testNegated [ { #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. - - - - - + 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') . + | 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). - - - + | 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. + 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)). + 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. + 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: oneone. -self deny: three 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' } @@ -353,16 +493,28 @@ PMHyperDualNumberTest >> testSqrt [ { #category : #'tests-mathematical functions' } PMHyperDualNumberTest >> 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. + 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. + 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' } @@ -377,23 +529,24 @@ PMHyperDualNumberTest >> testTan [ { #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. - - - - - + 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 ] From b24c7c5dedf46bbbeb162ad3902a60a449329851 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:15:44 +0100 Subject: [PATCH 150/161] [skip ci] --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 074be636c..ba8a1b7df 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,16 @@ -# PolyMath +

+

PolyMath

+

+ Ready-to-use components for interactive web applications + framework agnostic integration +
+ Explore the docs » +
+
+ Report a defect + | + Request feature +

+

[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build Status](https://travis-ci.org/PolyMathOrg/PolyMath.svg?branch=master)](https://travis-ci.org/PolyMathOrg/PolyMath) From 89d14f57a2a9b61587dfc83d0d71b65aa2e30c12 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:17:05 +0100 Subject: [PATCH 151/161] [skip CI] --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba8a1b7df..acb6d874d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@

PolyMath

- Ready-to-use components for interactive web applications + framework agnostic integration + Doing numerical computations in Pharo
Explore the docs »

- Report a defect + Report a defect | - Request feature + Request feature

From d24567b75414126fd7e9bb8bedf7983b9ca95ef9 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:20:17 +0100 Subject: [PATCH 152/161] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index acb6d874d..c39cb08e0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

+

PolyMath

Doing numerical computations in Pharo From e997987452ce38e1e290defe546da14026fb0471 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:20:59 +0100 Subject: [PATCH 153/161] [skip CI] --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index c39cb08e0..76724f84d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -

-

PolyMath

+

PolyMath

Doing numerical computations in Pharo
From 3e417027dc5bea1df2790be7a36f6e900559e6ff Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:22:32 +0100 Subject: [PATCH 154/161] [skip CI] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76724f84d..3ffda7a4f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

PolyMath +

PolyMath

Doing numerical computations in Pharo
From ddbad7f77b4aec07758a99952141457351817000 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:23:01 +0100 Subject: [PATCH 155/161] [skip CI] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ffda7a4f..598895c95 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

PolyMath +

PolyMath

Doing numerical computations in Pharo
From 35c7c92c997bdc15e44a9ec497a8698afceb1157 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:28:06 +0100 Subject: [PATCH 156/161] [skip CI] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 598895c95..510b86dae 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Metacello new load ``` -We have **799** green tests ! At the moment, all the development happens in the development branch. +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, From a003a08600d8a6460499b79295ddd6578409111b Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:35:22 +0100 Subject: [PATCH 157/161] [skip CI] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 510b86dae..f513adbdd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

PolyMath

- Doing numerical computations in Pharo + Scientific Computing with Pharo
Explore the docs »
From d92fa4bdf28a48644ca878560f2e738c27f2af08 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 16:37:35 +0100 Subject: [PATCH 158/161] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f513adbdd..e3507e799 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ You can load the code in a fresh Pharo 7.0 image with: ```Smalltalk Metacello new - repository: 'github://PolyMathOrg/PolyMath:development/src'; + repository: 'github://PolyMathOrg/PolyMath:master/src'; baseline: 'PolyMath'; load ``` @@ -51,7 +51,7 @@ To install PolyMath in your Pharo image you can just execute the following scrip ```Smalltalk Metacello new - githubUser: 'PolyMathOrg' project: 'PolyMath' commitish: 'development' path: 'src'; + githubUser: 'PolyMathOrg' project: 'PolyMath' commitish: 'master' path: 'src'; baseline: 'PolyMath'; load ``` @@ -61,7 +61,7 @@ To add PolyMath to your baseline just add this: ```Smalltalk spec baseline: 'PolyMath' - with: [ spec repository: 'github://PolyMathOrg/PolyMath:development/src' ] + with: [ spec repository: 'github://PolyMathOrg/PolyMath:master/src' ] ``` From 5c9b4621f3dbe3a5a7f7d4d19822c579e6fb255c Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Tue, 20 Aug 2019 17:04:07 +0100 Subject: [PATCH 159/161] [skip CI] --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c70fe89ec..258ee2814 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ In a fresh Pharo 7.0 image, load last development version of Polymath : ```Smalltalk Metacello new - githubUser: 'XXX' project: 'PolyMath' commitish: 'development' path: 'src'; + githubUser: 'XXX' project: 'PolyMath' commitish: 'master' path: 'src'; baseline: 'PolyMath'; load. ``` @@ -51,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. +This project uses 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. +- **release** : This branch contains the releases of this project. ## Hot fix From 453046d07a517938dd5bc6bf65190d0d27efaad0 Mon Sep 17 00:00:00 2001 From: Serge Stinckwich Date: Wed, 21 Aug 2019 10:54:37 +0100 Subject: [PATCH 160/161] [skip CI] We are using Trunk Based development after 1.0 release --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 258ee2814..7c4de85e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,10 +51,10 @@ Thus, it should be safe to depend on a fixed major version and moving minor vers # Branch management -This project uses trunk-based development: https://trunkbaseddevelopment.com/ +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. +- **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 From ee42a7509f5712f782384521f8565e1aa2fdeb81 Mon Sep 17 00:00:00 2001 From: Max Leske Date: Sat, 31 Aug 2019 23:58:19 +0200 Subject: [PATCH 161/161] Updated SMark version to 1.0.3 (#148) --- src/BaselineOfPolyMath/BaselineOfPolyMath.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st index 170622d77..57a688763 100644 --- a/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st +++ b/src/BaselineOfPolyMath/BaselineOfPolyMath.class.st @@ -180,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' ] ]