Skip to content

Added matrix operations - #12

Merged
jordanmontt merged 10 commits into
PolyMathOrg:masterfrom
DurieuxPol:feat/methods
Feb 19, 2026
Merged

Added matrix operations#12
jordanmontt merged 10 commits into
PolyMathOrg:masterfrom
DurieuxPol:feat/methods

Conversation

@DurieuxPol

@DurieuxPol DurieuxPol commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

Added methods to have the average of each column, and to subtract a vector to each row.

@jordanmontt

Copy link
Copy Markdown
Member

Could you please explain the changes that you did?

@coveralls

coveralls commented Feb 13, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 21994104149

Details

  • 145 of 150 (96.67%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.07%) to 92.628%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Math-Matrix/PMMatrix.class.st 108 113 95.58%
Totals Coverage Status
Change from base Build 19634706886: -0.07%
Covered Lines: 4121
Relevant Lines: 4449

💛 - Coveralls
Comment on lines +429 to +433
PMMatrix >> columnAverage [

^ (1 to: self numberOfColumns) collect: [ :colIndex |
(self columnAt: colIndex) average ]
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this method to have the average of each column of the matrix.

@DurieuxPol DurieuxPol changed the title Added column wise operations Feb 17, 2026
Comment on lines +901 to +912
PMMatrix >> rowWiseSubstractionWith: aRow [
"Assume a collection is a matrix of one row"

| result |
result := self class rows: self numberOfRows columns: self numberOfColumns.

1 to: self numberOfColumns do: [ :col |
| me |
me := self atColumn: col.
result atColumn: col put: me - (aRow at: col) ].
^ result
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also added this method to subtract a vector to each row of a matrix.
For example:

matrix := PMMatrix rows: #( #( 1 2 ) #( 3 4 ) ).
vector := #( 1 2 ) asPMVector.
matrix -= vector.

This gives:

PMMatrix rows: #( #( 0 0  ) #( 2 2) )

It is similar to the -= method from AIContiguousMatrix.
And I added a -= method also to PMMatrix that calls this method, for convenience.

@jordanmontt
jordanmontt merged commit bb4c5c9 into PolyMathOrg:master Feb 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants