Struct libbgs::numbers::Factorization  
source · pub struct Factorization { /* private fields */ }Expand description
A prime power decomposition of a positive integer.
Implementations§
source§impl Factorization
 
impl Factorization
sourcepub const fn new(factors: &'static [(u128, usize)]) -> Factorization
 
pub const fn new(factors: &'static [(u128, usize)]) -> Factorization
Creates a new factorization from the given prime powers.
sourcepub fn maximal_divisors<const L: usize>(
    &self,
    l: u128
) -> impl Iterator<Item = [usize; L]>
 
pub fn maximal_divisors<const L: usize>( &self, l: u128 ) -> impl Iterator<Item = [usize; L]>
Returns an Iterator yielding the maximal divisors of the number represented by this
Factorization below l; that is, if this Factorization represents the number $n$, then
this Iterator yields vectors representing all elements $d$ satisfying these properties:
- $d | n$,
- $d \leq l$, and
- there are no elements $k | n$ such that $d | k$ and $k \leq l$.
The iterator cannot outlive the Factorization, although the vectors yielded by it may.
sourcepub const fn is_empty(&self) -> bool
 
pub const fn is_empty(&self) -> bool
True if there the factorization represents 1. False otherwise.
sourcepub const fn factor(&self, i: usize) -> u128
 
pub const fn factor(&self, i: usize) -> u128
Returns the prime power factor represented by prime number i, $p_i^{t_i}$.
This method will panic if i is out of bounds.
sourcepub const fn factors(&self) -> &'static [(u128, usize)]
 
pub const fn factors(&self) -> &'static [(u128, usize)]
Gets the prime powers as an array. The first element of each entry is the prime, and the second is the power.
sourcepub const fn value(&self) -> u128
 
pub const fn value(&self) -> u128
Returns the positive integer represented by this Factorization.
sourcepub fn from_powers(&self, ds: &[usize]) -> u128
 
pub fn from_powers(&self, ds: &[usize]) -> u128
Converts an array of powers on the prime factors into an integer.
Trait Implementations§
source§impl Clone for Factorization
 
impl Clone for Factorization
source§fn clone(&self) -> Factorization
 
fn clone(&self) -> Factorization
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Factorization
 
impl Debug for Factorization
source§impl Index<usize> for Factorization
 
impl Index<usize> for Factorization
source§impl PartialEq<Factorization> for Factorization
 
impl PartialEq<Factorization> for Factorization
source§fn eq(&self, other: &Factorization) -> bool
 
fn eq(&self, other: &Factorization) -> bool
self and other values to be equal, and is used
by ==.