pub trait RingExtension: RingBase {
type BaseRing: RingStore;
// Required methods
fn base_ring(&self) -> &Self::BaseRing;
fn from(&self, x: El<Self::BaseRing>) -> Self::Element;
// Provided methods
fn from_ref(&self, x: &El<Self::BaseRing>) -> Self::Element { ... }
fn mul_assign_base(&self, lhs: &mut Self::Element, rhs: &El<Self::BaseRing>) { ... }
fn fma_base(
&self,
lhs: &Self::Element,
rhs: &El<Self::BaseRing>,
summand: Self::Element,
) -> Self::Element { ... }
fn mul_assign_base_through_hom<S: ?Sized + RingBase, H: Homomorphism<S, <Self::BaseRing as RingStore>::Type>>(
&self,
lhs: &mut Self::Element,
rhs: &S::Element,
hom: H,
) { ... }
}Expand description
Trait for rings that are an extension ring of a base ring. This does not have to be a proper extension in the mathematical sense, but is in some cases implemented for a wrapper of a ring object that represents the same ring.
Hence, this is technically just a ring R with an injective homomorphism
BaseRing -> R, but unlike CanHomFrom, implementors must provide
a reference to BaseRing via RingExtension::base_ring().
§Overlap with CanHomFrom
There is a certain amount of functionality overlap with CanHomFrom, and
in a perfect world, this trait would also be a subtrait of CanHomFrom<<Self::BaseRing as RingStore>::Type>. However, due to the issue with multiple blanket implementations for
CanHomFrom (see the docs), this is not the case and in fact there are ring extensions that
do not implement CanHomFrom<<Self::BaseRing as RingStore>::Type>.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn from_ref(&self, x: &El<Self::BaseRing>) -> Self::Element
fn from_ref(&self, x: &El<Self::BaseRing>) -> Self::Element
Maps an element of the base ring (given as reference) into this ring.
Sourcefn mul_assign_base(&self, lhs: &mut Self::Element, rhs: &El<Self::BaseRing>)
fn mul_assign_base(&self, lhs: &mut Self::Element, rhs: &El<Self::BaseRing>)
Computes lhs := lhs * rhs, where rhs is mapped into this
ring via RingExtension::from_ref(). Note that this may be
faster than self.mul_assign(lhs, self.from_ref(rhs)).
fn fma_base( &self, lhs: &Self::Element, rhs: &El<Self::BaseRing>, summand: Self::Element, ) -> Self::Element
Sourcefn mul_assign_base_through_hom<S: ?Sized + RingBase, H: Homomorphism<S, <Self::BaseRing as RingStore>::Type>>(
&self,
lhs: &mut Self::Element,
rhs: &S::Element,
hom: H,
)
fn mul_assign_base_through_hom<S: ?Sized + RingBase, H: Homomorphism<S, <Self::BaseRing as RingStore>::Type>>( &self, lhs: &mut Self::Element, rhs: &S::Element, hom: H, )
Computes lhs := lhs * rhs, where rhs is mapped into this ring
via the given homomorphism, followed by the inclusion (as specified by
RingExtension::from_ref()).
This is designed for the case that an extension ring element is represented
as a vector of base ring elements, in which case this function can make
use of an optimized Homomorphism::mul_assign_map() implementation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".