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§

source

fn floor_root(self, pow: POW) -> Self::Output

Implementations on Foreign Types§

source§

impl FloorRoot<u64> for i8

source§

fn floor_root(self, exp: u64) -> i8

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = i8

source§

impl FloorRoot<u64> for i16

source§

fn floor_root(self, exp: u64) -> i16

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = i16

source§

impl FloorRoot<u64> for i32

source§

fn floor_root(self, exp: u64) -> i32

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = i32

source§

impl FloorRoot<u64> for i64

source§

fn floor_root(self, exp: u64) -> i64

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = i64

source§

impl FloorRoot<u64> for i128

source§

fn floor_root(self, exp: u64) -> i128

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = i128

source§

impl FloorRoot<u64> for isize

source§

fn floor_root(self, exp: u64) -> isize

Returns the floor of the $n$th root of an integer.

$f(x, n) = \lfloor\sqrt[n]{x}\rfloor$.

§Worst-case complexity

Constant time and additional memory.

§Panics

Panics if exp is zero, or if self is negative and exp is even.

§Examples

See here.

§

type Output = isize

source§

impl FloorRoot<u64> for u8

source§

fn floor_root(self, exp: u64) -> u8

Returns the floor of the $n$th root of a u8.

$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 u8 implementation uses lookup tables.

§

type Output = u8

source§

impl FloorRoot<u64> for u16

source§

fn floor_root(self, exp: u64) -> u16

Returns the floor of the $n$th root of a u16.

$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 u16 implementation calls the implementation for u32s.

§

type Output = u16

source§

impl FloorRoot<u64> for u32

source§

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

source§

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

source§

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.

§

type Output = u128

source§

impl FloorRoot<u64> for usize

source§

fn floor_root(self, exp: u64) -> usize

Returns the floor of the $n$th root of a usize.

$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 usize implementation calls the u32 or u64 implementations.

§

type Output = usize

Implementors§