Struct libbgs::numbers::QuadNum

source ·
pub struct QuadNum<const P: u128>(pub FpNum<P>, pub FpNum<P>);
Expand description

An integer modulo P^2. An element $x$ is represented as $x = a_0 + a_1\sqrt{r}$, where $r$ is the fixed basis element. See Lubeck, Frank. (2003). “Standard generators of finite fields and their cyclic subgroups.” Journal of Symbolic Computation (117) 51-67. Note that the SylowDecomposable implementation for a QuadNum returns the decomposition for the subgroup with $p + 1$ elements, not the full group $\mathbb{F}_{p^2}^\times$. Also, <QuadNum<P> as GroupElem>::SIZE == P + 1, again refering to the subgroup. For these reasons, this API is likely to change in the future to bring the definitions of QuadNum<P> as GroupElem and the SylowDecomp instance in line with describing the full group.

Tuple Fields§

§0: FpNum<P>

The value $a_0$, when writing this QuadNum as $a_0 + a_1\sqrt{r}$.

§1: FpNum<P>

The value $a_1$, when writing this QuadNum as $a_0 + a_1\sqrt{r}$.

Implementations§

source§

impl<const P: u128> QuadNum<P>

source

pub const R: FpNum<P> = _

The basis element for the numbers outside of the prime subfield.

source

pub const ZERO: QuadNum<P> = _

The constant zero.

source

pub fn is_zero(&self) -> bool

True if this number is zero; false otherwise.

source

pub fn steinitz(i: u128) -> QuadNum<P>

Returns the Steinitz element of $\mathbb{F}_{p^2}$ with index i.

source

pub fn int_sqrt_either(x: FpNum<P>) -> Either<QuadNum<P>, FpNum<P>>

Calculates the square root of an integer modulo P, casting to an FpNum<P> if x is a quadratic residue. Returns a Left QuadNum<P> if x is a quadratic nonresidue, or a Right FpNum<P> if x is a quadratic residue (including 0).

source

pub fn int_sqrt(x: FpNum<P>) -> QuadNum<P>

Calculates the square root af in integer modulo P.

Trait Implementations§

source§

impl<const P: u128> Add<QuadNum<P>> for QuadNum<P>

§

type Output = QuadNum<P>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> QuadNum<P>

Performs the + operation. Read more
source§

impl<const P: u128> AddAssign<QuadNum<P>> for QuadNum<P>

source§

fn add_assign(&mut self, other: Self)

Performs the += operation. Read more
source§

impl<const P: u128> Clone for QuadNum<P>

source§

fn clone(&self) -> QuadNum<P>

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 P: u128> Debug for QuadNum<P>

source§

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

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

impl<const P: u128> From<(u128, u128)> for QuadNum<P>

source§

fn from(value: (u128, u128)) -> QuadNum<P>

Converts to this type from the input type.
source§

impl<const P: u128> From<FpNum<P>> for QuadNum<P>

source§

fn from(value: FpNum<P>) -> QuadNum<P>

Converts to this type from the input type.
source§

impl<S, const P: u128> FromChi<S, P> for QuadNum<P>where QuadNum<P>: Factor<S>,

source§

fn from_chi<const L: usize>( chi: &SylowElem<S, L, QuadNum<P>>, decomp: &SylowDecomp<S, L, QuadNum<P>> ) -> FpNum<P>

Returns $\chi + \chi^{-1}$.
source§

fn from_chi_conj<const L: usize>( chi: &SylowElem<S, L, QuadNum<P>>, decomp: &SylowDecomp<S, L, QuadNum<P>> ) -> FpNum<P>

Returns $\chi - \chi^{-1}$.
source§

impl<const P: u128> GroupElem for QuadNum<P>

source§

const ONE: Self = _

The unique identity element of this group.
source§

const SIZE: u128 = _

The size of the group this element belongs to.
source§

fn multiply(&self, other: &QuadNum<P>) -> QuadNum<P>

Returns the product of two elements under the group binary operator. If you implement this trait, you must guarantee that the operation is associative; that is, a.multiply(b.multiply(c)) == a.multiply(b).multiply(c).
source§

fn inverse(&self) -> QuadNum<P>

Returns the multiplicative inverse of this element. If you implement this trait, you must guarantee x.inverse().multiply(x) and x.multiply(x.inverse()) both evaluate to ONE.
source§

const ONE_256: [Self; 256] = _

👎Deprecated: To be replaced by inline const expressions once stabilized.
! 256 copies of Self::ONE in an array.
source§

fn pow(&self, n: u128) -> Self

Raises this element to the power of n.
source§

fn order<S>(&self) -> u128where Self: Factor<S>,

Returns the order of this element, that is, the smallest positive power p for which a.pow(p).is_one() returns True.
source§

impl<const P: u128> Hash for QuadNum<P>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<const P: u128> Mul<QuadNum<P>> for QuadNum<P>

§

type Output = QuadNum<P>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> QuadNum<P>

Performs the * operation. Read more
source§

impl<const P: u128> PartialEq<QuadNum<P>> for QuadNum<P>

source§

fn eq(&self, other: &QuadNum<P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const P: u128> PartialEq<u128> for QuadNum<P>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const P: u128> Sub<QuadNum<P>> for QuadNum<P>

§

type Output = QuadNum<P>

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> QuadNum<P>

Performs the - operation. Read more
source§

impl<S, const P: u128> SylowDecomposable<S> for QuadNum<P>where QuadNum<P>: Factor<S>,

source§

fn find_sylow_generator(i: usize) -> QuadNum<P>

Finds a Sylow generator for the Sylow subgroup of prime power index i.
source§

fn is_sylow_generator(candidate: &Self, d: (u128, usize)) -> Option<Self>

True if the given element is a generator of the Sylow subgroup of the prime power represented by d.
source§

fn count_elements_of_order(ds: &[usize]) -> u128

Returns the number of elements of a particular order. The argument is the powers of the prime factors of the group’s order.
source§

impl<const P: u128> Copy for QuadNum<P>

source§

impl<const P: u128> Eq for QuadNum<P>

source§

impl<const P: u128> StructuralEq for QuadNum<P>

source§

impl<const P: u128> StructuralPartialEq for QuadNum<P>

Auto Trait Implementations§

§

impl<const P: u128> RefUnwindSafe for QuadNum<P>

§

impl<const P: u128> Send for QuadNum<P>

§

impl<const P: u128> Sync for QuadNum<P>

§

impl<const P: u128> Unpin for QuadNum<P>

§

impl<const P: u128> UnwindSafe for QuadNum<P>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.