orx_v

Struct FunVec

Source
pub struct FunVec<D, T, F, C = UnboundedCard<D>>
where D: Dim, F: Fn(D::Idx) -> T, C: Card<D>,
{ /* private fields */ }
Expand description

A functional vector of dimension D and cardinality C having T scalar elements.

So much generics, but the important bit is:

  • any FunVec<D, T, F, C> implements NVec<D, T>

hence,

  • any FunVec<D1, T, F, C> implements V1<T>,
  • any FunVec<D2, T, F, C> implements V2<T>,
  • and so on.

Examples will hopefully clarify.

§Examples

use orx_v::*;
use std::collections::HashMap;

#[derive(Clone, Copy)]
struct Geocode(i32, i32);

fn compute_using_coordinates<V: V1<Geocode>>(geocodes: V) { /* todo */ }

// we can pass a Vec of coordinates
compute_using_coordinates(&vec![Geocode(0, 0), Geocode(1, 1)]);

// or we can pass a functional vector
let geocodes = V.d1().fun(|[i]| Geocode(i as i32, i as i32));
compute_using_coordinates(geocodes);

// also see sparse (V.d1().sparse(Geocode(0, 0)))
let known_geocodes: HashMap<usize, Geocode> = [(3, Geocode(1, 1)), (7, Geocode(2, 1))].into_iter().collect();
let geocodes = V.d1().fun(|[i]| match known_geocodes.get(&i) {
    Some(geo) => *geo,
    None => Geocode(0, 0),
});
compute_using_coordinates(geocodes);

// the functional vectors are unbounded on construction
assert!(geocodes.is_unbounded());
assert_eq!(geocodes.card([]), usize::MAX);

The function of the functional geocodes vector can be anything that can compute a geocode based on its index. This is exactly the same in higher dimensional vectors.

If we break down all generic parameters:

  • D = D1 since it is a 1-dimensional vector,
  • T = Geocode which is the scalar that the vector returns,
  • F is any function implementing Fn([usize; 1]) -> T, we can never type its name,
  • C = UnboundedCard<D1>.

You might guess that, all functional vectors in the above examples are capable of computing a geocode for any given index. Their domains are unbounded; hence, the generic cardinality parameter is C = UnboundedCard<D1>. This makes sense at one hand; however, having a bounded domain is often more practical on the other hand. We can introduce bounds to the domain of the functional vector by using:

  • bounded if the vector is of dimension D1,
  • with_rectangular_bounds or with_variable_bounds otherwise.

Implementations§

Source§

impl<T, F> FunVec<D1, T, F, UnboundedCard<D1>>
where F: Fn(<D1 as Dim>::Idx) -> T,

Source

pub fn bounded(self, num_elements: usize) -> FunVec<D1, T, F, CardD1>

Converts an unbounded functional vector into one with a provided bound.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With bounded method, domain of the vector is defined.

§Examples
use orx_v::*;

// [0, 10, 20, 30]
let v1 = V.d1().fun(|[i]| 10 * i as i32).bounded(4);

assert_eq!(v1.card([]), 4);
assert_eq!(v1.all().collect::<Vec<_>>(), vec![0, 10, 20, 30]);
assert_eq!(v1.equality(&[0, 10, 20, 30]), Equality::Equal);
assert_eq!(v1.all().sum::<i32>(), 60);

assert_eq!(v1.in_bounds([7]), false);
assert_eq!(v1.try_at([7]), None);
assert_eq!(v1.at([7]), 70); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source§

impl<T, F> FunVec<D2, T, F, UnboundedCard<D2>>
where F: Fn(<D2 as Dim>::Idx) -> T,

Source

pub fn with_rectangular_bounds( self, dimensions: [usize; 2], ) -> FunVec<D2, T, F, RectangularCardD2>

Converts an unbounded functional vector into one with rectangular bounds as in matrices:

  • the vector has dimensions[0] children, and
  • each children has dimensions[1] elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// 2x3 => [ [0, 1, 2], [100, 101, 102] ]
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_rectangular_bounds([2, 3]);

assert_eq!(v2.card([]), 2);
assert_eq!(v2.card([0]), 3);
assert_eq!(v2.card([1]), 3);

assert_eq!(v2.at([1, 2]), 102);

assert_eq!(v2.all().collect::<Vec<_>>(), vec![0, 1, 2, 100, 101, 102]);

