Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Math-Core/PMVector.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
20 changes: 20 additions & 0 deletions src/Math-Tests-Core/PMVectorTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down