simple_mod_int

Struct Mod

Source
pub struct Mod<const M: u32> {
    pub value: u32,
}

Fields§

§value: u32

Implementations§

Source§

impl<const M: u32> Mod<M>

Source

pub fn pow<T>(self, other: T) -> Self
where T: AsPrimitive<i64> + Copy,

累乗 #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

Source

pub fn inv(self) -> Self

逆元 #example

use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b = a.inv(); //12

#panic 基底と互いに素でない場合、panicが発生します。 when you try to calculate the inverse of a number that is not coprime with the base, panic occurs.

Methods from Deref<Target = u32>§

1.43.0 · Source

pub const MIN: u32 = 0u32

1.43.0 · Source

pub const MAX: u32 = 4_294_967_295u32

1.53.0 · Source

pub const BITS: u32 = 32u32

Trait Implementations§

Source§

impl<const M: u32, T> Add<T> for Mod<M>
where T: AsPrimitive<i64> + Copy,

数値型との加算 #example

use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a + b;
Source§

type Output = Mod<M>

The resulting type after applying the + operator.
Source§

fn add(self, other: T) -> Self::Output

Performs the + operation. Read more
Source§

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§

type Output = Mod<M>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

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)

Performs the += operation. Read more
Source§

impl<const M: u32> Clone for Mod<M>

Source§

fn clone(&self) -> Mod<M>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const M: u32> Deref for Mod<M>

Source§

type Target = u32

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<const M: u32, T> Div<T> for Mod<M>
where T: AsPrimitive<i64> + Copy,

数値型との除算 #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§

type Output = Mod<M>

The resulting type after applying the / operator.
Source§

fn div(self, other: T) -> Self::Output

Performs the / operation. Read more
Source§

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§

type Output = Mod<M>

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self::Output

Performs the / operation. Read more
Source§

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)

Performs the /= operation. Read more
Source§

impl<const M: u32, T> From<T> for Mod<M>
where T: AsPrimitive<i64> + Copy,

数値型からの変換 #example

use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl<const M: u32, T> Mul<T> for Mod<M>
where T: AsPrimitive<i64> + Copy,

数値型との乗算 #example

use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a * b;
Source§

type Output = Mod<M>

The resulting type after applying the * operator.
Source§

fn mul(self, other: T) -> Self::Output

Performs the * operation. Read more
Source§

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§

type Output = Mod<M>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
Source§

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)

Performs the *= operation. Read more
Source§

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 //true
Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const M: u32, T> Sub<T> for Mod<M>
where T: AsPrimitive<i64> + Copy,

数値型との減算 #example

use simple_mod_int::Mod;
let a: Mod<17> = 10.into();
let b: Mod<17> = 20;
let c = a - b;
Source§

type Output = Mod<M>

The resulting type after applying the - operator.
Source§

fn sub(self, other: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<const M: u32> Sub 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§

type Output = Mod<M>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<const M: u32> SubAssign 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 sub_assign(&mut self, other: Self)

Performs the -= operation. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.