Dense

Struct Dense 

Source
pub struct Dense<DS, const D: usize> { /* private fields */ }
Expand description

Base structure for all Dense variants.

§Types

  • D: Number of dimensions
  • DS: Data Storage

Implementations§

Source§

impl<DS, const D: usize> Dense<DS, D>

Source

pub fn dims(&self) -> &[usize; D]

The definitions of all dimensions.

§Example
use ndstruct::doc_tests::dense_array_3;
assert_eq!(dense_array_3().dims(), &[4, 3, 3]);
Source§

impl<DATA, DS, const D: usize> Dense<DS, D>
where DS: AsRef<[<DS as SingleTypeStorage>::Item]> + SingleTypeStorage<Item = DATA>,

Source

pub fn new(dims: [usize; D], data: DS) -> Result<Self>

Creates a valid Dense instance.

§Arguments
  • dims: Array of dimensions
  • data: Data collection
§Example
use ndstruct::dense::{DenseArray, DenseVec};
// Matrix ([1, 2, 3], [4, 5, 6])
let mut _matrix = DenseArray::new([2, 3], [1, 2, 3, 4, 5, 6]);
// A bunch of nothing for your overflow needs
let _over_nine: ndstruct::Result<DenseVec<(), 9001>>;
_over_nine = DenseVec::new([0; 9001], vec![]);
Source

pub fn data(&self) -> &[DATA]

The data that is being stored.

§Example
use ndstruct::doc_tests::dense_array_3;
assert_eq!(dense_array_3().data(), &[
   1,  2,  3,  4,  5,  6,  7,  8,  9,
  10, 11, 12, 13, 14, 15, 16, 17, 18,
  19, 20, 21, 22, 23, 24, 25, 26, 27,
  28, 29, 30, 31, 32, 33, 34, 35, 36,
]);
Source

pub fn value(&self, indcs: [usize; D]) -> Option<&DATA>

If any, retrieves an immutable data reference of a given set of indices.

§Arguments
  • indcs: Indices of the desired data location
§Example
use ndstruct::doc_tests::dense_array_3;
let elem = dense_array_3();
assert_eq!(elem.value([0, 0, 0]), Some(&1));
assert_eq!(elem.value([0, 0, 2]), Some(&3));
assert_eq!(elem.value([0, 2, 2]), Some(&9));
assert_eq!(elem.value([3, 2, 2]), Some(&36));
assert_eq!(elem.value([3, 2, 3]), None);

Trait Implementations§

Source§

impl<DS: Clone, const D: usize> Clone for Dense<DS, D>

Source§

fn clone(&self) -> Dense<DS, D>

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<DS: Debug, const D: usize> Debug for Dense<DS, D>

Source§

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

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

impl<DS: Default, const D: usize> Default for Dense<DS, D>

Source§

fn default() -> Dense<DS, D>

Returns the “default value” for a type. Read more
Source§

impl<'de, DS, const D: usize> Deserialize<'de> for Dense<DS, D>
where DS: 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<DS: Ord, const D: usize> Ord for Dense<DS, D>

Source§

fn cmp(&self, other: &Dense<DS, D>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<DS: PartialEq, const D: usize> PartialEq for Dense<DS, D>

Source§

fn eq(&self, other: &Dense<DS, D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<DS: PartialOrd, const D: usize> PartialOrd for Dense<DS, D>

Source§

fn partial_cmp(&self, other: &Dense<DS, D>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<DS, const D: usize> Serialize for Dense<DS, D>
where DS: 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<DS: Eq, const D: usize> Eq for Dense<DS, D>

Source§

impl<DS, const D: usize> StructuralPartialEq for Dense<DS, D>

Auto Trait Implementations§

§

impl<DS, const D: usize> Freeze for Dense<DS, D>
where DS: Freeze,

§

impl<DS, const D: usize> RefUnwindSafe for Dense<DS, D>
where DS: RefUnwindSafe,

§

impl<DS, const D: usize> Send for Dense<DS, D>
where DS: Send,

§

impl<DS, const D: usize> Sync for Dense<DS, D>
where DS: Sync,

§

impl<DS, const D: usize> Unpin for Dense<DS, D>
where DS: Unpin,

§

impl<DS, const D: usize> UnwindSafe for Dense<DS, D>
where DS: 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, 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> 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,