Steps2D

Struct Steps2D 

Source
pub struct Steps2D<T>(pub (T, T, usize), pub (T, T, usize));
Expand description

Utility for creating evenly spaced steps between two endpoints in 2 dimensions

§Example:

use spdcalc::utils::Steps2D;

let arr : Vec<(f64, f64)> = Steps2D((0., 1., 100), (0., 100., 100)).into_iter().collect();
assert_eq!(arr.len(), 100 * 100);
assert!((arr[0].0 - 0.).abs() < 1e-12);
assert!((arr[99].0 - 1.).abs() < 1e-12);
assert!((arr[0].1 - 0.).abs() < 1e-12);
assert!((arr[99].1 - 0.).abs() < 1e-12);
assert!((arr[9999].0 - 1.).abs() < 1e-12);
assert!((arr[9999].1 - 100.).abs() < 1e-12);

Tuple Fields§

§0: (T, T, usize)§1: (T, T, usize)

Implementations§

Source§

impl<T> Steps2D<T>
where T: Div<f64, Output = T> + Sub<T, Output = T> + Mul<f64, Output = T> + Add<T, Output = T> + Copy,

Source

pub fn new(x: (T, T, usize), y: (T, T, usize)) -> Self

Create a new instance

Source

pub fn divisions(&self) -> (usize, usize)

Number of divisions for each axis

Source

pub fn ranges(&self) -> ((T, T), (T, T))

Range of each axis

Source

pub fn len(&self) -> usize

Total number of steps

Source

pub fn is_empty(&self) -> bool

Is it empty?

Source

pub fn is_square(&self) -> bool

Same number of steps for each axis?

Source

pub fn value(&self, index: usize) -> (T, T)

Get the value at the given index

Source

pub fn swapped(self) -> Steps2D<T>

Swap x and y

Source

pub fn division_widths(&self) -> (T, T)

Get the width of the gap between each step.

§Example:
use spdcalc::utils::Steps2D;

let steps = Steps2D((0., 4., 3), (0., 8., 3)); // 3 steps: |0| --- |2| --- |4| and |0| --- |4| --- |8|
let dx = 2.;
let dy = 4.;
assert!((steps.division_widths().0 - dx).abs() < 1e-12);
assert!((steps.division_widths().1 - dy).abs() < 1e-12);

Trait Implementations§

Source§

impl<T: Clone> Clone for Steps2D<T>

Source§

fn clone(&self) -> Steps2D<T>

Returns a duplicate 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<T: Debug> Debug for Steps2D<T>

Source§

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

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

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

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 From<Steps2D<UCUM<f64, <TArr<Z0, TArr<Z0, TArr<Z0, TArr<PInt<UInt<UTerm, B1>>, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>> as Add<<TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>> as Sub<TArr<Z0, TArr<PInt<UInt<UTerm, B1>>, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>>>>::Output>>::Output>>> for FrequencySpace

Source§

fn from(steps: Steps2D<Frequency>) -> Self

Converts to this type from the input type.
Source§

impl From<Steps2D<UCUM<f64, <TArr<Z0, TArr<Z0, TArr<Z0, TArr<PInt<UInt<UTerm, B1>>, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>> as Add<<TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>> as Sub<TArr<Z0, TArr<PInt<UInt<UTerm, B1>>, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>>>>::Output>>::Output>>> for SumDiffFrequencySpace

Source§

fn from(steps: Steps2D<Frequency>) -> Self

Converts to this type from the input type.
Source§

impl From<Steps2D<UCUM<f64, TArr<PInt<UInt<UTerm, B1>>, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, TArr<Z0, ATerm>>>>>>>>>> for WavelengthSpace

Source§

fn from(steps: Steps2D<Wavelength>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Steps2D<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> IntoIterator for Steps2D<T>
where T: Div<f64, Output = T> + Sub<T, Output = T> + Mul<f64, Output = T> + Add<T, Output = T> + Copy,

Source§

type Item = (T, T)

The type of the elements being iterated over.
Source§

type IntoIter = Iterator2D<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoParallelIterator for Steps2D<T>
where T: Send + Sync + Div<f64, Output = T> + Sub<T, Output = T> + Mul<f64, Output = T> + Add<T, Output = T> + Copy,

Source§

type Item = (T, T)

The type of item that the parallel iterator will produce.
Source§

type Iter = ParIterator2D<T>

The parallel iterator type that will be created.
Source§

fn into_par_iter(self) -> Self::Iter

Converts self into a parallel iterator. Read more
Source§

impl<T> Serialize for Steps2D<T>
where T: Serialize,

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<T: Copy> Copy for Steps2D<T>

Auto Trait Implementations§

§

impl<T> Freeze for Steps2D<T>
where T: Freeze,

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Steps2D<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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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

Source§

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

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> SendAlias for T

Source§

impl<T> SyncAlias for T