Struct sprs::IndPtrBase[][src]

pub struct IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
{ /* fields omitted */ }

Implementations

impl<Iptr, Storage> IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

pub fn new_checked(storage: Storage) -> Result<Self, (Storage, StructureError)>[src]

pub fn view(&self) -> IndPtrView<'_, Iptr>[src]

pub fn len(&self) -> usize[src]

The length of the underlying storage

pub fn is_empty(&self) -> bool[src]

Tests whether this indptr is empty

pub fn outer_dims(&self) -> usize[src]

The number of outer dimensions this indptr represents

pub fn is_proper(&self) -> bool[src]

Indicates whether the underlying storage is proper, which means the indptr corresponds to a non-sliced matrix.

An empty matrix is considered non-proper.

pub fn as_slice(&self) -> Option<&[Iptr]>[src]

Return a view on the underlying slice if it is a proper indptr slice, which is the case if its first element is 0. None will be returned otherwise.

pub fn raw_storage(&self) -> &[Iptr]

Notable traits for &'_ mut [u8]

impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
[src]

Return a view of the underlying storage. Should be used with care in sparse algorithms, as this won’t check if the storage corresponds to a proper matrix

pub fn into_raw_storage(self) -> Storage[src]

Consume self and return the underlying storage

pub fn to_owned(&self) -> IndPtr<Iptr>[src]

pub fn to_proper(&self) -> Cow<'_, [Iptr]>[src]

Returns a proper indptr representation, cloning if we do not have a proper indptr.

Warning

For ffi usage, one needs to call Cow::as_ptr, but it’s important to keep the Cow alive during the lifetime of the pointer. Example of a correct and incorrect ffi usage:

let mat: sprs::CsMat<f64> = sprs::CsMat::eye(5);
let mid = mat.view().middle_outer_views(1, 2);
let ptr = {
    let indptr = mid.indptr(); // needed for lifetime
    let indptr_proper = indptr.to_proper();
    println!(
        "ptr {:?} is valid as long as _indptr_proper_owned is in scope",
        indptr_proper.as_ptr()
    );
    indptr_proper.as_ptr()
};
// This line is UB.
// println!("ptr deref: {}", *ptr);

It is much easier to directly use the proper_indptr method of CsMatBase directly:

let mat: sprs::CsMat<f64> = sprs::CsMat::eye(5);
let mid = mat.view().middle_outer_views(1, 2);
let ptr = {
    let indptr_proper = mid.proper_indptr();
    println!(
        "ptr {:?} is valid as long as _indptr_proper_owned is in scope",
        indptr_proper.as_ptr()
    );
    indptr_proper.as_ptr()
};
// This line is UB.
// println!("ptr deref: {}", *ptr);

pub fn iter_outer_nnz_inds(
    &self
) -> impl DoubleEndedIterator<Item = usize> + ExactSizeIterator<Item = usize> + '_
[src]

Iterate over the nonzeros represented by this indptr, yielding the outer dimension for each nonzero

pub fn iter_outer(
    &self
) -> impl DoubleEndedIterator<Item = Range<Iptr>> + ExactSizeIterator<Item = Range<Iptr>> + '_
[src]

Iterate over outer dimensions, yielding start and end indices for each outer dimension.

pub fn iter_outer_sz(
    &self
) -> impl DoubleEndedIterator<Item = Range<usize>> + ExactSizeIterator<Item = Range<usize>> + '_
[src]

Iterate over outer dimensions, yielding start and end indices for each outer dimension.

Returns a range of usize to ensure iteration of indices and data is easy

pub fn index(&self, i: usize) -> Iptr[src]

Return the value of the indptr at index i. This method is intended for low-level usage only, outer_inds should be preferred most of the time

pub fn outer_inds(&self, i: usize) -> Range<Iptr>[src]

Get the start and end indices for the requested outer dimension

Panics

If i >= self.outer_dims()

pub fn outer_inds_sz(&self, i: usize) -> Range<usize>[src]

Get the start and end indices for the requested outer dimension

Returns a range of usize to ensure iteration of indices and data is easy

Panics

If i >= self.outer_dims()

pub fn nnz_in_outer(&self, i: usize) -> Iptr[src]

Get the number of nonzeros in the requested outer dimension

Panics

If i >= self.outer_dims()

pub fn nnz_in_outer_sz(&self, i: usize) -> usize[src]

Get the number of nonzeros in the requested outer dimension

Returns a usize

Panics

If i >= self.outer_dims()

pub fn outer_inds_slice(&self, start: usize, end: usize) -> Range<usize>[src]

Get the start and end indices for the requested outer dimension slice

Panics

If start >= self.outer_dims() || end > self.outer_dims()

pub fn nnz(&self) -> usize[src]

The number of nonzero elements described by this indptr

pub fn nnz_i(&self) -> Iptr[src]

The number of nonzero elements described by this indptr, using the actual storage type

Trait Implementations

impl<Iptr: Clone, Storage: Clone> Clone for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr: Copy, Storage: Copy> Copy for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr: Debug, Storage: Debug> Debug for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<'de, Iptr, Storage> Deserialize<'de> for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>,
    Storage: Deserialize<'de>, 
[src]

impl<Iptr: Eq, Storage: Eq> Eq for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr: Hash, Storage: Hash> Hash for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr: PartialEq, Storage: PartialEq> PartialEq<IndPtrBase<Iptr, Storage>> for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr: SpIndex, IptrStorage, IptrStorage2> PartialEq<IptrStorage2> for IndPtrBase<Iptr, IptrStorage> where
    IptrStorage: Deref<Target = [Iptr]>,
    IptrStorage2: Deref<Target = [Iptr]>, 
[src]

Allows comparison to vectors and slices

impl<Iptr, Storage> Serialize for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>,
    Storage: Serialize
[src]

impl<Iptr, Storage> StructuralEq for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

impl<Iptr, Storage> StructuralPartialEq for IndPtrBase<Iptr, Storage> where
    Iptr: SpIndex,
    Storage: Deref<Target = [Iptr]>, 
[src]

Auto Trait Implementations

impl<Iptr, Storage> RefUnwindSafe for IndPtrBase<Iptr, Storage> where
    Storage: RefUnwindSafe

impl<Iptr, Storage> Send for IndPtrBase<Iptr, Storage> where
    Storage: Send

impl<Iptr, Storage> Sync for IndPtrBase<Iptr, Storage> where
    Storage: Sync

impl<Iptr, Storage> Unpin for IndPtrBase<Iptr, Storage> where
    Storage: Unpin

impl<Iptr, Storage> UnwindSafe for IndPtrBase<Iptr, Storage> where
    Storage: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.