Struct sprs::IndPtrBase [−][src]
Implementations
impl<Iptr, Storage> IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
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]ⓘ
[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]
&self
) -> impl DoubleEndedIterator<Item = usize> + ExactSizeIterator<Item = usize> + '_
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]
&self
) -> impl DoubleEndedIterator<Item = Range<Iptr>> + ExactSizeIterator<Item = Range<Iptr>> + '_
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]
&self
) -> impl DoubleEndedIterator<Item = Range<usize>> + ExactSizeIterator<Item = Range<usize>> + '_
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]
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]
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]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
fn clone(&self) -> IndPtrBase<Iptr, Storage>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Iptr: Copy, Storage: Copy> Copy for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
impl<Iptr: Debug, Storage: Debug> Debug for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
impl<'de, Iptr, Storage> Deserialize<'de> for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
Storage: Deserialize<'de>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
Storage: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<Iptr: Eq, Storage: Eq> Eq for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
impl<Iptr: Hash, Storage: Hash> Hash for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<Iptr: PartialEq, Storage: PartialEq> PartialEq<IndPtrBase<Iptr, Storage>> for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
fn eq(&self, other: &IndPtrBase<Iptr, Storage>) -> bool
[src]
fn ne(&self, other: &IndPtrBase<Iptr, Storage>) -> bool
[src]
impl<Iptr: SpIndex, IptrStorage, IptrStorage2> PartialEq<IptrStorage2> for IndPtrBase<Iptr, IptrStorage> where
IptrStorage: Deref<Target = [Iptr]>,
IptrStorage2: Deref<Target = [Iptr]>,
[src]
IptrStorage: Deref<Target = [Iptr]>,
IptrStorage2: Deref<Target = [Iptr]>,
Allows comparison to vectors and slices
fn eq(&self, other: &IptrStorage2) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Iptr, Storage> Serialize for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
Storage: Serialize,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
Storage: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<Iptr, Storage> StructuralEq for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
impl<Iptr, Storage> StructuralPartialEq for IndPtrBase<Iptr, Storage> where
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
[src]
Iptr: SpIndex,
Storage: Deref<Target = [Iptr]>,
Auto Trait Implementations
impl<Iptr, Storage> RefUnwindSafe for IndPtrBase<Iptr, Storage> where
Storage: RefUnwindSafe,
Storage: RefUnwindSafe,
impl<Iptr, Storage> Send for IndPtrBase<Iptr, Storage> where
Storage: Send,
Storage: Send,
impl<Iptr, Storage> Sync for IndPtrBase<Iptr, Storage> where
Storage: Sync,
Storage: Sync,
impl<Iptr, Storage> Unpin for IndPtrBase<Iptr, Storage> where
Storage: Unpin,
Storage: Unpin,
impl<Iptr, Storage> UnwindSafe for IndPtrBase<Iptr, Storage> where
Storage: UnwindSafe,
Storage: 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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> 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> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
[src]
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
[src]
pub fn is_in_subset(&self) -> bool
[src]
pub unsafe fn to_subset_unchecked(&self) -> SS
[src]
pub fn from_subset(element: &SS) -> SP
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,