SparseMatrix

Struct SparseMatrix 

Source
pub struct SparseMatrix<'a, T>{
    pub data: SparseMatrixData<'a, T>,
    pub nrows: usize,
    pub ncols: usize,
    /* private fields */
}
Expand description

Represents a sparse matrix and its data

Fields§

§data: SparseMatrixData<'a, T>

Vector containing all data

§nrows: usize

Number of rows

§ncols: usize

Number of columns

Implementations§

Source§

impl<'a, T> SparseMatrix<'a, T>

Source

pub fn new(data: SparseMatrixData<'a, T>, shape: Shape) -> Self

Constructs a new sparse matrix based on a hashmap containing the indices where value is not 0

This function does not check whether or not the indices are valid and according to shape. Use reshape to fix this issue.

Examples

use std::collections::HashMap;
use sukker::{smd, SparseMatrix, SparseMatrixData};

// Here we can use the smd! macro
// to easily be able to set up a new hashmap
let indexes: SparseMatrixData<f64> = smd![
    ( (0, 0), 2.0),
    ( (0, 3), 4.0),
    ( (4, 5), 6.0),
    ( (2, 7), 8.0)
];

let sparse = SparseMatrix::<f64>::new(indexes, (3,3));

assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.get(4,5), None);
assert_eq!(sparse.get(0,1), Some(0.0));
Source

pub fn init(nrows: usize, ncols: usize) -> Self

Inits an empty matrix based on shape

Source

pub fn eye(size: usize) -> Self

Returns a sparse eye matrix

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.ncols, 3);
assert_eq!(sparse.nrows, 3);
Source

pub fn eye_like(matrix: &Self) -> Self

Produces an eye with the same shape as another sparse matrix

Source

pub fn identity(size: usize) -> Self

Same as eye

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f64>::identity(3);

assert_eq!(sparse.ncols, 3);
assert_eq!(sparse.nrows, 3);
Source

pub fn ones(sparsity: f64, shape: Shape) -> Self

Creates a matrix with only one values at random locations

Same as random_like but with range from 1.0..=1.0

Source

pub fn reshape(&mut self, nrows: usize, ncols: usize)

Reshapes a sparse matrix

Examples

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<f64>::identity(3);

sparse.reshape(5,5);

assert_eq!(sparse.ncols, 5);
assert_eq!(sparse.nrows, 5);
Source

