File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010 PROJECT_NAME : MathVectorMatrix-${{ matrix.smalltalk }}
1111 strategy :
1212 matrix :
13- smalltalk : [ Pharo64-9.0 , Pharo64-10, Pharo64-11 ]
13+ smalltalk : [Pharo64-13 , Pharo64-14 ]
1414 name : ${{ matrix.smalltalk }}
1515 steps :
1616 - uses : actions/checkout@v3
1919 smalltalk-image : ${{ matrix.smalltalk }}
2020 - run : smalltalkci -s ${{ matrix.smalltalk }}
2121 shell : bash
22- timeout-minutes : 15
22+ timeout-minutes : 15
Original file line number Diff line number Diff line change 11<p align =" center " ><img alt =" PolyMath " src =" https://raw.githubusercontent.com/PolyMathOrg/PolyMath/master/assets/logos/logo.png " style =" width : 25% ; height : 25% " >
2- <h1 align =" center " >[Vector Matrix]</h1 >
2+ <h1 align =" center " >[PolyMath: Vector Matrix]</h1 >
33 <p align =" center " >
44 Scientific Computing with Pharo
55 <br>
1818
1919## Description
2020
21- A project to manage the data structures of PolyMaths . It currently includes the Vector and Matrix Pharo implementation.
21+ A project to manage the data structures of PolyMath . It currently includes the Vector and Matrix Pharo implementation.
2222
2323## Installation
2424
@@ -28,9 +28,7 @@ You can load all the packages into a fresh Pharo image by going to the Playgroun
2828 Metacello new
2929 baseline: 'MathVectorMatrix';
3030 repository: 'github://PolyMathOrg/vector-matrix/src';
31- onWarningLog;
32- onConflictUseIncoming;
33- load ]
31+ load
3432```
3533
3634This should load the default version of the project (you can also specify another version or branch).
Original file line number Diff line number Diff line change @@ -352,14 +352,7 @@ PMMatrixTest >> testMatrixAddSizeMismatch [
352352 self should: [ b transpose + a ] raise: SizeMismatch
353353]
354354
355- { #category : ' comparing' }
356- PMMatrixTest >> testMatrixCloseTo [
357- self assert: ((PMMatrix rows: #(#(1.00001 2.00002) #(3.00001 4.00002) )) closeTo: (PMMatrix rows: #(#(1.00002 2.00001) #(3.00002 4.00001) ))).
358- self assert: (PMMatrix rows: #(#(1.00001 2.00002) #(3.00001 4.00002) )) closeTo: (PMMatrix rows: #(#(1.00002 2.00001) #(3.00002 4.00001) )). " Double check that the TestAsserter >> #assert:closeTo: functions properly here."
359- self deny: ((PMMatrix rows: #(#(1.00001 2.00004) #(3.00001 4.00004) )) closeTo: (PMMatrix rows: #(#(1.00004 2.00001) #(3.00004 4.00001) ))).
360- ]
361-
362- { #category : ' comparing' }
355+ { #category : #comparing }
363356PMMatrixTest >> testMatrixCloseToPrecision [
364357 | a b |
365358 a := PMMatrix rows: #(#(1.2 2.4) #(1.2 2.4) ).
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [
3131{ #category : ' tests' }
3232PMQRTest >> testDecompositionOfMatrixCausingErraticFailure [
3333
34+ < expectedFailure>
3435 | a qrDecomposition matricesAndPivot q r expectedMatrix pivot |
3536 a := PMSymmetricMatrix rows:
3637 #( #( 0.41929313699681925 0.05975350554089691
Original file line number Diff line number Diff line change @@ -187,13 +187,6 @@ PMVectorTest >> testTensorProduct [
187187 self assert: (b tensorProduct: a) equals: c transpose
188188]
189189
190- { #category : #tests }
191- PMVectorTest >> testVectorCloseTo [
192- self assert: (#(1.00001 2.00005) asPMVector closeTo: #(1.00005 2.00001) asPMVector).
193- self assert: #(1.00001 2.00005) asPMVector closeTo: #(1.00005 2.00001) asPMVector. " Double check that the TestAsserter >> #assert:closeTo: functions properly here."
194- self deny: (#(1.00001 2.00007) asPMVector closeTo: #(1.00007 2.00001) asPMVector)
195- ]
196-
197190{ #category : #tests }
198191PMVectorTest >> testVectorCloseToPrecision [
199192 | u v |
@@ -217,6 +210,21 @@ PMVectorTest >> testVectorCumulativeSum [
217210 self assert: (w at: 3 ) equals: 6
218211]
219212
213+ { #category : #tests }
214+ PMVectorTest >> testVectorFirstNorm [
215+
216+ | v1 v2 v3 |
217+ v1 := #( 1 0 ) asPMVector.
218+ self assert: v1 firstNorm equals: 1 .
219+ v2 := #( 1 1 ) asPMVector.
220+ self assert: v2 firstNorm equals: 2 .
221+ v3 := #( -1 1 ) asPMVector.
222+ self assert: v3 firstNorm equals: 2 .
223+
224+ self assert: (v1 + v2) firstNorm equals: 3 .
225+ self assert: (v2 + v3) firstNorm equals: 2
226+ ]
227+
220228{ #category : #tests }
221229PMVectorTest >> testVectorGreater [
222230
Original file line number Diff line number Diff line change @@ -181,6 +181,13 @@ PMVector >> cumsum [
181181
182182]
183183
184+ { #category : #operation }
185+ PMVector >> firstNorm [
186+ " Answer the first norm of the receiver."
187+
188+ ^ self inject: 0 into: [ :accu :e | accu + e abs ]
189+ ]
190+
184191{ #category : #operation }
185192PMVector >> hadamardProduct: aVector [
186193 " Answers the elementwise product of the receiver with aVector."
@@ -252,10 +259,12 @@ PMVector >> normalized [
252259{ #category : #operation }
253260PMVector >> productWithVector: aVector [
254261 " Answers the scalar product of aVector with the receiver."
262+
255263 | n |
256264 n := 0 .
257- ^ self inject: 0
258- into: [ :sum :each | n := n + 1 . (aVector at: n) * each + sum]
265+ ^ self inject: 0 into: [ :sum :each |
266+ n := n + 1 .
267+ (aVector at: n) * each + sum ]
259268]
260269
261270{ #category : #operation }
You can’t perform that action at this time.
0 commit comments