let row1 = v2.child(1);
assert_eq!(row1.card([]), 3);
assert_eq!(row1.at([0]), 100);
assert_eq!(row1.all().collect::<Vec<_>>(), vec![100, 101, 102]);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source

pub fn with_variable_bounds<C>( self, cardinality: C, ) -> FunVec<D2, T, F, VariableCardD2<C>>
where C: V1<usize>,

Converts an unbounded functional vector into one with variable bounds as in jagged arrays:

  • the vector has cardinality.card([]) children, and
  • i-th child has cardinality.at([i]) elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// jagged => [ [0, 1], [100, 101, 102], [200] ]
let num_cols = vec![2, 3, 1];
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 3);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 1);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200]]),
    Equality::Equal,
);

// jagged => [ [0, 1], [100, 101, 102], [200, 201], [300, 301, 302] ]
let num_cols = V.d1().fun(|[i]| match i % 2 == 0 {
    true => 2,
    false => 3,
}).bounded(4);
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 4);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 2);
assert_eq!(v2.card([3]), 3);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200, 201], vec![300, 301, 302]]),
    Equality::Equal,
);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source§

impl<T, F> FunVec<D3, T, F, UnboundedCard<D3>>
where F: Fn(<D3 as Dim>::Idx) -> T,

Source

pub fn with_rectangular_bounds( self, dimensions: [usize; 3], ) -> FunVec<D3, T, F, RectangularCardD3>

Converts an unbounded functional vector into one with rectangular bounds as in multi-dimensional matrices. The matrix has dimensions[0] x dimensions[1] x dimensions[2] elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// 2x3 => [ [0, 1, 2], [100, 101, 102] ]
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_rectangular_bounds([2, 3]);

assert_eq!(v2.card([]), 2);
assert_eq!(v2.card([0]), 3);
assert_eq!(v2.card([1]), 3);

assert_eq!(v2.at([1, 2]), 102);

assert_eq!(v2.all().collect::<Vec<_>>(), vec![0, 1, 2, 100, 101, 102]);

let row1 = v2.child(1);
assert_eq!(row1.card([]), 3);
assert_eq!(row1.at([0]), 100);
assert_eq!(row1.all().collect::<Vec<_>>(), vec![100, 101, 102]);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source

pub fn with_variable_bounds<C>( self, cardinality: C, ) -> FunVec<D3, T, F, VariableCardD3<C>>
where C: V2<usize>,

Converts an unbounded functional vector into one with variable bounds as in jagged arrays:

  • the vector has cardinality.card([]) children, and
  • i-th child has cardinality.card([i]) children, and
  • j-th child of the i-th child has cardinality.at([i, j]) elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// jagged => [ [0, 1], [100, 101, 102], [200] ]
let num_cols = vec![2, 3, 1];
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 3);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 1);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200]]),
    Equality::Equal,
);

// jagged => [ [0, 1], [100, 101, 102], [200, 201], [300, 301, 302] ]
let num_cols = V.d1().fun(|[i]| match i % 2 == 0 {
    true => 2,
    false => 3,
}).bounded(4);
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 4);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 2);
assert_eq!(v2.card([3]), 3);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200, 201], vec![300, 301, 302]]),
    Equality::Equal,
);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source§

impl<T, F> FunVec<D4, T, F, UnboundedCard<D4>>
where F: Fn(<D4 as Dim>::Idx) -> T,

Source

pub fn with_rectangular_bounds( self, dimensions: [usize; 4], ) -> FunVec<D4, T, F, RectangularCardD4>

Converts an unbounded functional vector into one with rectangular bounds as in multi-dimensional matrices. The matrix has dimensions[0] x dimensions[1] x dimensions[2] x dimensions[3] elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// 2x3 => [ [0, 1, 2], [100, 101, 102] ]
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_rectangular_bounds([2, 3]);

assert_eq!(v2.card([]), 2);
assert_eq!(v2.card([0]), 3);
assert_eq!(v2.card([1]), 3);

assert_eq!(v2.at([1, 2]), 102);

assert_eq!(v2.all().collect::<Vec<_>>(), vec![0, 1, 2, 100, 101, 102]);

let row1 = v2.child(1);
assert_eq!(row1.card([]), 3);
assert_eq!(row1.at([0]), 100);
assert_eq!(row1.all().collect::<Vec<_>>(), vec![100, 101, 102]);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Source

pub fn with_variable_bounds<C>( self, cardinality: C, ) -> FunVec<D4, T, F, VariableCardD4<C>>
where C: V3<usize>,

Converts an unbounded functional vector into one with variable bounds as in jagged arrays:

  • the vector has cardinality.card([]) children, and
  • i-th child has cardinality.card([i]) children, and
  • j-th child of the i-th child has cardinality.card([i, j]) children, and
  • k-th child of the [i,j]-th child has cardinality.at([i, j, k]) elements.

Note that in practice, unbounded cardinality corresponds to a length of usize::MAX. One needs to be careful in using the all method which would iterate over the entire 0..usize::MAX range unless it is stopped on a condition such as in find method or limited by methods such as take.

With with_rectangular_bounds or with_variable_bounds methods, domain of the vector is defined.

§Examples
use orx_v::*;

// jagged => [ [0, 1], [100, 101, 102], [200] ]
let num_cols = vec![2, 3, 1];
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 3);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 1);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200]]),
    Equality::Equal,
);

// jagged => [ [0, 1], [100, 101, 102], [200, 201], [300, 301, 302] ]
let num_cols = V.d1().fun(|[i]| match i % 2 == 0 {
    true => 2,
    false => 3,
}).bounded(4);
let v2 = V.d2().fun(|[i, j]| (100 * i + j) as i64).with_variable_bounds(num_cols);

assert_eq!(v2.card([]), 4);
assert_eq!(v2.card([0]), 2);
assert_eq!(v2.card([1]), 3);
assert_eq!(v2.card([2]), 2);
assert_eq!(v2.card([3]), 3);

assert_eq!(v2.at([0, 1]), 1);
assert_eq!(v2.at([1, 2]), 102);

assert_eq!(
    v2.equality(&[vec![0, 1], vec![100, 101, 102], vec![200, 201], vec![300, 301, 302]]),
    Equality::Equal,
);

assert_eq!(v2.in_bounds([100, 72]), false);
assert_eq!(v2.try_at([100, 72]), None);
assert_eq!(v2.at([100, 72]), 100 * 100 + 72); // (!) un-compromised performance

(!) un-compromised performance

Main reason to add bounds to a sparse vector is to set its domain. However, calling at with an out-of-bounds index can still produce a valid element in order not to compromise performance. If we want to check whether or not an index is in bounds or not, we can use the in_bounds or card methods, or use try_at instead which would return None if the index is out of bounds.

Trait Implementations§

Source§

impl<D, T, F, C> Clone for FunVec<D, T, F, C>
where D: Dim, F: Fn(D::Idx) -> T + Clone, C: Card<D> + Clone,

Source§

fn clone(&self) -> Self

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<T, F, C> Debug for FunVec<D1, T, F, C>
where F: Fn(<D1 as Dim>::Idx) -> T, C: Card<D1>, T: Debug, Self: NVec<D1, T>,

Source§

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

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

impl<T, F, C> Debug for FunVec<D2, T, F, C>
where F: Fn(<D2 as Dim>::Idx) -> T, C: Card<D2>, T: Debug, Self: NVec<D2, T>,

Source§

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

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

impl<T, F, C> Debug for FunVec<D3, T, F, C>
where F: Fn(<D3 as Dim>::Idx) -> T, C: Card<D3>, T: Debug, Self: NVec<D3, T>,

Source§

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

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

impl<T, F, C> Debug for FunVec<D4, T, F, C>
where F: Fn(<D4 as Dim>::Idx) -> T, C: Card<D4>, T: Debug, Self: NVec<D4, T>,

Source§

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

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

impl<D, T, F, C> IntoCached<D, T> for FunVec<D, T, F, C>
where D: Dim, F: Fn(D::Idx) -> T, C: Card<D>, T: Copy, D::Idx: Ord + Hash, Self: NVec<D, T>,

Source§

fn into_cached(self) -> CachedVec<D, T, Self, DefaultCache<D, T>>

Converts an NVec<D, T> into a cached vector which maintains an internal cache. Read more
Source§

fn into_cached_with<C: Cache<D::Idx, T>>( self, cache: C, ) -> CachedVec<D, T, Self, C>

Converts an NVec<D, T> into a cached vector which maintains an internal cache. Read more
Source§

impl<D, T, F, C> NVec<D, T> for FunVec<D, T, F, C>
where D: Dim, F: Fn(<D as Dim>::Idx) -> T, C: Card<D>,

Source§

fn at(&self, idx: impl IntoIdx<D>) -> T

Returns the element at the idx-th position of the vector. Read more
Source§

fn child(&self, i: <D as Dim>::ChildIdx) -> impl NVec<<D as Dim>::PrevDim, T>

Returns the i-th child of the vector. Read more
Source§

fn all(&self) -> impl Iterator<Item = T>

Returns a flattened iterator over all scalar (D0) elements of the vector. Read more
Source§

fn num_children(&self) -> usize

Returns the number of children of the vector; i.e., number of elements of the one lower dimension. Read more
Source§

fn card(&self, idx: impl Into<D::CardIdx>) -> usize

Returns the cardinality of the vec in any of the lower dimensions. Read more
Source§

fn is_bounded(&self) -> bool

Returns whether or not the vector is bounded. Read more
Source§

fn is_rectangular(&self) -> bool

Returns whether or not the cardinalities of the vector are rectangular. A rectangular vector of dimension D has the same number of children at a given lower dimension for all indices. Read more
Source§

fn is_unbounded(&self) -> bool

Returns whether or not the vector is unbounded. Read more
Source§

fn in_bounds(&self, idx: impl Into<D::LeqIdx>) -> bool

Returns whether or not the given idx is in bounds. Read more
Source§

fn card_equality(&self, other: &impl NVec<D, T>) -> CardEquality<D>

Returns the cardinality equality of this vec with the other: Read more
Source§

fn try_at(&self, idx: impl IntoIdx<D>) -> Option<T>

Returns the element at the idx-th position of the vector if the index is in_bounds; returns None otherwise. Read more
Source§

fn equality(&self, other: &impl NVec<D, T>) -> Equality<D>
where T: PartialEq,

Returns the equality of this vec with the other: Read more
Source§

fn children(&self) -> impl Iterator<Item = impl NVec<D::PrevDim, T>>

Returns an iterator of all children of the vector. Read more
Source§

fn all_in( &self, indices: impl Iterator<Item = impl IntoIdx<D>>, ) -> impl Iterator<Item = T>

Returns an iterator of elements for the given indices. Read more
Source§

impl<D, T: Copy, F, C> Copy for FunVec<D, T, F, C>
where D: Dim + Copy, F: Fn(D::Idx) -> T + Copy, C: Card<D> + Copy,

Auto Trait Implementations§

§

impl<D, T, F, C> Freeze for FunVec<D, T, F, C>
where F: Freeze, C: Freeze,

§

impl<D, T, F, C> RefUnwindSafe for FunVec<D, T, F, C>

§

impl<D, T, F, C> Send for FunVec<D, T, F, C>
where F: Send, C: Send, D: Send, T: Send,

§

impl<D, T, F, C> Sync for FunVec<D, T, F, C>
where F: Sync, C: Sync, D: Sync, T: Sync,

§

impl<D, T, F, C> Unpin for FunVec<D, T, F, C>
where F: Unpin, C: Unpin, D: Unpin, T: Unpin,

§

impl<D, T, F, C> UnwindSafe for FunVec<D, T, F, C>

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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, V> IntoJagged<T> for V
where V: NVec<D1, T>,

Source§

fn into_jagged<I>(self, row_end_indices: I) -> FlatJagged<Self, I, T>
where I: NVec<D1, usize>,

Converts a D1 vector into a jagged D2 vector where each row is identified by row_end_indices. Read more
Source§

fn as_jagged<I>(&self, row_end_indices: I) -> FlatJagged<&Self, I, T>
where I: NVec<D1, usize>,

From a flat D1 vector, creates a jagged D2 vector view where each row is identified by row_end_indices. Read more
Source§

fn as_jagged_mut<I>( &mut self, row_end_indices: I, ) -> FlatJagged<&mut Self, I, T>
where I: NVec<D1, usize>,

From a flat D1 vector, creates a mutable jagged D2 vector view where each row is identified by row_end_indices. Read more
Source§

fn into_jagged_from_row_lengths<I>( self, row_lengths: &I, ) -> FlatJagged<Self, Vec<usize>, T>
where I: NVec<D1, usize>,

Converts a D1 vector into a jagged D2 vector where each row is identified by row_lengths. Read more
Source§

fn as_jagged_from_row_lengths<I>( &self, row_lengths: &I, ) -> FlatJagged<&Self, Vec<usize>, T>
where I: NVec<D1, usize>,

From a flat D1 vector, creates a jagged D2 vector view where each row is identified by row_lengths. Read more
Source§

fn as_jagged_mut_from_row_lengths<I>( &mut self, row_lengths: &I, ) -> FlatJagged<&mut Self, Vec<usize>, T>
where I: NVec<D1, usize>,

From a flat D1 vector, creates a mutable jagged D2 vector view where each row is identified by row_lengths. Read more
Source§

fn into_jagged_with_uniform_lengths( self, uniform_length: usize, ) -> FlatJagged<Self, UniformEndIndices, T>

Converts a D1 vector into a jagged D2 vector where each row has the given uniform_length, except that the last row might have fewer elements if the cardinality of the D1 vector is not divisible by the uniform length. Read more
Source§

fn as_jagged_with_uniform_lengths( &self, uniform_length: usize, ) -> FlatJagged<&Self, UniformEndIndices, T>

From a flat D1 vector, creates a jagged D2 vector view where each row has the given uniform_length, except that the last row might have fewer elements if the cardinality of the D1 vector is not divisible by the uniform length. Read more
Source§

fn as_jagged_mut_with_uniform_lengths( &mut self, uniform_length: usize, ) -> FlatJagged<&mut Self, UniformEndIndices, T>

From a flat D1 vector, creates a mutable jagged D2 vector view where each row has the given uniform_length, except that the last row might have fewer elements if the cardinality of the D1 vector is not divisible by the uniform length. 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, V> V1AsMatrix<T> for V
where V: NVec<D1, T>,

Source§

fn v1_into_matrix( self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, Self, V1LayoutRowMajor>
where Self: NVec<D1, T>,

Converts the flat D1 vector into a row-major matrix. Read more
Source§

fn v1_as_matrix( &self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, &Self, V1LayoutRowMajor>
where Self: NVec<D1, T>,

Creates a row-major matrix view over the flat D1 vector. Read more
Source§

fn v1_as_matrix_mut( &mut self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, &mut Self, V1LayoutRowMajor>
where Self: NVecMut<D1, T>,

Creates a mutable row-major matrix view over the flat D1 vector. Read more
Source§

fn v1_into_matrix_col_major( self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, Self, V1LayoutColMajor>
where Self: NVec<D1, T>,

Converts the flat D1 vector into a column-major matrix. Read more
Source§

fn v1_as_matrix_col_major( &self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, &Self, V1LayoutColMajor>
where Self: NVec<D1, T>,

Creates a column-major matrix view over the flat D1 vector. Read more
Source§

fn v1_as_matrix_col_major_mut( &mut self, num_rows: usize, num_cols: usize, ) -> V1Matrix<T, &mut Self, V1LayoutColMajor>
where Self: NVecMut<D1, T>,

Creates a mutable column-major matrix view over the flat D1 vector. Read more
Source§

impl<T, V> V2AsMatrix<T> for V
where V: NVec<D2, T>,

Source§

fn into_matrix(self) -> V2MatrixRowMajor<T, Self>
where Self: NVec<D2, T>,

Converts the rectangular D2 vector into a row-major matrix. Read more
Source§

fn as_matrix(&self) -> V2MatrixRowMajor<T, &Self>
where Self: NVec<D2, T>,

Creates a row-major matrix view over the rectangular D2 vector. Read more
Source§

fn as_matrix_mut(&mut self) -> V2MatrixRowMajor<T, &mut Self>
where Self: NVecMut<D2, T>,

Creates a mutable row-major matrix view over the rectangular D2 vector. Read more
Source§

fn into_matrix_col_major(self) -> V2MatrixColMajor<T, Self>
where Self: NVec<D2, T>,

Converts the rectangular D2 vector into a column-major matrix. Read more
Source§

fn as_matrix_col_major(&self) -> V2MatrixColMajor<T, &Self>
where Self: NVec<D2, T>,

Creates a column-major matrix view over the rectangular D2 vector. Read more
Source§

fn as_matrix_col_major_mut(&mut self) -> V2MatrixColMajor<T, &mut Self>
where Self: NVecMut<D2, T>,

Creates a mutable column-major matrix view over the rectangular D2 vector. Read more
Source§

impl<D, V, T> NVecCore<D, T> for V
where D: Dim, V: NVecCoreSealed<D, T>,

Source§

impl<T, N> V1<T> for N
where N: NVec<D1, T>,

Source§

impl<T, N> V2<T> for N
where N: NVec<D2, T>,

Source§

impl<T, N> V3<T> for N
where N: NVec<D3, T>,

Source§

impl<T, N> V4<T> for N
where N: NVec<D4, T>,