Add more see-also content to glm docs.
This commit is contained in:
parent
12962c3c13
commit
ca9b4e38dd
@ -3,18 +3,30 @@ use aliases::TVec;
|
||||
use traits::{Alloc, Dimension};
|
||||
|
||||
/// Component-wise exponential.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`exp2`](fn.exp2.html)
|
||||
pub fn exp<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| x.exp())
|
||||
}
|
||||
|
||||
/// Component-wise base-2 exponential.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`exp`](fn.exp.html)
|
||||
pub fn exp2<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| x.exp2())
|
||||
}
|
||||
|
||||
/// Compute the inverse of the square root of each component of `v`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`sqrt`](fn.sqrt.html)
|
||||
pub fn inversesqrt<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| N::one() / x.sqrt())
|
||||
@ -22,12 +34,20 @@ pub fn inversesqrt<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
}
|
||||
|
||||
/// Component-wise logarithm.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`log2`](fn.log2.html)
|
||||
pub fn log<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| x.ln())
|
||||
}
|
||||
|
||||
/// Component-wise base-2 logarithm.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`log`](fn.log.html)
|
||||
pub fn log2<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| x.log2())
|
||||
@ -40,6 +60,13 @@ pub fn pow<N: Real, D: Dimension>(base: &TVec<N, D>, exponent: &TVec<N, D>) -> T
|
||||
}
|
||||
|
||||
/// Component-wise square root.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`exp`](fn.exp.html)
|
||||
/// * [`exp2`](fn.exp2.html)
|
||||
/// * [`inversesqrt`](fn.inversesqrt.html)
|
||||
/// * [`pow`](fn.pow.html)
|
||||
pub fn sqrt<N: Real, D: Dimension>(v: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
v.map(|x| x.sqrt())
|
||||
|
@ -7,6 +7,21 @@ pub fn epsilon<N: AbsDiffEq<Epsilon = N>>() -> N {
|
||||
}
|
||||
|
||||
/// The value of PI.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn pi<N: Real>() -> N {
|
||||
N::pi()
|
||||
}
|
||||
|
@ -4,48 +4,144 @@ use traits::{Alloc, Number, Dimension};
|
||||
use aliases::TVec;
|
||||
|
||||
/// Component-wise maximum between a vector and a scalar.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn max<N: Number, D: Dimension>(a: &TVec<N, D>, b: N) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
a.map(|a| na::sup(&a, &b))
|
||||
}
|
||||
|
||||
/// Component-wise maximum between two vectors.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn max2<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
na::sup(a, b)
|
||||
}
|
||||
|
||||
/// Component-wise maximum between three vectors.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn max3<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
max2(&max2(a, b), c)
|
||||
}
|
||||
|
||||
/// Component-wise maximum between four vectors.
|
||||
///
|
||||
/// # 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)
|
||||
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>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
max2(&max2(a, b), &max2(c, d))
|
||||
}
|
||||
|
||||
/// Component-wise minimum between a vector and a scalar.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn min<N: Number, D: Dimension>(x: &TVec<N, D>, y: N) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
x.map(|x| na::inf(&x, &y))
|
||||
}
|
||||
|
||||
/// Component-wise minimum between two vectors.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn min2<N: Number, D: Dimension>(x: &TVec<N, D>, y: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
na::inf(x, y)
|
||||
}
|
||||
|
||||
/// Component-wise minimum between three vectors.
|
||||
///
|
||||
/// # 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)
|
||||
pub fn min3<N: Number, D: Dimension>(a: &TVec<N, D>, b: &TVec<N, D>, c: &TVec<N, D>) -> TVec<N, D>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
min2(&min2(a, b), c)
|
||||
}
|
||||
|
||||
/// Component-wise minimum between four vectors.
|
||||
///
|
||||
/// # 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)
|
||||
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>
|
||||
where DefaultAllocator: Alloc<N, D> {
|
||||
min2(&min2(a, b), &min2(c, d))
|
||||
|
@ -11,6 +11,21 @@ pub fn euler<N: Real>() -> N {
|
||||
}
|
||||
|
||||
/// Returns `4 / pi`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn four_over_pi<N: Real>() -> N {
|
||||
na::convert::<_, N>(4.0) / N::pi()
|
||||
}
|
||||
@ -21,21 +36,51 @@ pub fn golden_ratio<N: Real>() -> N {
|
||||
}
|
||||
|
||||
/// Returns `pi / 2`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn half_pi<N: Real>() -> N {
|
||||
N::frac_pi_2()
|
||||
}
|
||||
|
||||
/// Returns `ln(ln(2))`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`ln_ten`](fn.ln_ten.html)
|
||||
/// * [`ln_two`](fn.ln_two.html)
|
||||
pub fn ln_ln_two<N: Real>() -> N {
|
||||
N::ln_2().ln()
|
||||
}
|
||||
|
||||
/// Returns `ln(10)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`ln_ln_two`](fn.ln_ln_two.html)
|
||||
/// * [`ln_two`](fn.ln_two.html)
|
||||
pub fn ln_ten<N: Real>() -> N {
|
||||
N::ln_10()
|
||||
}
|
||||
|
||||
/// Returns `ln(2)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`ln_ln_two`](fn.ln_ln_two.html)
|
||||
/// * [`ln_ten`](fn.ln_ten.html)
|
||||
pub fn ln_two<N: Real>() -> N {
|
||||
N::ln_2()
|
||||
}
|
||||
@ -44,6 +89,21 @@ pub fn ln_two<N: Real>() -> N {
|
||||
pub use na::one;
|
||||
|
||||
/// Returns `1 / pi`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn one_over_pi<N: Real>() -> N {
|
||||
N::frac_1_pi()
|
||||
}
|
||||
@ -54,21 +114,71 @@ pub fn one_over_root_two<N: Real>() -> N {
|
||||
}
|
||||
|
||||
/// Returns `1 / (2pi)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn one_over_two_pi<N: Real>() -> N {
|
||||
N::frac_1_pi() * na::convert(0.5)
|
||||
}
|
||||
|
||||
/// Returns `pi / 4`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn quarter_pi<N: Real>() -> N {
|
||||
N::frac_pi_4()
|
||||
}
|
||||
|
||||
/// Returns `sqrt(5)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`root_three`](fn.root_three.html)
|
||||
/// * [`root_two`](fn.root_two.html)
|
||||
pub fn root_five<N: Real>() -> N {
|
||||
na::convert::<_, N>(5.0).sqrt()
|
||||
}
|
||||
|
||||
/// Returns `sqrt(pi / 2)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn root_half_pi<N: Real>() -> N {
|
||||
(N::pi() / na::convert(2.0)).sqrt()
|
||||
}
|
||||
@ -79,55 +189,162 @@ pub fn root_ln_four<N: Real>() -> N {
|
||||
}
|
||||
|
||||
/// Returns the square root of pi.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn root_pi<N: Real>() -> N {
|
||||
N::pi().sqrt()
|
||||
}
|
||||
|
||||
/// Returns the square root of 3.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`root_five`](fn.root_five.html)
|
||||
/// * [`root_two`](fn.root_two.html)
|
||||
pub fn root_three<N: Real>() -> N {
|
||||
na::convert::<_, N>(3.0).sqrt()
|
||||
}
|
||||
|
||||
/// Returns the square root of 2.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`root_five`](fn.root_five.html)
|
||||
/// * [`root_three`](fn.root_three.html)
|
||||
pub fn root_two<N: Real>() -> N {
|
||||
// FIXME: there should be a ::sqrt_2() on the Real trait.
|
||||
na::convert::<_, N>(2.0).sqrt()
|
||||
}
|
||||
|
||||
/// Returns the square root of 2pi.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn root_two_pi<N: Real>() -> N {
|
||||
N::two_pi().sqrt()
|
||||
}
|
||||
|
||||
/// Returns `1 / 3`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`two_thirds`](fn.two_thirds.html)
|
||||
pub fn third<N: Real>() -> N {
|
||||
na::convert(1.0 / 3.0)
|
||||
}
|
||||
|
||||
/// Returns `3 / (2pi)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn three_over_two_pi<N: Real>() -> N {
|
||||
na::convert::<_, N>(3.0) / N::two_pi()
|
||||
}
|
||||
|
||||
/// Returns `2 / pi`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn two_over_pi<N: Real>() -> N {
|
||||
N::frac_2_pi()
|
||||
}
|
||||
|
||||
/// Returns `2 / sqrt(pi)`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_pi`](fn.two_pi.html)
|
||||
pub fn two_over_root_pi<N: Real>() -> N {
|
||||
N::frac_2_sqrt_pi()
|
||||
}
|
||||
|
||||
/// Returns `2pi`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`four_over_pi`](fn.four_over_pi.html)
|
||||
/// * [`half_pi`](fn.half_pi.html)
|
||||
/// * [`one_over_pi`](fn.one_over_pi.html)
|
||||
/// * [`one_over_two_pi`](fn.one_over_two_pi.html)
|
||||
/// * [`pi`](fn.pi.html)
|
||||
/// * [`quarter_pi`](fn.quarter_pi.html)
|
||||
/// * [`root_half_pi`](fn.root_half_pi.html)
|
||||
/// * [`root_pi`](fn.root_pi.html)
|
||||
/// * [`root_two_pi`](fn.root_two_pi.html)
|
||||
/// * [`three_over_two_pi`](fn.three_over_two_pi.html)
|
||||
/// * [`two_over_pi`](fn.two_over_pi.html)
|
||||
/// * [`two_over_root_pi`](fn.two_over_root_pi.html)
|
||||
pub fn two_pi<N: Real>() -> N {
|
||||
N::two_pi()
|
||||
}
|
||||
|
||||
/// Returns `2 / 3`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`third`](fn.third.html)
|
||||
pub fn two_thirds<N: Real>() -> N {
|
||||
na::convert(2.0 / 3.0)
|
||||
}
|
||||
|
||||
/// Returns `0`.
|
||||
pub use na::zero;
|
||||
pub use na::zero;
|
||||
|
@ -4,12 +4,24 @@ use traits::{Alloc, Dimension};
|
||||
use aliases::{TVec, TMat};
|
||||
|
||||
/// The `index`-th column of the matrix `m`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`row`](fn.row.html)
|
||||
/// * [`set_column`](fn.set_column.html)
|
||||
/// * [`set_row`](fn.set_row.html)
|
||||
pub fn column<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize) -> TVec<N, R>
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.column(index).into_owned()
|
||||
}
|
||||
|
||||
/// Sets to `x` the `index`-th column of the matrix `m`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`column`](fn.column.html)
|
||||
/// * [`row`](fn.row.html)
|
||||
/// * [`set_row`](fn.set_row.html)
|
||||
pub fn set_column<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize, x: &TVec<N, R>) -> TMat<N, R, C>
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
let mut res = m.clone();
|
||||
@ -18,12 +30,24 @@ pub fn set_column<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, inde
|
||||
}
|
||||
|
||||
/// The `index`-th row of the matrix `m`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`column`](fn.column.html)
|
||||
/// * [`set_column`](fn.set_column.html)
|
||||
/// * [`set_row`](fn.set_row.html)
|
||||
pub fn row<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize) -> TVec<N, C>
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.row(index).into_owned().transpose()
|
||||
}
|
||||
|
||||
/// Sets to `x` the `index`-th row of the matrix `m`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`column`](fn.column.html)
|
||||
/// * [`row`](fn.row.html)
|
||||
/// * [`set_column`](fn.set_column.html)
|
||||
pub fn set_row<N: Scalar, R: Dimension, C: Dimension>(m: &TMat<N, R, C>, index: usize, x: &TVec<N, C>) -> TMat<N, R, C>
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
let mut res = m.clone();
|
||||
|
@ -4,28 +4,60 @@ use traits::{Number, Alloc, Dimension};
|
||||
use aliases::TMat;
|
||||
|
||||
/// The sum of every components of the given matrix or vector.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`comp_max`](fn.comp_max.html)
|
||||
/// * [`comp_min`](fn.comp_min.html)
|
||||
/// * [`comp_mul`](fn.comp_mul.html)
|
||||
pub fn comp_add<N: Number, R: Dimension, C: Dimension>(m: &TMat<N, R, C>) -> N
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.iter().fold(N::zero(), |x, y| x + *y)
|
||||
}
|
||||
|
||||
/// The maximum of every components of the given matrix or vector.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`comp_add`](fn.comp_add.html)
|
||||
/// * [`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)
|
||||
pub fn comp_max<N: Number, R: Dimension, C: Dimension>(m: &TMat<N, R, C>) -> N
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.iter().fold(N::min_value(), |x, y| na::sup(&x, y))
|
||||
}
|
||||
|
||||
/// The minimum of every components of the given matrix or vector.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`comp_add`](fn.comp_add.html)
|
||||
/// * [`comp_max`](fn.comp_max.html)
|
||||
/// * [`comp_mul`](fn.comp_mul.html)
|
||||
/// * [`min`](fn.min.html)
|
||||
/// * [`min2`](fn.min2.html)
|
||||
/// * [`min3`](fn.min3.html)
|
||||
/// * [`min4`](fn.min4.html)
|
||||
pub fn comp_min<N: Number, R: Dimension, C: Dimension>(m: &TMat<N, R, C>) -> N
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.iter().fold(N::max_value(), |x, y| na::inf(&x, y))
|
||||
}
|
||||
|
||||
/// The product of every components of the given matrix or vector.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`comp_add`](fn.comp_add.html)
|
||||
/// * [`comp_max`](fn.comp_max.html)
|
||||
/// * [`comp_min`](fn.comp_min.html)
|
||||
pub fn comp_mul<N: Number, R: Dimension, C: Dimension>(m: &TMat<N, R, C>) -> N
|
||||
where DefaultAllocator: Alloc<N, R, C> {
|
||||
m.iter().fold(N::one(), |x, y| x * *y)
|
||||
}
|
||||
|
||||
//pub fn vec< L, floatType, Q > compNormalize (vec< L, T, Q > const &v)
|
||||
//pub fn vec< L, T, Q > compScale (vec< L, floatType, Q > const &v)
|
||||
//pub fn vec< L, T, Q > compScale (vec< L, floatType, Q > const &v)
|
||||
|
@ -4,12 +4,20 @@ use aliases::TVec;
|
||||
use traits::{Number, Alloc, Dimension};
|
||||
|
||||
/// Checks that all the vector components are `true`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`any`](fn.any.html)
|
||||
pub fn all<D: Dimension>(v: &TVec<bool, D>) -> bool
|
||||
where DefaultAllocator: Alloc<bool, D> {
|
||||
v.iter().all(|x| *x)
|
||||
}
|
||||
|
||||
/// Checks that at least one of the vector components is `true`.
|
||||
///
|
||||
/// # See also:
|
||||
///
|
||||
/// * [`all`](fn.all.html)
|
||||
pub fn any<D: Dimension>(v: &TVec<bool, D>) -> bool
|
||||
where DefaultAllocator: Alloc<bool, D> {
|
||||
v.iter().any(|x| *x)
|
||||
|
Loading…
Reference in New Issue
Block a user