Skip to main content

Sequence

Trait Sequence 

Source
pub trait Sequence {
    type Term;

Show 19 methods // Required methods fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>; fn approx_num_terms(&self) -> Option<usize>; // Provided methods fn is_finite_sequence(&self) -> bool { ... } fn is_empty(&self) -> bool { ... } fn term(&self, n: usize) -> Option<Self::Term> where Self: Sized { ... } fn first_term(&self) -> Option<Self::Term> { ... } fn term_local_zero(&self) -> Option<Self::Term> where Self::Term: LocalZero { ... } fn term_local_one(&self) -> Option<Self::Term> where Self::Term: LocalOne { ... } fn term_local_prime(&self) -> Option<Prime> where Self::Term: AdicPrimitive { ... } fn truncation(&self, len: usize) -> Vec<Self::Term> { ... } fn enumerate(self) -> EnumeratedSequence<Self> where Self: Sized { ... } fn skip(self, n: usize) -> SkippedSequence<Self> where Self: Sized { ... } fn term_map<F, U>(self, op: F) -> MappedSequence<Self, F, U> where Self: Sized, F: Fn(Self::Term) -> U { ... } fn term_scan<St, F, U>( self, initial: St, op: F, ) -> ScannedSequence<Self, St, F, U> where St: Clone, Self: Sized, F: Fn(&mut St, Self::Term) -> U { ... } fn term_add<S>(self, other: S) -> TermAddSequence<Self, S> where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Add<Output = Self::Term> { ... } fn term_mul<S>( self, other: S, trailing_ones: bool, ) -> TermMulSequence<Self, S> where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Mul<Output = Self::Term> { ... } fn term_compose<S, F, U>( self, other: S, default: (Self::Term, S::Term), op: F, ) -> TermComposedSequence<Self, S, F, U> where Self::Term: Clone, Self: Sized, S: Sequence, S::Term: Clone, F: Fn(Self::Term, S::Term) -> U { ... } fn foil_mul<S>(self, other: S) -> FoilMulSequence<Self, S> where Self: Sized, Self::Term: Clone + Mul<Output = Self::Term> + Add<Output = Self::Term>, S: Sequence<Term = Self::Term> { ... } fn carry_with(self, modulus: Self::Term) -> CarrySequence<Self> where Self: Sized, Self::Term: LocalZero + LocalOne + PartialOrd + Add<Output = Self::Term> + Sub<Output = Self::Term> { ... }
}
Expand description

A general sequence of terms

Can be combined with other Sequences with e.g. term_add or foil_mul. Designed to do iterator-like tasks, but Sequence is a collection, not an iterator.

Note: This trait will likely change in adic 0.6.

Required Associated Types§

Source

type Term

Type for the terms of the Sequence

Required Methods§

Source

fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>

Returns an iterator of Sequence terms

Source

fn approx_num_terms(&self) -> Option<usize>

How many terms are in the Sequence or None if it is infinite

Note: do not expect this to be an exact measure of the number of terms. Do not even expect it to match None when infinite, although it should.

Provided Methods§

Source

fn is_finite_sequence(&self) -> bool

Is a finite sequence

Source

fn is_empty(&self) -> bool

Does the Sequence contain no terms

Source

fn term(&self, n: usize) -> Option<Self::Term>
where Self: Sized,

Returns the term at the index

Source

fn first_term(&self) -> Option<Self::Term>

First term; None if Sequence is empty

Source

fn term_local_zero(&self) -> Option<Self::Term>
where Self::Term: LocalZero,

Retrieve a local zero from first term; None if Sequence is empty

Source

fn term_local_one(&self) -> Option<Self::Term>
where Self::Term: LocalOne,

Retrieve a local zero from first term; None if Sequence is empty

Source

fn term_local_prime(&self) -> Option<Prime>
where Self::Term: AdicPrimitive,

Retrieve a prime from first term; None if Sequence is empty

Source

fn truncation(&self, len: usize) -> Vec<Self::Term>

Truncates a Sequence and returns a Vec

Source

fn enumerate(self) -> EnumeratedSequence<Self>
where Self: Sized,

Enumerate a Sequence

Source

fn skip(self, n: usize) -> SkippedSequence<Self>
where Self: Sized,

