2018-09-20 20:23:31 +08:00
|
|
|
use na::{self, DefaultAllocator};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-20 20:23:31 +08:00
|
|
|
use traits::{Alloc, Number, Dimension};
|
2018-09-23 20:48:45 +08:00
|
|
|
use aliases::TVec;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise maximum between a vector and a scalar.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn max<N: Number, D: Dimension>(a: &TVec<N, D>, b: N) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
a.map(|a| na::sup(&a, &b))
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise maximum between two vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn max2<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
na::sup(a, b)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise maximum between three vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn max3<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
max2(&max2(a, b), c)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise maximum between four vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn max4<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>, d: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
max2(&max2(a, b), &max2(c, d))
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-23 00:11:51 +08:00
|
|
|
/// Component-wise minimum between a vector and a scalar.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn min<N: Number, D: Dimension>(x: &TVec<N, D>, y: N) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
x.map(|x| na::inf(&x, &y))
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-23 00:11:51 +08:00
|
|
|
/// Component-wise minimum between two vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn min2<N: Number, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
na::inf(x, y)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-23 00:11:51 +08:00
|
|
|
/// Component-wise minimum between three vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min4`](fn.min4.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn min3<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
min2(&min2(a, b), c)
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-23 00:11:51 +08:00
|
|
|
/// Component-wise minimum between four vectors.
|
2018-10-03 19:28:07 +08:00
|
|
|
///
|
|
|
|
/// # See also:
|
|
|
|
///
|
|
|
|
/// * [`comp_max`](fn.comp_max.html)
|
|
|
|
/// * [`comp_min`](fn.comp_min.html)
|
|
|
|
/// * [`max`](fn.max.html)
|
|
|
|
/// * [`max2`](fn.max2.html)
|
|
|
|
/// * [`max3`](fn.max3.html)
|
|
|
|
/// * [`max4`](fn.max4.html)
|
|
|
|
/// * [`min`](fn.min.html)
|
|
|
|
/// * [`min2`](fn.min2.html)
|
|
|
|
/// * [`min3`](fn.min3.html)
|
2018-09-23 20:48:45 +08:00
|
|
|
pub fn min4<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>, d: &TVec<N, D>) -> TVec<N, D>
|
2018-09-20 16:50:34 +08:00
|
|
|
where DefaultAllocator: Alloc<N, D> {
|
2018-09-20 20:23:31 +08:00
|
|
|
min2(&min2(a, b), &min2(c, d))
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|