Skip to main content

Trellis

Trait Trellis 

Source
pub trait Trellis<const DEGREE: usize> {
    type Frame<'a>: Copy
       where Self: 'a;

    const REACH: u8 = 1;

    // Required methods
    fn num_frames(&self) -> usize;
    fn num_positions(&self) -> usize;
    fn frame(&self, frame: usize) -> Self::Frame<'_>;
    fn steps_into(
        &self,
        frame: Self::Frame<'_>,
        position: usize,
    ) -> [Step; DEGREE];
}
Expand description

T frames against N + 1 positions, one frame consumed per transition.

DEGREE is how many transitions enter every cell, four for the chain align uses. They are listed best-first: the solver keeps the first of them that is strictly better than what it has, so the order is the tie-break, and a trellis states its own by the order it lists them in.

See the module docs for a worked implementation.

Provided Associated Constants§

Source

const REACH: u8 = 1

The most positions any one transition advances. One for a chain, where a frame either holds its position or moves to the next; more for a trellis that can pass over several positions at once, such as one that gives up a whole word.

It sets how wide the band has to be, so an overstated REACH costs work while an understated one is a contract violation.

Required Associated Types§

Source

type Frame<'a>: Copy where Self: 'a

What one frame’s transitions are read from, usually a row of acoustic scores.

Taken once per frame rather than once per cell, which for a matrix means the row is sliced T times rather than T × N times.

Required Methods§

Source

fn num_frames(&self) -> usize

The number of frames to be accounted for.

Source

fn num_positions(&self) -> usize

The last position. There are num_positions() + 1 cells in a frame, s_0 through s_N; a path starts at s_0 and has to finish at s_N.

Source

fn frame(&self, frame: usize) -> Self::Frame<'_>

One frame’s scores.

Source

fn steps_into(&self, frame: Self::Frame<'_>, position: usize) -> [Step; DEGREE]

The DEGREE transitions entering position, best-first.

A transition that does not exist at this cell is Step::ABSENT, and so is one that would come from before s_0, since the solver indexes position - advance without checking it.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<A: Arc> Trellis<4> for ChainTrellis<'_, A>
where A::Weight: FromScore,

Source§

type Frame<'f> = &'f [f32] where Self: 'f