Skip n terms of a Sequence

Source

fn term_map<F, U>(self, op: F) -> MappedSequence<Self, F, U>
where Self: Sized, F: Fn(Self::Term) -> U,

Map a Sequence to another with the given op, term by term

Source

fn term_scan<St, F, U>( self, initial: St, op: F, ) -> ScannedSequence<Self, St, F, U>
where St: Clone, Self: Sized, F: Fn(&mut St, Self::Term) -> U,

Scans a Sequence, mutating initial and returning it, term by term

Source

fn term_add<S>(self, other: S) -> TermAddSequence<Self, S>
where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Add<Output = Self::Term>,

Add two Sequences, term by term

Source

fn term_mul<S>(self, other: S, trailing_ones: bool) -> TermMulSequence<Self, S>
where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Mul<Output = Self::Term>,

Multiply two Sequences, term by term

If trailing_ones is true, the Sequence continues with 1 after it ends. If trailing_ones is false, the Sequence terminates with 0 after it ends.

Source

fn term_compose<S, F, U>( self, other: S, default: (Self::Term, S::Term), op: F, ) -> TermComposedSequence<Self, S, F, U>
where Self::Term: Clone, Self: Sized, S: Sequence, S::Term: Clone, F: Fn(Self::Term, S::Term) -> U,

Compose two Sequences with the given op, term by term

default gives the term that should be used after one of the sequences terminates.

Source

fn foil_mul<S>(self, other: S) -> FoilMulSequence<Self, S>
where Self: Sized, Self::Term: Clone + Mul<Output = Self::Term> + Add<Output = Self::Term>, S: Sequence<Term = Self::Term>,

Multiply two Sequences by FOIL, i.e. (a, b, c...).foil_mul(d, e, f...) = (ad, ae + bd, af + be + cd...)

Source

fn carry_with(self, modulus: Self::Term) -> CarrySequence<Self>
where Self: Sized, Self::Term: LocalZero + LocalOne + PartialOrd + Add<Output = Self::Term> + Sub<Output = Self::Term>,

Rectify Sequence terms to be 0 <= term < modulus, carrying remainders

Trait Implementations§

Source§

impl<T> Sequence for Box<dyn Sequence<Term = T> + '_>

Source§

type Term = T

Type for the terms of the Sequence
Source§

fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>

Returns an iterator of Sequence terms
Source§

fn approx_num_terms(&self) -> Option<usize>

How many terms are in the Sequence or None if it is infinite Read more
Source§

fn is_finite_sequence(&self) -> bool

Is a finite sequence
Source§

fn is_empty(&self) -> bool

Does the Sequence contain no terms
Source§

fn term(&self, n: usize) -> Option<Self::Term>
where Self: Sized,

Returns the term at the index
Source§

fn first_term(&self) -> Option<Self::Term>

First term; None if Sequence is empty
Source§

fn term_local_zero(&self) -> Option<Self::Term>
where Self::Term: LocalZero,

Retrieve a local zero from first term; None if Sequence is empty
Source§

fn term_local_one(&self) -> Option<Self::Term>
where Self::Term: LocalOne,

Retrieve a local zero from first term; None if Sequence is empty
Source§

fn term_local_prime(&self) -> Option<Prime>
where Self::Term: AdicPrimitive,

Retrieve a prime from first term; None if Sequence is empty
Source§

fn truncation(&self, len: usize) -> Vec<Self::Term>

Truncates a Sequence and returns a Vec
Source§

fn enumerate(self) -> EnumeratedSequence<Self>
where Self: Sized,

Enumerate a Sequence
Source§

fn skip(self, n: usize) -> SkippedSequence<Self>
where Self: Sized,

Skip n terms of a Sequence
Source§

fn term_map<F, U>(self, op: F) -> MappedSequence<Self, F, U>
where Self: Sized, F: Fn(Self::Term) -> U,

Map a Sequence to another with the given op, term by term
Source§

fn term_scan<St, F, U>( self, initial: St, op: F, ) -> ScannedSequence<Self, St, F, U>
where St: Clone, Self: Sized, F: Fn(&mut St, Self::Term) -> U,

Scans a Sequence, mutating initial and returning it, term by term
Source§