pub fn from_dense(matrix: Matrix<'a, T>) -> Self

Creates a sparse matrix from a already existent dense one.

Examples:

use sukker::{SparseMatrix, Matrix};

let dense = Matrix::<i32>::eye(4);

let sparse = SparseMatrix::from_dense(dense);

assert_eq!(sparse.get(0,0), Some(1));
assert_eq!(sparse.get(1,0), Some(0));
assert_eq!(sparse.shape(), (4,4));
Source

pub fn from_slices( rows: &[usize], cols: &[usize], vals: &[T], shape: Shape, ) -> Result<Self, MatrixError>

Constructs a sparse matrix from 3 slices. One for the rows, one for the cols, and one for the value. A combination of values fromt the same index corresponds to an entry in the hasmap.

Csc in numpy uses 3 lists of same size

Examples:

use sukker::SparseMatrix;

let rows = vec![0,1,2,3];
let cols = vec![1,2,3,4];
let vals= vec![0.0,1.3,0.05,4.53];

let shape = (6,7);

let sparse = SparseMatrix::from_slices(&rows, &cols, &vals, shape).unwrap();

assert_eq!(sparse.shape(), (6,7));
assert_eq!(sparse.at(1,2), 1.3);
assert_eq!(sparse.at(0,1), 0.0);
Source

pub fn from_file(path: &'static str) -> Result<Self, MatrixError>

Parses from file, but will return a default sparse matrix if nothing is given

§Examples
use sukker::SparseMatrix;

// let m: SparseMatrix<f32> = Matrix::from_file("../../test.txt").unwrap();

// m.print(4);
Source

pub fn get(&self, i: usize, j: usize) -> Option<T>

Gets an element from the sparse matrix.

Returns None if index is out of bounds.

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.get(0,0), Some(1));
assert_eq!(sparse.get(1,0), Some(0));
assert_eq!(sparse.get(4,0), None);
Source

pub fn randomize_range(start: T, end: T, sparsity: f64, shape: Shape) -> Self

Gets the size of the sparse matrix

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::randomize_range(1.0,2.0, 0.75, (4,4));

assert_eq!(sparse.shape(), (4,4));
assert_eq!(sparse.sparsity(), 0.75);
assert_eq!(sparse.all(|(_, val)| val >= 1.0 && val <= 2.0), true);
assert_eq!(sparse.size(), 16);
Source

pub fn randomize(sparcity: f64, shape: Shape) -> Self

Randomizes a sparse matrix with values between 0 and 1.

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::randomize(0.75, (4,4));

assert_eq!(sparse.shape(), (4,4));
assert_eq!(sparse.sparsity(), 0.75);
assert_eq!(sparse.all(|(_, val)| val >= 0.0 && val <= 1.0), true);
assert_eq!(sparse.size(), 16);
Source

pub fn randomize_range_like(start: T, end: T, matrix: &Self) -> Self

Randomizes a sparse matrix to have same shape and sparcity as another one You can however set the range

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::randomize_range(1.0,2.0, 0.75, (4,4));

let copy = SparseMatrix::randomize_range_like(2.0, 4.0, &sparse);

assert_eq!(copy.shape(), (4,4));
assert_eq!(copy.sparsity(), 0.75);
assert_eq!(copy.all(|(_, val)| val >= 2.0 && val <= 4.0), true);
assert_eq!(copy.size(), 16);
Source

pub fn random_like(matrix: &Self) -> Self

Randomizes a sparse matrix to have same shape and sparcity as another one The values here are set to be between 0 and 1, no matter the value range of the matrix whos shape is being copied.

Examples

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::randomize_range(2.0, 4.0, 0.75, (4,4));

let copy = SparseMatrix::random_like(&sparse);

assert_eq!(copy.shape(), (4,4));
assert_eq!(copy.sparsity(), 0.75);
assert_eq!(copy.all(|(_, val)| val >= 0.0 && val <= 1.0), true);
assert_eq!(copy.size(), 16);
Source

pub fn at(&self, i: usize, j: usize) -> T

Same as get, but will panic if indexes are out of bounds

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.at(0,0), 1);
assert_eq!(sparse.at(1,0), 0);
Source

pub fn set(&mut self, value: T, idx: Shape)

Sets an element

If you’re trying to insert a zero-value, this function does nothing

Mutates or inserts a value based on indeces given

Source

pub fn insert(&mut self, i: usize, j: usize, value: T)

A way of inserting with individual row and col

Source

pub fn print(&self, decimals: usize)

Prints out the sparse matrix data

Only prints out the hashmap with a set amount of decimals

Source

pub fn size(&self) -> usize

Gets the size of the sparse matrix

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(4);

assert_eq!(sparse.size(), 16);
Source

pub fn get_zero_count(&self) -> usize

Get’s amount of 0s in the matrix

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(4);

assert_eq!(sparse.get_zero_count(), 12);
Source

pub fn sparsity(&self) -> f64

Calcualtes sparcity for the given matrix Sparity is defined as the percantage of the matrix filled with 0 values

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(4);

assert_eq!(sparse.sparsity(), 0.75);
Source

pub fn shape(&self) -> Shape

Shape of the matrix outputted as a tuple

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.shape(), (3,3));
Source

pub fn transpose(&mut self)

Transpose the matrix

Examples:

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<i32>::init(4,4);

sparse.set(1, (2,0));
sparse.set(2, (3,0));
sparse.set(3, (0,1));
sparse.set(4, (0,2));

sparse.transpose();

