Skip to content

Commit

Permalink
More elegant initial value for xcmp
Browse files Browse the repository at this point in the history
  • Loading branch information
w1th0utnam3 authored and sebcrozet committed Aug 27, 2019
1 parent c625a37 commit a06b833
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/base/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,10 +871,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
fn xcmp<N2>(&self, abs: impl Fn(N) -> N2, ordering: Ordering) -> N2
where N2: Scalar + PartialOrd + Zero {
let mut iter = self.iter();
let mut max = match iter.next() {
Some(first) => abs(*first),
None => { return N2::zero(); }
};
let mut max = iter.next().cloned().map_or(N2::zero(), &abs);

for e in iter {
let ae = abs(*e);
Expand Down

0 comments on commit a06b833

Please sign in to comment.