Trait malachite_base::num::arithmetic::traits::FloorRoot
source · pub trait FloorRoot<POW> {
type Output;
// Required method
fn floor_root(self, pow: POW) -> Self::Output;
}
Expand description
Finds the floor of the $n$th root of a number.
Required Associated Types§
Required Methods§
fn floor_root(self, pow: POW) -> Self::Output
Implementations on Foreign Types§
source§impl FloorRoot<u64> for i16
impl FloorRoot<u64> for i16
source§impl FloorRoot<u64> for i32
impl FloorRoot<u64> for i32
source§impl FloorRoot<u64> for i64
impl FloorRoot<u64> for i64
source§impl FloorRoot<u64> for i128
impl FloorRoot<u64> for i128
source§impl FloorRoot<u64> for isize
impl FloorRoot<u64> for isize
source§impl FloorRoot<u64> for u16
impl FloorRoot<u64> for u16
source§impl FloorRoot<u64> for u32
impl FloorRoot<u64> for u32
source§fn floor_root(self, exp: u64) -> u32
fn floor_root(self, exp: u64) -> u32
Returns the floor of the $n$th root of a u32
.
$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if exp
is zero.
§Examples
See here.
§Notes
For cube roots, the u32
implementation uses a piecewise Chebyshev approximation. For
other roots, it uses Newton’s method. In both implementations, the result of these
approximations is adjusted afterwards to account for error.
type Output = u32
source§impl FloorRoot<u64> for u64
impl FloorRoot<u64> for u64
source§fn floor_root(self, exp: u64) -> u64
fn floor_root(self, exp: u64) -> u64
Returns the floor of the $n$th root of a u64
.
$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if exp
is zero.
§Examples
See here.
§Notes
For cube roots, the u64
implementation uses a piecewise Chebyshev approximation. For
other roots, it uses Newton’s method. In both implementations, the result of these
approximations is adjusted afterwards to account for error.
type Output = u64
source§impl FloorRoot<u64> for u128
impl FloorRoot<u64> for u128
source§fn floor_root(self, exp: u64) -> u128
fn floor_root(self, exp: u64) -> u128
Returns the floor of the $n$th root of a u128
.
$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.
§Worst-case complexity
Constant time and additional memory.
§Panics
Panics if exp
is zero.
§Examples
See here.
§Notes
The u128
implementation computes the root using floating-point arithmetic. The
approximate result is adjusted afterwards to account for error.