assert_eq!(sparse.at(0,2), 1);
assert_eq!(sparse.at(0,3), 2);
assert_eq!(sparse.at(1,0), 3);
assert_eq!(sparse.at(2,0), 4);

// Old value is now gone
assert_eq!(sparse.get(3,0), Some(0));
Source

pub fn t(&mut self)

Shorthand for transpose

Source

pub fn transpose_new(&self) -> Self

Tranpose the matrix into a new copy

Examples:

use sukker::SparseMatrix;

let mut mat = SparseMatrix::<i32>::init(4,4);

mat.set(1, (2,0));
mat.set(2, (3,0));
mat.set(3, (0,1));
mat.set(4, (0,2));

let sparse = mat.transpose_new();

assert_eq!(sparse.at(0,2), 1);
assert_eq!(sparse.at(0,3), 2);
assert_eq!(sparse.at(1,0), 3);
assert_eq!(sparse.at(2,0), 4);

assert_eq!(sparse.get(3,0), Some(0));
Source

pub fn max(&self) -> T

Finds max element of a sparse matrix Will return 0 if matrix is empty

Source

pub fn min(&self) -> T

Finds minimum element of a sparse matrix Will return 0 if matrix is empty

Source

pub fn neg(&self) -> Self

Negates all items

Source

pub fn avg(&self) -> T

Finds average value of a matrix

Returns 0 if matrix is empty

Source

pub fn mean(&self) -> T

Same as avg

Source

pub fn median(&self) -> T

Finds the median value of a matrix

If the matrix is empty, 0 is returned

Source§

impl<'a, T> SparseMatrix<'a, T>

Operations on sparse matrices

Source

pub fn add(&self, other: &Self) -> Result<Self, MatrixError>

Adds two sparse matrices together and return a new one

Examples:

use sukker::SparseMatrix;

let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

let res = sparse1.add(&sparse2).unwrap();

assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);
Source

pub fn sub(&self, other: &Self) -> Result<Self, MatrixError>

Subtracts two sparse matrices and return a new one

Examples:

use sukker::SparseMatrix;

let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

let res = sparse1.sub(&sparse2).unwrap();

assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);
Source

pub fn mul(&self, other: &Self) -> Result<Self, MatrixError>

Multiplies two sparse matrices together and return a new one

Examples:

use sukker::SparseMatrix;

let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

let res = sparse1.mul(&sparse2).unwrap();

assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);
Source

pub fn dot(&self, other: &Self) -> Result<Self, MatrixError>

Same as mul. This kind of matrix multiplication is called a dot product

Source

pub fn div(&self, other: &Self) -> Result<Self, MatrixError>

Divides two sparse matrices and return a new one

Examples:

use sukker::SparseMatrix;

let sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

let res = sparse1.div(&sparse2).unwrap();

assert_eq!(res.shape(), (3,3));
assert_eq!(res.get(0,0).unwrap(), 2);
Source

pub fn add_self(&mut self, other: &Self)

Adds rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs

Examples:

use sukker::SparseMatrix;

let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

sparse1.add_self(&sparse2);

assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 2);
Source

pub fn sub_self(&mut self, other: &Self)

Subs rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs

Examples:

use sukker::SparseMatrix;

let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

sparse1.sub_self(&sparse2);

assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 0);
Source

pub fn mul_self(&mut self, other: &Self)

Multiplies rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs

Examples:

use sukker::SparseMatrix;

let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

sparse1.mul_self(&sparse2);

assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 1);
Source

pub fn div_self(&mut self, other: &Self)

Divides rhs matrix on to lhs matrix. All elements from rhs gets inserted into lhs

Examples:

use sukker::SparseMatrix;

let mut sparse1 = SparseMatrix::<i32>::eye(3);
let sparse2 = SparseMatrix::<i32>::eye(3);

sparse1.div_self(&sparse2);

assert_eq!(sparse1.shape(), (3,3));
assert_eq!(sparse1.get(0,0).unwrap(), 1);
Source