fn term_add<S>(self, other: S) -> TermAddSequence<Self, S>
where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Add<Output = Self::Term>,

Add two Sequences, term by term
Source§

fn term_mul<S>(self, other: S, trailing_ones: bool) -> TermMulSequence<Self, S>
where Self: Sized, S: Sequence<Term = Self::Term>, Self::Term: Clone + Mul<Output = Self::Term>,

Multiply two Sequences, term by term Read more
Source§

fn term_compose<S, F, U>( self, other: S, default: (Self::Term, S::Term), op: F, ) -> TermComposedSequence<Self, S, F, U>
where Self::Term: Clone, Self: Sized, S: Sequence, S::Term: Clone, F: Fn(Self::Term, S::Term) -> U,

Compose two Sequences with the given op, term by term Read more
Source§

fn foil_mul<S>(self, other: S) -> FoilMulSequence<Self, S>
where Self: Sized, Self::Term: Clone + Mul<Output = Self::Term> + Add<Output = Self::Term>, S: Sequence<Term = Self::Term>,

Multiply two Sequences by FOIL, i.e. (a, b, c...).foil_mul(d, e, f...) = (ad, ae + bd, af + be + cd...)
Source§

fn carry_with(self, modulus: Self::Term) -> CarrySequence<Self>
where Self: Sized, Self::Term: LocalZero + LocalOne + PartialOrd + Add<Output = Self::Term> + Sub<Output = Self::Term>,

Rectify Sequence terms to be 0 <= term < modulus, carrying remainders

Implementations on Foreign Types§

Source§

impl<T> Sequence for Box<dyn Sequence<Term = T> + '_>

Source§

type Term = T

Source§

fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>

Source§

fn approx_num_terms(&self) -> Option<usize>

Source§

impl<T> Sequence for Rc<dyn Sequence<Term = T> + '_>

Source§

type Term = T

Source§

fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>

Source§

fn approx_num_terms(&self) -> Option<usize>

Source§

impl<T> Sequence for Vec<T>
where T: Clone,

Source§

type Term = T

Source§

fn terms(&self) -> Box<dyn Iterator<Item = Self::Term> + '_>

Source§

fn approx_num_terms(&self) -> Option<usize>

Implementors§

Source§

impl<A, B> Sequence for FoilMulSequence<A, B>
where A: Sequence, B: Sequence<Term = A::Term>, A::Term: Clone + Add<Output = A::Term> + Mul<Output = A::Term>,

Source§

type Term = <A as Sequence>::Term

Source§

impl<A, B> Sequence for TermAddSequence<A, B>
where A: Sequence, B: Sequence<Term = A::Term>, A::Term: Clone + Add<Output = A::Term>,

Source§

type Term = <A as Sequence>::Term

Source§

impl<A, B> Sequence for TermMulSequence<A, B>
where A: Sequence, B: Sequence<Term = A::Term>, A::Term: Clone + Mul<Output = A::Term>,

Source§

type Term = <A as Sequence>::Term

Source§

impl<A, B, F, U> Sequence for TermComposedSequence<A, B, F, U>
where A: Sequence, A::Term: Clone, B: Sequence, B::Term: Clone, F: Fn(A::Term, B::Term) -> U,

Source§

type Term = U

Source§

impl<F, T> Sequence for F
where F: Fn(usize) -> T,

Source§

type Term = T

Source§

impl<S> Sequence for CarrySequence<S>
where S: Sequence, S::Term: Clone + LocalZero + LocalOne + PartialOrd + Add<Output = S::Term> + Sub<Output = S::Term>,

Source§

type Term = <S as Sequence>::Term

Source§

impl<S> Sequence for EnumeratedSequence<S>
where S: Sequence,

Source§

type Term = (usize, <S as Sequence>::Term)

Source§

impl<S> Sequence for SkippedSequence<S>
where S: Sequence,

Source§

type Term = <S as Sequence>::Term

Source§

impl<S, F, U> Sequence for MappedSequence<S, F, U>
where S: Sequence, F: Fn(S::Term) -> U,

Source§

type Term = U

Source§

impl<S, St, F, U> Sequence for ScannedSequence<S, St, F, U>
where S: Sequence, St: Clone, F: Fn(&mut St, S::Term) -> U,

Source§

type Term = U