AtheMathmo / rulinalg

A linear algebra library written in Rust

Home Page:https://crates.io/crates/rulinalg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Matrix Row / column wise min/max

sinhrks opened this issue · comments

It is convenient if we have row / column-wise .min and .max of Matrix.

  • accept Axes to specify axis like other aggregation funcs.
  • min / max logic should be the same as argmin / argmax. (thus requires PartialEq)

I agree that this would be a useful addition. The only issue is that we would require the PartialEq trait and so we cannot add this to the BaseMatrix trait.

In order to implement this properly we would need column iterators ( #3 ) which are on the way with #84 .

Excuse part of my above comment - we can add this to the BaseMatrix trait by adding a where clause to the function which requires T: PartialEq.

In which case I think this is a solid addition and I would welcome a PR. If you want to work on this feel free to implement the function without column iterators for now. We should use the Axis enum to keep things tidy.

Also note that - for the sake of performance - the column-wise min/max is probably better implemented by using the row iterator and folding the rows by accumulating min/max values for each column entry in the row into a vector, rather than using column iterators. This because it's likely far more cache-friendly.

That said, measure first and all that.