Struct npyz::sparse::BsrBase

source ·
pub struct BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]>, Indices: AsRef<[u64]>, Indptr: AsRef<[usize]>,
{ pub shape: [u64; 2], pub blocksize: [usize; 2], pub data: Data, pub indices: Indices, pub indptr: Indptr, }
Expand description

Raw representation of a scipy.sparse.bsr_matrix.

In spirit, each field is simply a Vec. (see the type alias Bsr). This generic base class exists in order to allow you to use slices when writing.

Fields§

§shape: [u64; 2]

Dimensions of the matrix [nrow, ncol].

These dimensions must be divisible by the respective elements of blocksize.

§blocksize: [usize; 2]

Size of the blocks in the matrix.

§data: Data

Contains the C-order data of a shape [nnzb, block_nrow, block_ncol] ndarray.

(effectively concatenating the flattened data of all nonzero blocks, sorted by superrow)

§indices: Indices

A vector of length nnzb indicating the supercolumn index of each block.

Beware: scipy does not require or guarantee that the column indices within each row are sorted.

§indptr: Indptr

A vector of length (nrow / block_nrow) + 1 indicating the indices which partition Self::indices and the outermost axis of Self::data into data for each superrow.

Typically, the elements are nondecreasing, with the first equal to 0 and the final equal to nnzb (though the set of requirements that are actually validated by scipy are weaker and somewhat arbitrary).

Implementations§

source§

impl<T: Deserialize> BsrBase<T, Vec<T>, Vec<u64>, Vec<usize>>

source

pub fn from_npz<R: Read + Seek>(npz: &mut NpzArchive<R>) -> Result<Self>

Read a sparse bsr_matrix saved by scipy.sparse.save_npz.

source§

impl<T, Data, Indices, Indptr> BsrBase<T, Data, Indices, Indptr>
where T: AutoSerialize, Data: Deref<Target = [T]>, Indices: AsRef<[u64]>, Indptr: AsRef<[usize]>,

source

pub fn write_npz<W: Write + Seek>(&self, npz: &mut NpzWriter<W>) -> Result<()>

Write a sparse bsr_matrix matrix, like scipy.sparse.save_npz.

Panics

Panics if data.len() is not equal to indices.len() * blocksize[0] * blocksize[1].

Trait Implementations§

source§

impl<T: Clone, Data, Indices, Indptr> Clone for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]> + Clone, Indices: AsRef<[u64]> + Clone, Indptr: AsRef<[usize]> + Clone,

source§

fn clone(&self) -> BsrBase<T, Data, Indices, Indptr>

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: Debug, Data, Indices, Indptr> Debug for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]> + Debug, Indices: AsRef<[u64]> + Debug, Indptr: AsRef<[usize]> + Debug,

source§

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

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

impl<T: PartialEq, Data, Indices, Indptr> PartialEq for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]> + PartialEq, Indices: AsRef<[u64]> + PartialEq, Indptr: AsRef<[usize]> + PartialEq,

source§

fn eq(&self, other: &BsrBase<T, Data, Indices, Indptr>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: Eq, Data, Indices, Indptr> Eq for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]> + Eq, Indices: AsRef<[u64]> + Eq, Indptr: AsRef<[usize]> + Eq,

source§

impl<T, Data, Indices, Indptr> StructuralEq for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]>, Indices: AsRef<[u64]>, Indptr: AsRef<[usize]>,

source§

impl<T, Data, Indices, Indptr> StructuralPartialEq for BsrBase<T, Data, Indices, Indptr>
where Data: Deref<Target = [T]>, Indices: AsRef<[u64]>, Indptr: AsRef<[usize]>,

Auto Trait Implementations§

§

impl<T, Data, Indices, Indptr> RefUnwindSafe for BsrBase<T, Data, Indices, Indptr>
where Data: RefUnwindSafe, Indices: RefUnwindSafe, Indptr: RefUnwindSafe,

§

impl<T, Data, Indices, Indptr> Send for BsrBase<T, Data, Indices, Indptr>
where Data: Send, Indices: Send, Indptr: Send,

§

impl<T, Data, Indices, Indptr> Sync for BsrBase<T, Data, Indices, Indptr>
where Data: Sync, Indices: Sync, Indptr: Sync,

§

impl<T, Data, Indices, Indptr> Unpin for BsrBase<T, Data, Indices, Indptr>
where Data: Unpin, Indices: Unpin, Indptr: Unpin,

§

impl<T, Data, Indices, Indptr> UnwindSafe for BsrBase<T, Data, Indices, Indptr>
where Data: UnwindSafe, Indices: UnwindSafe, Indptr: 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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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.