Skip to content

Added matrix operations#12

Open
DurieuxPol wants to merge 8 commits intoPolyMathOrg:masterfrom
DurieuxPol:feat/methods
Open

Added matrix operations#12
DurieuxPol wants to merge 8 commits intoPolyMathOrg:masterfrom
DurieuxPol:feat/methods

Conversation

@DurieuxPol
Copy link

@DurieuxPol DurieuxPol commented Feb 13, 2026

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

@jordanmontt
Copy link
Member

Could you please explain the changes that you did?

@coveralls
Copy link

coveralls commented Feb 13, 2026

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
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 Added matrix 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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants