Skip to main content

ModOrd

Trait ModOrd 

Source
pub trait ModOrd: Sized {
    // Required method
    fn mod_ord(self, other: Self) -> Option<Self>;
}
Expand description

位数。

法を $n$ として $a, a^2, \dots, a^m$ が互いに異なり、かつ $a^m \equiv 1$ である $m$ が存在すれば、それを返す。

$0\le a\lt n$ とする。

§Complexity

$\lambda(n)$ に対する素因数列挙にかかる時間に加え、各素因数に対して $O(\log(\lambda(n)))$ 時間。試し割り法では $O(\sqrt{n})$ 時間。

§Examples

use nekolib::math::ModOrd;

assert_eq!(7_u64.mod_ord(10), Some(4));
assert_eq!(1_u64.mod_ord(3), Some(1));
assert_eq!(22_u64.mod_ord(30), None);

§Suggestions

dlog と同様、$\lambda$ 関数と素因数列挙に関して引数で渡したいかも。

Required Methods§

Source

fn mod_ord(self, other: Self) -> Option<Self>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ModOrd for u8

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Source§

impl ModOrd for u16

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Source§

impl ModOrd for u32

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Source§

impl ModOrd for u64

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Source§

impl ModOrd for u128

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Source§

impl ModOrd for usize

Source§

fn mod_ord(self, n: Self) -> Option<Self>

Implementors§