pub fn add_val(&self, value: T) -> Self

Adds value to all non zero values in the matrix and return a new matrix

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;

let res = sparse.add_val(val);

assert_eq!(res.get(0,0).unwrap(), 5.5);
Source

pub fn sub_val(&self, value: T) -> Self

Subs value to all non zero values in the matrix and return a new matrix

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;

let res = sparse.sub_val(val);

assert_eq!(res.get(0,0).unwrap(), -3.5);
Source

pub fn mul_val(&self, value: T) -> Self

Multiplies value to all non zero values in the matrix and return a new matrix

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.5;

let res = sparse.mul_val(val);

assert_eq!(res.get(0,0).unwrap(), 4.5);
Source

pub fn div_val(&self, value: T) -> Self

Divides value to all non zero values in the matrix and return a new matrix.

Will panic if you choose to divide by zero

Examples:

use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::eye(3);
let val: f32 = 4.0;

let res = sparse.div_val(val);

assert_eq!(res.get(0,0).unwrap(), 0.25);
Source

pub fn add_val_self(&mut self, value: T)

Adds value to all non zero elements in matrix

Examples:

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;

sparse.add_val_self(val);

assert_eq!(sparse.get(0,0).unwrap(), 11.0);
Source

pub fn sub_val_self(&mut self, value: T)

Subtracts value to all non zero elements in matrix

Examples:

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;

sparse.sub_val_self(val);

assert_eq!(sparse.get(0,0).unwrap(), -9.0);
Source

pub fn mul_val_self(&mut self, value: T)

Multiplies value to all non zero elements in matrix

Examples:

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;

sparse.mul_val_self(val);

assert_eq!(sparse.get(0,0).unwrap(), 10.0);
Source

pub fn div_val_self(&mut self, value: T)

Divides all non zero elemnts in matrix by value in-place

Will panic if you choose to divide by zero

Examples:

use sukker::SparseMatrix;

let mut sparse = SparseMatrix::<f64>::eye(3);
let val = 10.0;

sparse.div_val_self(val);

assert_eq!(sparse.get(0,0).unwrap(), 0.1);
Source

pub fn matmul_sparse(&self, other: &Self) -> Result<Self, MatrixError>

Sparse matrix multiplication

For two n x n matrices, we use this algorithm: https://theory.stanford.edu/~virgi/cs367/papers/sparsemult.pdf

Else, we use this: link..

In this example we have these two matrices:

A:

0.0 2.0 0.0 4.0 6.0 0.0 0.0 0.0 8.0

B:

2.0 0.0 0.0 4.0 8.0 0.0 8.0 6.0 0.0

0.0 24.0 0 8.0 72.0 0 0.0 0.0 48.0

Examples

use std::collections::HashMap;
use sukker::{SparseMatrix, SparseMatrixData};

let mut indexes: SparseMatrixData<f64> = HashMap::new();

indexes.insert((0, 0), 2.0);
indexes.insert((0, 1), 2.0);
indexes.insert((1, 0), 2.0);
indexes.insert((1, 1), 2.0);

let sparse = SparseMatrix::<f64>::new(indexes, (2, 2));

let mut indexes2: SparseMatrixData<f64> = HashMap::new();

indexes2.insert((0, 0), 2.0);
indexes2.insert((0, 1), 2.0);
indexes2.insert((1, 0), 2.0);
indexes2.insert((1, 1), 2.0);

let sparse2 = SparseMatrix::<f64>::new(indexes2, (2, 2));

let res = sparse.matmul_sparse(&sparse2).unwrap();

assert_eq!(res.at(0, 0), 8.0);
assert_eq!(res.at(0, 1), 8.0);
assert_eq!(res.at(1, 0), 8.0);
assert_eq!(res.at(1, 1), 8.0);
Source§

impl<'a, T> SparseMatrix<'a, T>

Predicates for sparse matrices

Source

