[−][src]Struct ndsparse::coo::Coo
Methods
impl<DA, DS> Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
pub fn dims(&self) -> &DA
[src]
The definitions of all dimensions.
Example
use ndsparse::doc_tests::coo_array_5; assert_eq!(coo_array_5().dims(), &[2, 3, 4, 3, 3]);
impl<DA, DATA, DS> Coo<DA, DS> where
DA: Dims,
DS: AsRef<[<DS as Storage>::Item]> + Storage<Item = (ArrayWrapper<DA>, DATA)>,
[src]
DA: Dims,
DS: AsRef<[<DS as Storage>::Item]> + Storage<Item = (ArrayWrapper<DA>, DATA)>,
pub fn new<ID, IDS>(into_dims: ID, into_data: IDS) -> Self where
ID: Into<ArrayWrapper<DA>>,
IDS: Into<DS>,
[src]
ID: Into<ArrayWrapper<DA>>,
IDS: Into<DS>,
Creates a valid COO instance.
Arguments
into_dims
: Array of dimensionsinto_data
: Data collection
Example
use ndsparse::coo::{CooArray, CooVec}; // Sparse array ([8, _, _, _, _, 9, _, _, _, _]) let mut _sparse_array = CooArray::new([10], [([0].into(), 8.0), ([5].into(), 9.0)]); // A bunch of nothing for your overflow needs let mut _over_nine: CooVec<[usize; 9001], ()>; _over_nine = CooVec::new([0; 9001], vec![]);
Assertions
- Data indices must be in asceding order
use ndsparse::coo::CooArray; let _ = CooArray::new([2, 2], [([1, 1].into(), 8), ([0, 0].into(), 9)]);
- All indices must be lesser than the defined dimensions
use ndsparse::coo::CooArray; let _ = CooArray::new([2, 2], [([0, 1].into(), 8), ([9, 9].into(), 9)]);
- Must not have duplicated indices
use ndsparse::coo::CooArray; let _ = CooArray::new([2, 2], [([0, 0].into(), 8), ([0, 0].into(), 9)]);
pub fn data(&self) -> &[(ArrayWrapper<DA>, DATA)]
[src]
The data that is being stored.
Example
use ndsparse::doc_tests::coo_array_5; assert_eq!(coo_array_5().data().get(0), Some(&([0, 0, 1, 1, 2].into(), 1)));
pub fn value(&self, indcs: DA) -> Option<&DATA>
[src]
impl<DA, DATA, DS> Coo<DA, DS> where
DA: Dims,
DS: AsMut<[<DS as Storage>::Item]> + Storage<Item = (ArrayWrapper<DA>, DATA)>,
[src]
DA: Dims,
DS: AsMut<[<DS as Storage>::Item]> + Storage<Item = (ArrayWrapper<DA>, DATA)>,
pub unsafe fn data_mut(&mut self) -> &[(ArrayWrapper<DA>, DATA)]
[src]
pub fn value_mut(&mut self, indcs: DA) -> Option<&mut DATA>
[src]
Mutable version of value
.
impl<DA, DATA, DS> Coo<DA, DS> where
DA: Dims,
DS: AsMut<[<DS as Storage>::Item]> + AsRef<[<DS as Storage>::Item]> + Default + Storage<Item = (ArrayWrapper<DA>, DATA)> + Push<Input = <DS as Storage>::Item>,
[src]
DA: Dims,
DS: AsMut<[<DS as Storage>::Item]> + AsRef<[<DS as Storage>::Item]> + Default + Storage<Item = (ArrayWrapper<DA>, DATA)> + Push<Input = <DS as Storage>::Item>,
pub fn new_random_with_rand<F, ID, R>(
into_dims: ID,
nnz: usize,
rng: &mut R,
cb: F
) -> Self where
F: FnMut(&mut R, &DA) -> DATA,
ID: Into<ArrayWrapper<DA>>,
R: Rng,
[src]
into_dims: ID,
nnz: usize,
rng: &mut R,
cb: F
) -> Self where
F: FnMut(&mut R, &DA) -> DATA,
ID: Into<ArrayWrapper<DA>>,
R: Rng,
Creates a new random and valid instance delimited by the passed arguments.
Arguments
into_dims
: Array of dimensionsnnz
: Number of Non-Zero elementsrng
:rand::Rng
traitcb
: Callback to control data creation
Example
use ndsparse::coo::CooVec; use rand::{thread_rng, Rng}; let mut _random: CooVec<[usize; 8], u8>; let mut rng = thread_rng(); _random = CooVec::new_random_with_rand([1, 2, 3, 4, 5, 6, 7, 8], 9, &mut rng, |r, _| r.gen());
Trait Implementations
impl<DA: Clone, DS: Clone> Clone for Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
impl<DA: Debug, DS: Debug> Debug for Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
impl<DA: Default, DS: Default> Default for Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
impl<'de, DA, DS> Deserialize<'de> for Coo<DA, DS> where
DA: Dims,
DA: Deserialize<'de>,
DS: Deserialize<'de>,
[src]
DA: Dims,
DA: Deserialize<'de>,
DS: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<DA: PartialEq, DS: PartialEq> PartialEq<Coo<DA, DS>> for Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
impl<DA, DS> Serialize for Coo<DA, DS> where
DA: Dims,
DA: Serialize,
DS: Serialize,
[src]
DA: Dims,
DA: Serialize,
DS: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<DA, DS> StructuralPartialEq for Coo<DA, DS> where
DA: Dims,
[src]
DA: Dims,
Auto Trait Implementations
impl<DA, DS> RefUnwindSafe for Coo<DA, DS> where
DA: RefUnwindSafe,
DS: RefUnwindSafe,
DA: RefUnwindSafe,
DS: RefUnwindSafe,
impl<DA, DS> Send for Coo<DA, DS> where
DA: Send,
DS: Send,
DA: Send,
DS: Send,
impl<DA, DS> Sync for Coo<DA, DS> where
DA: Sync,
DS: Sync,
DA: Sync,
DS: Sync,
impl<DA, DS> Unpin for Coo<DA, DS> where
DA: Unpin,
DS: Unpin,
DA: Unpin,
DS: Unpin,
impl<DA, DS> UnwindSafe for Coo<DA, DS> where
DA: UnwindSafe,
DS: UnwindSafe,
DA: UnwindSafe,
DS: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,