Struct vegas_lattice::Vertex

source ·
pub struct Vertex { /* private fields */ }
Expand description

Represents a vertex in a lattice.

The source and target fields are the indices of the sites that the vertex connects. The delta field is a tuple of the displacements of the target site from the source site. A delta of (0, 0, 1) would mean that the target site is one unit along the z axis from the source site.

For a simple cubic lattice the source and target for all the vertices would be the same, 0. While delta would be (1, 0, 0), (0, 1, 0), (0, 0, 1). Those 3 vertices would connect all the sites in the lattice.

§Examples

Here is an example of how to create a vertex and access its fields:

use vegas_lattice::Vertex;

let vertex = Vertex::new(0, 1, (0, 0, 1));
assert_eq!(vertex.source(), 0);
assert_eq!(vertex.target(), 1);
assert_eq!(vertex.delta(), (0, 0, 1));

Here’s how to move a vertex along an axis:

use vegas_lattice::{Vertex, Axis};

let vertex = Vertex::new(0, 1, (0, 0, 1)).move_along(Axis::Z, 1, 2, 3);
assert_eq!(vertex.source(), 2);
assert_eq!(vertex.target(), 5);
assert_eq!(vertex.delta(), (0, 0, 0));

Implementations§

source§

impl Vertex

source

pub fn new(source: usize, target: usize, delta: (i32, i32, i32)) -> Self

Creates a new vertex with the given source and target

source

pub fn source(&self) -> usize

Returns the source of the vertex

source

pub fn target(&self) -> usize

Returns the target of the vertex

source

pub fn delta(&self) -> (i32, i32, i32)

Returns the delta of the vertex

source

pub fn delta_along(&self, axis: Axis) -> i32

Returns the delta of the vertex alogn a given axis

source

pub fn with_tags(self, tags: Vec<&str>) -> Self

Chagges the tags of the vertex

source

pub fn move_along( self, axis: Axis, amount: usize, nsites: usize, limit: usize ) -> Self

Move the vertex along a given axis by a given amount

The only reason you would want to move a vertex along an axis is to grow a lattice along that axis. That’s why we’re going to need to know the parameters of how much the lattice is going to grow by. This function takes in the nsites, the number of sites in the original lattice, and the limit, the total number of units the lattice will be grown by. The vertex will be changed assuming that the new number of sites will be limit * nsites.

§Warning

This function is so complicated it should be private!

§Arguments
  • axis - The axis along which to move the vertex
  • amount - The number of units to move the vertex
  • nsites - The number of sites in the original lattice
  • limit - The total number of units the lattice will be grown by
source

pub fn reindex(self, index: &[usize]) -> Self

Re-index the vertex

Trait Implementations§

source§

impl Clone for Vertex

source§

fn clone(&self) -> Vertex

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Vertex

source§

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

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

impl<'de> Deserialize<'de> for Vertex

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromStr for Vertex

§

type Err = Error

The associated error which can be returned from parsing.
source§

fn from_str(source: &str) -> Result<Vertex, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl Serialize for Vertex

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Tagged for Vertex

source§

fn tags(&self) -> Option<&Vec<String>>

Returns the tags of the object
source§

fn has_tag(&self, tag: String) -> bool

Returns true if the object has the given tag

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

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,