Skip to content

Commit d269822

Browse files
Merge pull request #58 from PolyMathOrg/hemalvarambhia-issue-48
Hemalvarambhia issue 48
2 parents ee8345e + 1c22772 commit d269822

File tree

6 files changed

+74
-19
lines changed

6 files changed

+74
-19
lines changed

src/BaselineOfPolyMath/BaselineOfPolyMath.class.st

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ BaselineOfPolyMath >> baseline: spec [
5656
package: 'Math-Physics-Constants';
5757
package: 'Math-PrincipalComponentAnalysis' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Matrix' 'Math-Polynomials') ];
5858
package: 'Math-Quantile';
59-
package: 'Math-Quaternion' with: [ spec requires: #('Math-Complex') ];
60-
package: 'Math-QuaternionExtensions' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Quaternion' 'Math-Polynomials') ];
59+
package: 'Math-Quaternion' with: [ spec requires: #('Math-Complex' 'Math-DHB-Numerical' 'Math-Polynomials') ];
6160
package: 'Math-Random';
6261
package: 'Math-RandomDistributionBased' with: [ spec requires: #('Math-DHB-Numerical' 'Math-Polynomials') ];
6362
package: 'Math-Series';
@@ -87,7 +86,7 @@ BaselineOfPolyMath >> baseline: spec [
8786
group: 'Accuracy' with: #('Math-Accuracy-ODE' 'Math-Accuracy-Core');
8887
group: 'Benchmarks' with: #('Math-Benchmarks-ODE' 'Math-Benchmarks-KDTree');
8988
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');
90-
group: 'Extensions' with: #('Math-Clustering' 'Math-Number-Extensions' 'Math-QuaternionExtensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' 'Math-KernelSmoothing' 'Math-RandomDistributionBased' 'Math-KolmogorovSmirnov');
89+
group: 'Extensions' with: #('Math-Clustering' 'Math-Number-Extensions' 'Math-Chromosome' 'Math-PrincipalComponentAnalysis' 'Math-FunctionFit' 'Math-AutomaticDifferenciation' 'Math-KernelSmoothing' 'Math-RandomDistributionBased' 'Math-KolmogorovSmirnov');
9190
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');
9291
group: 'default' with: #('Core' 'Extensions' 'Tests' 'Benchmarks' 'Accuracy') ]
9392
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Extension { #name : #PMPolynomial }
22

3-
{ #category : #'*Math-QuaternionExtensions' }
3+
{ #category : #'*Math-Quaternion' }
44
PMPolynomial >> adaptToQuaternion: rcvr andSend: selector [
55
^(self class coefficients: (Array with: rcvr) ) perform: selector with: self
66
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Extension { #name : #PMVector }
22

3-
{ #category : #'*Math-QuaternionExtensions' }
3+
{ #category : #'*Math-Quaternion' }
44
PMVector >> adaptToQuaternion: aQuaternion andSend: aByteSymbol [
55
^ self collect: [ :ea | aQuaternion perform: aByteSymbol with: ea ]
66
]

src/Math-Quaternion/Quaternion.class.st

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ Quaternion class >> qr: qr qi: qi qj: qj qk: qk [
5555
qk: qk
5656
]
5757

58+
{ #category : #'*Math-Quaternion' }
59+
Quaternion class >> random [
60+
"Answers a random quaternion with abs at most one."
61+
62+
^ (0.5 - Float random)
63+
i: (0.5 - Float random)
64+
j: (0.5 - Float random)
65+
k: (0.5 - Float random).
66+
]
67+
5868
{ #category : #'constants access' }
5969
Quaternion class >> zero [
6070
^self
@@ -173,6 +183,16 @@ Quaternion >> adaptToInteger: rcvr andSend: selector [
173183
^ rcvr asQuaternion perform: selector with: self
174184
]
175185

186+
{ #category : #'*Math-Quaternion' }
187+
Quaternion >> addPolynomial: aPolynomial [
188+
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
189+
Initial code: 19/4/99
190+
191+
added to Quaternion 11 May 2012 Daniel Uber
192+
"
193+
^aPolynomial addNumber: self
194+
]
195+
176196
{ #category : #accessing }
177197
Quaternion >> angle [
178198
"answer the rotation angle associated with the receiver"
@@ -232,6 +252,13 @@ Quaternion >> cosh [
232252
^(self exp + self negated exp) / 2
233253
]
234254

255+
{ #category : #'*Math-Quaternion' }
256+
Quaternion >> dividingPolynomial: aPolynomial [
257+
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
258+
Initial code: 17/4/99 "
259+
^aPolynomial timesNumber: (1 / self)
260+
]
261+
235262
{ #category : #'mathematical functions' }
236263
Quaternion >> exp [
237264
"Answer the receiver exponential"
@@ -369,6 +396,14 @@ Quaternion >> printOn: aStream [
369396
self storeOn: aStream
370397
]
371398

399+
{ #category : #'*Math-Quaternion' }
400+
Quaternion >> productWithVector: aVector [
401+
"Answers a new vector product of the receiver with aVector.
402+
(c) Copyrights Didier BESSET, 1999, all rights reserved.
403+
Initial code: 11/2/99 "
404+
^aVector collect: [ :each | each * self]
405+
]
406+
372407
{ #category : #accessing }
373408
Quaternion >> qi [
374409
^qi
@@ -439,6 +474,12 @@ Quaternion >> raisedToInteger: operand [
439474
^ result
440475
]
441476

477+
{ #category : #'*Math-Quaternion' }
478+
Quaternion >> random [
479+
"analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
480+
^ self class random * self.
481+
]
482+
442483
{ #category : #accessing }
443484
Quaternion >> real [
444485
"answer the real part of the receiver"
@@ -538,6 +579,13 @@ Quaternion >> storeOn: aStream [
538579
aStream nextPut: $)
539580
]
540581

582+
{ #category : #'*Math-Quaternion' }
583+
Quaternion >> subtractToPolynomial: aPolynomial [
584+
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
585+
Initial code: 19/4/99 "
586+
^aPolynomial addNumber: self negated
587+
]
588+
541589
{ #category : #'mathematical functions' }
542590
Quaternion >> tan [
543591
"Answer the receiver tangent"
@@ -555,6 +603,15 @@ Quaternion >> tanh [
555603
^(ep - em) / (ep + em)
556604
]
557605

606+
{ #category : #'*Math-Quaternion' }
607+
Quaternion >> timesPolynomial: aPolynomial [
608+
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
609+
Initial code: 17/4/99
610+
added to Complex class 12 May 2012, Daniel Uber
611+
"
612+
^aPolynomial timesNumber: self
613+
]
614+
558615
{ #category : #accessing }
559616
Quaternion >> unreal [
560617
"answer the unreal part of the receiver"

src/Math-QuaternionExtensions/Quaternion.extension.st renamed to src/Math-Quaternion/Quaternion.extension.st

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Extension { #name : #Quaternion }
22

3-
{ #category : #'*Math-QuaternionExtensions' }
3+
{ #category : #'*Math-Quaternion' }
44
Quaternion >> addPolynomial: aPolynomial [
55
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
66
Initial code: 19/4/99
@@ -10,23 +10,29 @@ Quaternion >> addPolynomial: aPolynomial [
1010
^aPolynomial addNumber: self
1111
]
1212

13-
{ #category : #'*Math-QuaternionExtensions' }
13+
{ #category : #'*Math-Quaternion' }
1414
Quaternion >> dividingPolynomial: aPolynomial [
1515
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
1616
Initial code: 17/4/99 "
1717
^aPolynomial timesNumber: (1 / self)
1818
]
1919

20-
{ #category : #'*Math-QuaternionExtensions' }
20+
{ #category : #'*Math-Quaternion' }
2121
Quaternion >> productWithVector: aVector [
2222
"Answers a new vector product of the receiver with aVector.
2323
(c) Copyrights Didier BESSET, 1999, all rights reserved.
2424
Initial code: 11/2/99 "
2525
^aVector collect: [ :each | each * self]
2626
]
2727

28-
{ #category : #'*Math-QuaternionExtensions' }
29-
Quaternion classSide >> random [
28+
{ #category : #'*Math-Quaternion' }
29+
Quaternion >> random [
30+
"analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
31+
^ self class random * self.
32+
]
33+
34+
{ #category : #'*Math-Quaternion' }
35+
Quaternion class >> random [
3036
"Answers a random quaternion with abs at most one."
3137

3238
^ (0.5 - Float random)
@@ -35,20 +41,14 @@ Quaternion classSide >> random [
3541
k: (0.5 - Float random).
3642
]
3743

38-
{ #category : #'*Math-QuaternionExtensions' }
39-
Quaternion >> random [
40-
"analog to Number>>random. The resulting quaternion will have abs at most that of the receiver"
41-
^ self class random * self.
42-
]
43-
44-
{ #category : #'*Math-QuaternionExtensions' }
44+
{ #category : #'*Math-Quaternion' }
4545
Quaternion >> subtractToPolynomial: aPolynomial [
4646
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
4747
Initial code: 19/4/99 "
4848
^aPolynomial addNumber: self negated
4949
]
5050

51-
{ #category : #'*Math-QuaternionExtensions' }
51+
{ #category : #'*Math-Quaternion' }
5252
Quaternion >> timesPolynomial: aPolynomial [
5353
"(c) Copyrights Didier BESSET, 1999, all rights reserved.
5454
Initial code: 17/4/99

src/Math-QuaternionExtensions/package.st

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)