Skip to main content

Trellis

Struct Trellis 

Source
pub struct Trellis {
    pub threshold: usize,
    pub n_max: usize,
    /* private fields */
}
Expand description

Trellis is a data structure to hold a bounded trellis

Trellis nodes hold a rug::Integer and are indexed by stage (0..n_max) and weight_level (one of the accepted weight levels).

weight_levels for each stage are returned by Trellis::get_weight_levels(). Node values can be read and set by using the Trellis::get() and Trellis::set() methods.

Fields§

§threshold: usize§n_max: usize

Implementations§

Source§

impl Trellis

Source

pub fn new(threshold: usize, n_max: usize, weights: &[usize]) -> Trellis

Create a new Trellis instance

The smallest weight must be 0

Source

pub fn new_like(trellis: &Trellis) -> Trellis

Source

pub fn new_expandable(n_max: usize, weights: &[usize]) -> Trellis

Source§

impl Trellis

Source

pub fn get(&self, stage: usize, weight_level: usize) -> Integer

Get function for trellis values

Source

pub fn get_or_0(&self, stage: usize, weight_level: usize) -> Integer

Get function for trellis values, returns 0 if weight_level is invalid

Source

pub fn get_stage(&self, stage: usize) -> Vec<Integer>

Source

pub fn set(&mut self, stage: usize, weight_level: usize, value: Integer)

Set function for trellis values

Source

pub fn add(&mut self, stage: usize, weight_level: usize, value: Integer)

Function to add a value to an existing trellis value

Source

pub fn get_weight(&self, weight_index: usize) -> usize

Returns the weight for the given weight index

Source

pub fn get_weights(&self) -> Vec<usize>

Returns the weights of this trellis

Source

pub fn get_weight_levels(&self) -> Vec<usize>

Returns the weight levels of this trellis

Source

pub fn get_num_weight_levels(&self) -> usize

Returns the number of weight levels used by the stored data

Source

pub fn get_weight_level_index(&self, weight_level: usize) -> usize

Returns the index of the given weight level

Source

pub fn get_storage_dimensions(&self) -> (usize, usize)

Source

pub fn expand_with( &mut self, new_values: &mut Vec<Integer>, ) -> Result<(), &'static str>

Increase the trellis size by one weight level mooving in the provided trellis values

Note: the values are removed from new_values

Source

pub fn get_successors(&self, weight_level: usize) -> Vec<(usize, usize)>

Returns a Vec of (weight_index, weight_level) for each weight level reachable from weight_level with a single step

The weight levels are sorted in ascending order. Multiple entries with the same weight level are sorted by weight index in ascending order.

Source

pub fn get_predecessors(&self, weight_level: usize) -> Vec<(usize, usize)>

Returns a Vec of (weight_index, weight_level) for each weight level which can reach weight_level with a single step

The tuples are sorted in ascending order wrt. the weight_level values. Multiple tuples with the same weight_level are sorted in descending order wrt. the weight_index.

Trait Implementations§

Source§

impl Debug for Trellis

Source§

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

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

impl PartialEq for Trellis

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 Eq for Trellis

Auto Trait Implementations§

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.