Struct nalgebra::sparse::CsMatrix

source ·
pub struct CsMatrix<T: Scalar, R: Dim = Dyn, C: Dim = Dyn, S: CsStorage<T, R, C> = CsVecStorage<T, R, C>> { /* private fields */ }
Expand description

A compressed sparse column matrix.

Implementations§

source§

impl<T: Scalar, R: Dim, C: Dim> CsMatrix<T, R, C>

source

pub fn new_uninitialized_generic(nrows: R, ncols: C, nvals: usize) -> Self

Creates a new compressed sparse column matrix with the specified dimension and nvals possible non-zero values.

source§

impl<T: Scalar, R: Dim, C: Dim, S: CsStorage<T, R, C>> CsMatrix<T, R, C, S>

source

pub fn len(&self) -> usize

The size of the data buffer.

source

pub fn nrows(&self) -> usize

The number of rows of this matrix.

source

pub fn ncols(&self) -> usize

The number of rows of this matrix.

source

pub fn shape(&self) -> (usize, usize)

The shape of this matrix.

source

pub fn is_square(&self) -> bool

Whether this matrix is square or not.

source

pub fn is_sorted(&self) -> bool

Should always return true.

This method is generally used for debugging and should typically not be called in user code. This checks that the row inner indices of this matrix are sorted. It takes O(n) time, where nisself.len(). All operations of CSC matrices on nalgebra assume, and will return, sorted indices. If at any time this is_sortedmethod returnsfalse`, then, something went wrong and an issue should be open on the nalgebra repository with details on how to reproduce this.

source

pub fn transpose(&self) -> CsMatrix<T, C, R>

Computes the transpose of this sparse matrix.

source§

impl<T: Scalar, R: Dim, C: Dim, S: CsStorageMut<T, R, C>> CsMatrix<T, R, C, S>

source

pub fn values_mut(&mut self) -> impl Iterator<Item = &mut T>

Iterator through all the mutable values of this sparse matrix.

source§

impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix<T>

source

pub fn from_triplet( nrows: usize, ncols: usize, irows: &[usize], icols: &[usize], vals: &[T] ) -> Self

Creates a column-compressed sparse matrix from a sparse matrix in triplet form.

source§

impl<'a, T: Scalar + Zero + ClosedAdd, R: Dim, C: Dim> CsMatrix<T, R, C>

source

pub fn from_triplet_generic( nrows: R, ncols: C, irows: &[usize], icols: &[usize], vals: &[T] ) -> Self

Creates a column-compressed sparse matrix from a sparse matrix in triplet form.

source§

impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S>

source

pub fn solve_lower_triangular<R2: Dim, C2: Dim, S2>( &self, b: &Matrix<T, R2, C2, S2> ) -> Option<OMatrix<T, R2, C2>>
where S2: Storage<T, R2, C2>, DefaultAllocator: Allocator<T, R2, C2>, ShapeConstraint: SameNumberOfRows<D, R2>,

Solve a lower-triangular system with a dense right-hand-side.

source

pub fn tr_solve_lower_triangular<R2: Dim, C2: Dim, S2>( &self, b: &Matrix<T, R2, C2, S2> ) -> Option<OMatrix<T, R2, C2>>
where S2: Storage<T, R2, C2>, DefaultAllocator: Allocator<T, R2, C2>, ShapeConstraint: SameNumberOfRows<D, R2>,

Solve a lower-triangular system with self transposed and a dense right-hand-side.

source

pub fn solve_lower_triangular_mut<R2: Dim, C2: Dim, S2>( &self, b: &mut Matrix<T, R2, C2, S2> ) -> bool
where S2: StorageMut<T, R2, C2>, ShapeConstraint: SameNumberOfRows<D, R2>,

Solve in-place a lower-triangular system with a dense right-hand-side.

source

pub fn tr_solve_lower_triangular_mut<R2: Dim, C2: Dim, S2>( &self, b: &mut Matrix<T, R2, C2, S2> ) -> bool
where S2: StorageMut<T, R2, C2>, ShapeConstraint: SameNumberOfRows<D, R2>,

Solve a lower-triangular system with self transposed and a dense right-hand-side.

source

pub fn solve_lower_triangular_cs<D2: Dim, S2>( &self, b: &CsVector<T, D2, S2> ) -> Option<CsVector<T, D2>>

Solve a lower-triangular system with a sparse right-hand-side.

Trait Implementations§

source§

impl<'a, 'b, T, R1, R2, C1, C2, S1, S2> Add<&'b CsMatrix<T, R2, C2, S2>> for &'a CsMatrix<T, R1, C1, S1>
where T: Scalar + ClosedAdd + ClosedMul + Zero + One, R1: Dim, C1: Dim, R2: Dim, C2: Dim, S1: CsStorage<T, R1, C1>, S2: CsStorage<T, R2, C2>, ShapeConstraint: DimEq<R1, R2> + DimEq<C1, C2>, DefaultAllocator: Allocator<usize, C2> + Allocator<usize, R1> + Allocator<T, R1>,

§

type Output = CsMatrix<T, R1, C2>

The resulting type after applying the + operator.
source§

fn add(self, rhs: &'b CsMatrix<T, R2, C2, S2>) -> Self::Output

Performs the + operation. Read more
source§

impl<T: Clone + Scalar, R: Clone + Dim, C: Clone + Dim, S: Clone + CsStorage<T, R, C>> Clone for CsMatrix<T, R, C, S>

source§

fn clone(&self) -> CsMatrix<T, R, C, S>

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 + Scalar, R: Debug + Dim, C: Debug + Dim, S: Debug + CsStorage<T, R, C>> Debug for CsMatrix<T, R, C, S>

source§

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

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

impl<'a, T: Scalar + Zero, R: Dim, C: Dim, S> From<CsMatrix<T, R, C, S>> for OMatrix<T, R, C>
where S: CsStorage<T, R, C>, DefaultAllocator: Allocator<T, R, C>,

source§

fn from(m: CsMatrix<T, R, C, S>) -> Self

Converts to this type from the input type.
source§

impl<'a, T: Scalar + Zero, R: Dim, C: Dim, S> From<Matrix<T, R, C, S>> for CsMatrix<T, R, C>
where S: Storage<T, R, C>, DefaultAllocator: Allocator<T, R, C> + Allocator<usize, C>,

source§

fn from(m: Matrix<T, R, C, S>) -> Self

Converts to this type from the input type.
source§

impl<'a, 'b, T, R1, R2, C1, C2, S1, S2> Mul<&'b CsMatrix<T, R2, C2, S2>> for &'a CsMatrix<T, R1, C1, S1>
where T: Scalar + ClosedAdd + ClosedMul + Zero, R1: Dim, C1: Dim, R2: Dim, C2: Dim, S1: CsStorage<T, R1, C1>, S2: CsStorage<T, R2, C2>, ShapeConstraint: AreMultipliable<R1, C1, R2, C2>, DefaultAllocator: Allocator<usize, C2> + Allocator<usize, R1> + Allocator<T, R1>,

§

type Output = CsMatrix<T, R1, C2>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &'b CsMatrix<T, R2, C2, S2>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, 'b, T, R, C, S> Mul<T> for CsMatrix<T, R, C, S>
where T: Scalar + ClosedAdd + ClosedMul + Zero, R: Dim, C: Dim, S: CsStorageMut<T, R, C>,

§

type Output = CsMatrix<T, R, C, S>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
source§

impl<T: PartialEq + Scalar, R: PartialEq + Dim, C: PartialEq + Dim, S: PartialEq + CsStorage<T, R, C>> PartialEq for CsMatrix<T, R, C, S>

source§

fn eq(&self, other: &CsMatrix<T, R, C, S>) -> 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: Scalar, R: Dim, C: Dim, S: CsStorage<T, R, C>> StructuralPartialEq for CsMatrix<T, R, C, S>

Auto Trait Implementations§

§

impl<T, R, C, S> Freeze for CsMatrix<T, R, C, S>
where S: Freeze,

§

impl<T, R, C, S> RefUnwindSafe for CsMatrix<T, R, C, S>

§

impl<T, R, C, S> Send for CsMatrix<T, R, C, S>
where S: Send, T: Send,

§

impl<T, R, C, S> Sync for CsMatrix<T, R, C, S>
where S: Sync, T: Sync,

§

impl<T, R, C, S> Unpin for CsMatrix<T, R, C, S>
where C: Unpin, R: Unpin, S: Unpin, T: Unpin,

§

impl<T, R, C, S> UnwindSafe for CsMatrix<T, R, C, S>

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> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,