forked from M-Labs/nalgebra
Add .min and .max.
This commit is contained in:
parent
b4b66bddd2
commit
cae2be5cad
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nalgebra"
|
name = "nalgebra"
|
||||||
version = "0.16.5"
|
version = "0.16.12"
|
||||||
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
||||||
|
|
||||||
description = "Linear algebra library with transformations and statically-sized or dynamically-sized matrices."
|
description = "Linear algebra library with transformations and statically-sized or dynamically-sized matrices."
|
||||||
|
@ -761,7 +761,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<N: Scalar + PartialOrd + Signed, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
|
impl<N: Scalar + PartialOrd + Signed, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
|
||||||
/// Returns the absolute value of the coefficient with the largest absolute value.
|
/// Returns the absolute value of the component with the largest absolute value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn amax(&self) -> N {
|
pub fn amax(&self) -> N {
|
||||||
let mut max = N::zero();
|
let mut max = N::zero();
|
||||||
@ -777,7 +777,7 @@ impl<N: Scalar + PartialOrd + Signed, R: Dim, C: Dim, S: Storage<N, R, C>> Matri
|
|||||||
max
|
max
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the absolute value of the coefficient with the smallest absolute value.
|
/// Returns the absolute value of the component with the smallest absolute value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn amin(&self) -> N {
|
pub fn amin(&self) -> N {
|
||||||
let mut it = self.iter();
|
let mut it = self.iter();
|
||||||
@ -796,4 +796,42 @@ impl<N: Scalar + PartialOrd + Signed, R: Dim, C: Dim, S: Storage<N, R, C>> Matri
|
|||||||
|
|
||||||
min
|
min
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the component with the largest value.
|
||||||
|
#[inline]
|
||||||
|
pub fn max(&self) -> N {
|
||||||
|
let mut it = self.iter();
|
||||||
|
let mut max = it
|
||||||
|
.next()
|
||||||
|
.expect("max: empty matrices not supported.");
|
||||||
|
|
||||||
|
for e in it {
|
||||||
|
let ae = e;
|
||||||
|
|
||||||
|
if ae > max {
|
||||||
|
max = ae;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*max
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the component with the smallest value.
|
||||||
|
#[inline]
|
||||||
|
pub fn min(&self) -> N {
|
||||||
|
let mut it = self.iter();
|
||||||
|
let mut min = it
|
||||||
|
.next()
|
||||||
|
.expect("min: empty matrices not supported.");
|
||||||
|
|
||||||
|
for e in it {
|
||||||
|
let ae = e;
|
||||||
|
|
||||||
|
if ae < min {
|
||||||
|
min = ae;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*min
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user