pub struct Mod<const M: u32> {
pub value: u32,
}Fields§
§value: u32Implementations§
Source§impl<const M: u32> Mod<M>
impl<const M: u32> Mod<M>
Sourcepub fn pow<T>(self, other: T) -> Self
pub fn pow<T>(self, other: T) -> Self
累乗 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
let c = a.pow(b);負の指数も指定可能 負の指数の場合、逆元を計算してから累乗します can specify negative exponent when you specify a negative exponent, it calculates the inverse and then raises it to the power
Trait Implementations§
Source§impl<const M: u32, T> Add<T> for Mod<M>
数値型との加算
#example
impl<const M: u32, T> Add<T> for Mod<M>
数値型との加算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a + b;Source§impl<const M: u32> Add for Mod<M>
加算
#example
impl<const M: u32> Add for Mod<M>
加算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
let c = a + b;Source§impl<const M: u32> AddAssign for Mod<M>
加算代入
#example
impl<const M: u32> AddAssign for Mod<M>
加算代入 #example
use simple_mod_int::Mod;
let mut a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
a += b;Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl<const M: u32> Debug for Mod<M>
デバッグ
#example
impl<const M: u32> Debug for Mod<M>
デバッグ #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
println!("{:?}", a); //Mod { value: 10 , mod: 17 }Source§impl<const M: u32, T> Div<T> for Mod<M>
数値型との除算
#example
impl<const M: u32, T> Div<T> for Mod<M>
数値型との除算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a / b;#panic baseと互いに素な数で除算しようとした場合、panicが発生します。 when you try to divide by a number that is not coprime with the base, panic occurs.
Source§impl<const M: u32> Div for Mod<M>
除算
#example
impl<const M: u32> Div for Mod<M>
除算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
let c = a / b;Source§impl<const M: u32> DivAssign for Mod<M>
除算代入
#example
impl<const M: u32> DivAssign for Mod<M>
除算代入 #example
use simple_mod_int::Mod;
let mut a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
a /= b;Source§fn div_assign(&mut self, other: Self)
fn div_assign(&mut self, other: Self)
Performs the
/= operation. Read moreSource§impl<const M: u32, T> From<T> for Mod<M>
数値型からの変換
#example
impl<const M: u32, T> From<T> for Mod<M>
数値型からの変換 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();Source§impl<const M: u32, T> Mul<T> for Mod<M>
数値型との乗算
#example
impl<const M: u32, T> Mul<T> for Mod<M>
数値型との乗算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a * b;Source§impl<const M: u32> Mul for Mod<M>
乗算
#example
impl<const M: u32> Mul for Mod<M>
乗算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
let c = a * b;Source§impl<const M: u32> MulAssign for Mod<M>
乗算代入
#example
impl<const M: u32> MulAssign for Mod<M>
乗算代入 #example
use simple_mod_int::Mod;
let mut a: Mod<17> = 10.into();
let b: Mod<17> = 20.into();
a *= b;Source§fn mul_assign(&mut self, other: Self)
fn mul_assign(&mut self, other: Self)
Performs the
*= operation. Read moreSource§impl<const M: u32> PartialEq for Mod<M>
等価
#example
impl<const M: u32> PartialEq for Mod<M>
等価 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 61.into();
a==b //trueSource§impl<const M: u32, T> Sub<T> for Mod<M>
数値型との減算
#example
impl<const M: u32, T> Sub<T> for Mod<M>
数値型との減算 #example
use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a - b;Auto Trait Implementations§
impl<const M: u32> Freeze for Mod<M>
impl<const M: u32> RefUnwindSafe for Mod<M>
impl<const M: u32> Send for Mod<M>
impl<const M: u32> Sync for Mod<M>
impl<const M: u32> Unpin for Mod<M>
impl<const M: u32> UnwindSafe for Mod<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more