pub struct TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,{
pub elems: Vec<FE>,
/* private fields */
}
Expand description
An element of the tensor algebra defined as the tensor product of FE
and FE
as fields.
A tensor algebra element is a length $D$ vector of FE
field elements, where $D$ is the degree
of FE
as an extension of F
. The algebra has a “vertical subring” and a “horizontal subring”,
which are both isomorphic to FE
as a field.
See DP24 Section 2 for further details.
Fields§
§elems: Vec<FE>
Implementations§
Source§impl<F, FE> TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Sourcepub fn new(elems: Vec<FE>) -> Self
pub fn new(elems: Vec<FE>) -> Self
Constructs an element from a vector of vertical subring elements.
§Preconditions
elems
must have lengthFE::DEGREE
, otherwise this will pad or truncate.
Sourcepub fn vertical_elems(&self) -> &[FE]
pub fn vertical_elems(&self) -> &[FE]
Returns a slice of the vertical subfield elements composing the tensor algebra element.
Sourcepub fn tensor(vertical: FE, horizontal: FE) -> Self
pub fn tensor(vertical: FE, horizontal: FE) -> Self
Tensor product of a vertical subring element and a horizontal subring element.
Sourcepub fn from_vertical(x: FE) -> Self
pub fn from_vertical(x: FE) -> Self
Constructs a TensorAlgebra
in the vertical subring.
Sourcepub fn try_extract_vertical(&self) -> Option<FE>
pub fn try_extract_vertical(&self) -> Option<FE>
If the algebra element lives in the vertical subring, this returns it as a field element.
Sourcepub fn scale_vertical(self, scalar: FE) -> Self
pub fn scale_vertical(self, scalar: FE) -> Self
Multiply by an element from the vertical subring.
Source§impl<F, FE> TensorAlgebra<F, FE>
impl<F, FE> TensorAlgebra<F, FE>
Sourcepub fn scale_horizontal(self, scalar: FE) -> Self
pub fn scale_horizontal(self, scalar: FE) -> Self
Multiply by an element from the vertical subring.
Internally, this performs a transpose, vertical scaling, then transpose sequence. If multiple horizontal scaling operations are required and performance is a concern, it may be better for the caller to do the transposes directly and amortize their cost.
Sourcepub fn transpose(self) -> Self
pub fn transpose(self) -> Self
Transposes the algebra element.
A transpose flips the vertical and horizontal subring elements.
Sourcepub fn fold_vertical(self, coeffs: &[FE]) -> FE
pub fn fold_vertical(self, coeffs: &[FE]) -> FE
Fold the tensor algebra element into a field element by scaling the rows and accumulating.
§Preconditions
coeffs
must have length $2^\kappa$
Trait Implementations§
Source§impl<F, FE> Add<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> Add<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Source§impl<F, FE> AddAssign<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> AddAssign<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
+=
operation. Read moreSource§impl<F, FE> Clone for TensorAlgebra<F, FE>
impl<F, FE> Clone for TensorAlgebra<F, FE>
Source§fn clone(&self) -> TensorAlgebra<F, FE>
fn clone(&self) -> TensorAlgebra<F, FE>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<F, FE> Debug for TensorAlgebra<F, FE>
impl<F, FE> Debug for TensorAlgebra<F, FE>
Source§impl<F, FE> Default for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> Default for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Source§impl<F, FE> PartialEq for TensorAlgebra<F, FE>
impl<F, FE> PartialEq for TensorAlgebra<F, FE>
Source§impl<F, FE> Sub<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> Sub<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Source§impl<F, FE> SubAssign<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> SubAssign<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
-=
operation. Read moreSource§impl<'a, F, FE> Sum<&'a TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<'a, F, FE> Sum<&'a TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
impl<F, FE> Eq for TensorAlgebra<F, FE>
impl<F, FE> StructuralPartialEq for TensorAlgebra<F, FE>where
F: Field,
FE: ExtensionField<F>,
Auto Trait Implementations§
impl<F, FE> Freeze for TensorAlgebra<F, FE>
impl<F, FE> RefUnwindSafe for TensorAlgebra<F, FE>where
<FE as WithUnderlier>::Underlier: Sized,
<F as WithUnderlier>::Underlier: Sized,
F: RefUnwindSafe,
FE: RefUnwindSafe,
impl<F, FE> Send for TensorAlgebra<F, FE>
impl<F, FE> Sync for TensorAlgebra<F, FE>
impl<F, FE> Unpin for TensorAlgebra<F, FE>where
<FE as WithUnderlier>::Underlier: Sized,
<F as WithUnderlier>::Underlier: Sized,
F: Unpin,
FE: Unpin,
impl<F, FE> UnwindSafe for TensorAlgebra<F, FE>where
<FE as WithUnderlier>::Underlier: Sized,
<F as WithUnderlier>::Underlier: Sized,
F: UnwindSafe,
FE: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more