pub fn all<F>(&self, pred: F) -> bool
where F: Fn((Shape, T)) -> bool + Sync + Send,

Returns whether or not predicate holds for all values

§Examples
use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.all(|(idx, val)| val >= 0), true);
Source

pub fn any<F>(&self, pred: F) -> bool
where F: Fn((Shape, T)) -> bool + Sync + Send,

Returns whether or not predicate holds for any

§Examples
use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.shape(), (3,3));
assert_eq!(sparse.any(|(_, val)| val == 1), true);
Source

pub fn count_where<F>(&'a self, pred: F) -> usize
where F: Fn((&Shape, &T)) -> bool + Sync,

Counts all occurances where predicate holds

§Examples
use sukker::SparseMatrix;

let sparse = SparseMatrix::<i32>::eye(3);

assert_eq!(sparse.count_where(|(_, &val)| val == 1), 3);
Source

pub fn sum_where<F>(&self, pred: F) -> T
where F: Fn((&Shape, &T)) -> bool + Sync,

Sums all occurances where predicate holds

§Examples
use sukker::SparseMatrix;

let sparse = SparseMatrix::<f32>::eye(3);

assert_eq!(sparse.sum_where(|(&(i, j), &val)| val == 1.0 && i > 0), 2.0);
Source

pub fn set_where<F>(&mut self, pred: F)
where F: FnMut((&Shape, &mut T)) + Sync + Send,

Sets all elements where predicate holds true. The new value is to be set inside the predicate as well

§Examples
Source

pub fn find<F>(&self, pred: F) -> Option<T>
where F: Fn((&Shape, &T)) -> bool + Sync,

Finds value of first occurance where predicate holds true

§Examples
Source

pub fn position<F>(&self, pred: F) -> Option<Shape>
where F: Fn((&Shape, &T)) -> bool + Sync,

Finds indices of first occurance where predicate holds true

§Examples

Trait Implementations§

Source§

impl<'a, T> Clone for SparseMatrix<'a, T>

Source§

fn clone(&self) -> SparseMatrix<'a, T>

Returns a duplicate 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<'a, T> Debug for SparseMatrix<'a, T>

Source§

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

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

impl<'a, T> Default for SparseMatrix<'a, T>

Source§

fn default() -> Self

Returns a sparse 3x3 identity matrix

Source§

impl<'de, 'a, T> Deserialize<'de> for SparseMatrix<'a, T>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a, T> Display for SparseMatrix<'a, T>

Source§

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

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

impl<'a, T> Error for SparseMatrix<'a, T>

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<'a, T> FromStr for SparseMatrix<'a, T>
where T: MatrixElement, <T as FromStr>::Err: Error + 'static,

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<'a, T> LinAlgFloats<'a, T> for SparseMatrix<'a, T>

Linear algebra on sparse matrices

Source§

fn ln(&self) -> Self

Source§

fn log(&self, base: T) -> Self

Source§

fn sin(&self) -> Self

Source§

fn cos(&self) -> Self

Source§

fn tan(&self) -> Self

Source§

fn sqrt(&self) -> Self

Source§

fn sinh(&self) -> Self

Source§

fn cosh(&self) -> Self

Source§

fn tanh(&self) -> Self

Source§

fn get_eigenvalues(&self) -> Option<Vec<T>>

Source§

fn get_eigenvectors(&self) -> Option<Vec<T>>

Source§

impl<'a, T> PartialEq for SparseMatrix<'a, T>

Source§

fn eq(&self, other: &SparseMatrix<'a, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T> Serialize for SparseMatrix<'a, T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a, T> Send for SparseMatrix<'a, T>

Source§

impl<'a, T> StructuralPartialEq for SparseMatrix<'a, T>

Source§

impl<'a, T> Sync for SparseMatrix<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for SparseMatrix<'a, T>

§

impl<'a, T> RefUnwindSafe for SparseMatrix<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Unpin for SparseMatrix<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for SparseMatrix<'a, T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,