binius_core::tensor_algebra

Struct TensorAlgebra

source
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>,

source

pub fn new(elems: Vec<FE>) -> Self

Constructs an element from a vector of vertical subring elements.

§Preconditions
  • elems must have length FE::DEGREE, otherwise this will pad or truncate.
source

pub const fn kappa() -> usize

Returns $\kappa$, the base-2 logarithm of the extension degree.

source

pub fn byte_size() -> usize

Returns the byte size of an element.

source

pub fn one() -> Self

Returns the multiplicative identity element, one.

source

pub fn vertical_elems(&self) -> &[FE]

Returns a slice of the vertical subfield elements composing the tensor algebra element.

source

pub fn tensor(vertical: FE, horizontal: FE) -> Self

Tensor product of a vertical subring element and a horizontal subring element.

source

pub fn from_vertical(x: FE) -> Self

Constructs a TensorAlgebra in the vertical subring.

source

pub fn try_extract_vertical(&self) -> Option<FE>

If the algebra element lives in the vertical subring, this returns it as a field element.

source

pub fn scale_vertical(self, scalar: FE) -> Self

Multiply by an element from the vertical subring.

source§

impl<F, FE> TensorAlgebra<F, FE>
where F: Field, FE: ExtensionField<F> + PackedExtension<F>, FE::Scalar: ExtensionField<F>,

source

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.

source

pub fn transpose(self) -> Self

Transposes the algebra element.

A transpose flips the vertical and horizontal subring elements.

Trait Implementations§

source§

impl<F, FE> Add<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>
where F: Field, FE: ExtensionField<F>,

source§

type Output = TensorAlgebra<F, FE>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &Self) -> Self

Performs the + operation. Read more
source§

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)

Performs the += operation. Read more
source§

impl<F, FE> Clone for TensorAlgebra<F, FE>
where F: Field + Clone, FE: ExtensionField<F> + Clone,

source§

fn clone(&self) -> TensorAlgebra<F, FE>

Returns a copy of the value. Read more
1.6.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<F, FE> Debug for TensorAlgebra<F, FE>
where F: Field + Debug, FE: ExtensionField<F> + Debug,

source§

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

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

impl<F, FE> Default for TensorAlgebra<F, FE>
where F: Field, FE: ExtensionField<F>,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<F, FE> PartialEq for TensorAlgebra<F, FE>
where F: Field + PartialEq, FE: ExtensionField<F> + PartialEq,

source§

fn eq(&self, other: &TensorAlgebra<F, FE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.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<F, FE> Sub<&TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>
where F: Field, FE: ExtensionField<F>,

source§

type Output = TensorAlgebra<F, FE>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: &Self) -> Self

Performs the - operation. Read more
source§

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)

Performs the -= operation. Read more
source§

impl<'a, F, FE> Sum<&'a TensorAlgebra<F, FE>> for TensorAlgebra<F, FE>
where F: Field, FE: ExtensionField<F>,

source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl<F, FE> Eq for TensorAlgebra<F, FE>
where F: Field + Eq, FE: ExtensionField<F> + Eq,

source§

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>

§

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>

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 T)

🔬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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

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 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more