Skip to main content

PotentialFunction

Trait PotentialFunction 

Source
pub trait PotentialFunction {
    type Item: CommutativeGroup;

    // Required methods
    fn new(n: usize, cgroup: Self::Item) -> Self;
    fn len(&self) -> usize;
    fn relate(
        &mut self,
        u: usize,
        v: usize,
        w: <Self::Item as Magma>::Set,
    ) -> Result<bool, <Self::Item as Magma>::Set>;
    fn diff(&self, u: usize, v: usize) -> Option<<Self::Item as Magma>::Set>;
    fn repr_diff(&self, u: usize) -> (usize, <Self::Item as Magma>::Set);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

ポテンシャル関数。

Required Associated Types§

Source

type Item: CommutativeGroup

要素の型。

Required Methods§

Source

fn new(n: usize, cgroup: Self::Item) -> Self

要素数 $n$ の集合 $\{0, 1, \dots, n-1\}$ で初期化する。

Source

fn len(&self) -> usize

集合の要素数 $n$ を返す。

Source

fn relate( &mut self, u: usize, v: usize, w: <Self::Item as Magma>::Set, ) -> Result<bool, <Self::Item as Magma>::Set>

ポテンシャルの差を定義する。

$\phi(x_u)-\phi(x_v) = w$ とする。

呼び出し前の定義と矛盾しない場合、呼び出し前に $\phi(x_u)-\phi(x_v)$ が未定義なら Ok(true) を、そうでなければ Ok(false) を返す。 矛盾する場合、定義は変化せずに Err(e) を返す。ただし、e は呼び出し前の $\phi(x_u) - \phi(x_v)$ を表す。

Source

fn diff(&self, u: usize, v: usize) -> Option<<Self::Item as Magma>::Set>

ポテンシャルの差を求める。

$\phi(x_u)-\phi(x_v) = w$ であれば Some(w) を返す。 未定義ならば None を返す。

Source

fn repr_diff(&self, u: usize) -> (usize, <Self::Item as Magma>::Set)

代表元とのポテンシャルの差を求める。

Provided Methods§

Source

fn is_empty(&self) -> bool

集合が空であれば true を返す。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§