Struct discrete::Context

source ·
pub struct Context<T = Data>(/* private fields */);
Expand description

A discrete space that can model spatial operations over arbitrary states, therefore useful for context analysis.

It can be constructed by taking a N-dimensional space, for each dimension create a pair subspace and sum over the dimensions. It can also be thought of as the edges in an undirected graph, where each node is described by a N-dimensional coordinate, and all nodes are connected which differ by one axis.

Dimensions of size 2 gives the edges on a hypercube of the number of dimensions. For example, [2, 2, 2] gives edges on a cube in 3 dimensions.

The position is a tuple (Vec<usize>, usize, usize), where the first component describes the node coordinates, the second component describes the index of the coordinate that changes, and the third component describes the new value.

Trait Implementations§

source§

impl<T> Construct for Context<T>

source§

fn new() -> Context<T>

Constructs a new Self.
source§

impl Space<BigUint> for Context<Data>

§

type Dim = Vec<BigUint>

The dimension type of the space.
§

type Pos = (Vec<BigUint>, usize, BigUint)

The position type of the space.
source§

fn count(&self, dim: &Vec<BigUint>) -> BigUint

Counts the size of space given the dimensions.
source§

fn zero(&self, dim: &Vec<BigUint>) -> (Vec<BigUint>, usize, BigUint)

Creates a default element.
source§

fn to_index(&self, dim: &Self::Dim, (p, ind, b): &Self::Pos) -> BigUint

Converts position to index.
source§

fn to_pos( &self, dim: &Self::Dim, index: BigUint, (p, ind, b): &mut (Vec<BigUint>, usize, BigUint) )

Converts index to position.
source§

impl<N, T> Space<N> for Context<Of<T>>
where T: Space<N>, Pair<Data>: Space<N, Dim = N, Pos = (N, N)>, for<'a> N: Clone + From<usize> + Ord + MulAssign<&'a N> + SubAssign<&'a N> + DivAssign<&'a N> + AddAssign<&'a N>, for<'a> &'a N: Mul<&'a N, Output = N> + Div<&'a N, Output = N> + Add<&'a N, Output = N> + Sub<&'a N, Output = N>,

§

type Dim = Vec<<T as Space<N>>::Dim>

The dimension type of the space.
§

type Pos = (Vec<<T as Space<N>>::Pos>, usize, <T as Space<N>>::Pos)

The position type of the space.
source§

fn count(&self, dim: &Self::Dim) -> N

Counts the size of space given the dimensions.
source§

fn zero(&self, dim: &Self::Dim) -> Self::Pos

Creates a default element.
source§

fn to_index(&self, dim: &Self::Dim, (p, ind, b): &Self::Pos) -> N

Converts position to index.
source§

fn to_pos(&self, dim: &Self::Dim, index: N, (p, ind, b): &mut Self::Pos)

Converts index to position.
source§

impl Space<usize> for Context<Data>

§

type Dim = Vec<usize>

The dimension type of the space.
§

type Pos = (Vec<usize>, usize, usize)

The position type of the space.
source§

fn count(&self, dim: &Vec<usize>) -> usize

Counts the size of space given the dimensions.
source§

fn zero(&self, dim: &Vec<usize>) -> (Vec<usize>, usize, usize)

Creates a default element.
source§

fn to_index( &self, dim: &Vec<usize>, (p, ind, b): &(Vec<usize>, usize, usize) ) -> usize

Converts position to index.
source§

fn to_pos( &self, dim: &Vec<usize>, index: usize, (p, ind, b): &mut (Vec<usize>, usize, usize) )

Converts index to position.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Context<T>
where T: RefUnwindSafe,

§

impl<T> Send for Context<T>
where T: Send,

§

impl<T> Sync for Context<T>
where T: Sync,

§

impl<T> Unpin for Context<T>
where T: Unpin,

§

impl<T> UnwindSafe for Context<T>
where T: UnwindSafe,

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<D, T> Count<D, BigUint> for T
where T: Space<BigUint, Dim = D>,

source§

fn count(&self, dim: &D) -> BigUint

Counts the size of space given the dimensions.
source§

impl<D, T> Count<D, usize> for T
where T: Space<usize, Dim = D>,

source§

fn count(&self, dim: &D) -> usize

Counts the size of space given the dimensions.
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<D, P, T> ToIndex<D, P, BigUint> for T
where T: Space<BigUint, Dim = D, Pos = P>,

source§

fn to_index(&self, dim: &D, pos: &P) -> BigUint

Converts position to index.
source§

impl<D, P, T> ToIndex<D, P, usize> for T
where T: Space<usize, Dim = D, Pos = P>,

source§

fn to_index(&self, dim: &D, pos: &P) -> usize

Converts position to index.
source§

impl<D, P, T> ToPos<D, P, BigUint> for T
where T: Space<BigUint, Dim = D, Pos = P>,

source§

fn to_pos(&self, dim: &D, ind: BigUint, pos: &mut P)

Converts index to position.
source§

impl<D, P, T> ToPos<D, P, usize> for T
where T: Space<usize, Dim = D, Pos = P>,

source§

fn to_pos(&self, dim: &D, ind: usize, pos: &mut P)

Converts index to position.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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<D, P, T> Zero<D, P, BigUint> for T
where T: Space<BigUint, Dim = D, Pos = P>,

source§

fn zero(&self, dim: &D) -> P

Creates a default element.
source§

impl<D, P, T> Zero<D, P, usize> for T
where T: Space<usize, Dim = D, Pos = P>,

source§

fn zero(&self, dim: &D) -> P

Creates a default element.