impl<const SCALE: u32> crate::D<crate::int::types::Int<2>, SCALE> {
#[cfg(feature = "std")]
#[inline]
#[must_use]
pub fn powf_fast(self, exp: crate::D<crate::int::types::Int<2>, SCALE>) -> Self {
Self::from_f64(self.to_f64().powf(exp.to_f64()))
}
#[cfg(feature = "std")]
#[inline]
#[must_use]
pub fn sqrt_fast(self) -> Self {
Self::from_f64(self.to_f64().sqrt())
}
#[cfg(feature = "std")]
#[inline]
#[must_use]
pub fn cbrt_fast(self) -> Self {
Self::from_f64(self.to_f64().cbrt())
}
#[cfg(feature = "std")]
#[inline]
#[must_use]
pub fn hypot_fast(self, other: Self) -> Self {
let a = self.abs();
let b = other.abs();
let (large, small) = if a >= b { (a, b) } else { (b, a) };
if large == Self::ZERO {
Self::ZERO
} else {
let ratio = small / large;
let one_plus_sq = Self::ONE + ratio * ratio;
large * one_plus_sq.sqrt_fast()
}
}
}
#[cfg(all(feature = "std", any(not(feature = "strict"), feature = "fast")))]
impl<const SCALE: u32> crate::D<crate::int::types::Int<2>, SCALE> {
#[inline]
#[must_use]
pub fn powf(self, exp: crate::D<crate::int::types::Int<2>, SCALE>) -> Self {
self.powf_fast(exp)
}
#[inline]
#[must_use]
pub fn sqrt(self) -> Self {
self.sqrt_fast()
}
#[inline]
#[must_use]
pub fn cbrt(self) -> Self {
self.cbrt_fast()
}
#[inline]
#[must_use]
pub fn hypot(self, other: Self) -> Self {
self.hypot_fast(other)
}
}