Skip to main content

igraph_matrix_int_t

Struct igraph_matrix_int_t 

Source
pub struct igraph_matrix_int_t { /* private fields */ }

Implementations§

Source§

impl igraph_matrix_int_t

Source

pub fn zeros(nrow: usize, ncol: usize) -> Self

Creates a nrow × ncol matrix filled with zeros (igraph_matrix_init).

§Panics

If igraph cannot allocate the matrix, or the size overflows, like Vec::with_capacity.

Source

pub fn new() -> Self

Creates an empty 0 × 0 matrix.

Source

pub fn from_column_major( nrow: usize, ncol: usize, data: &[igraph_int_t], ) -> Result<Self>

Builds a matrix from its elements given in column-major order (igraph’s storage order, see igraph_matrix_init_array).

§Errors

ErrorKind::InvalidValue if data.len() != nrow * ncol.

Source

pub fn from_row_major( nrow: usize, ncol: usize, data: &[igraph_int_t], ) -> Result<Self>

Builds a matrix from its elements given in row-major order.

§Errors

ErrorKind::InvalidValue if data.len() != nrow * ncol.

Source

pub fn from_rows<R: AsRef<[igraph_int_t]>>(rows: &[R]) -> Result<Self>

Builds a matrix from a slice of rows (a 0 × 0 matrix for no rows).

§Errors

ErrorKind::InvalidValue if the rows do not all have the same length.

Source

pub fn nrow(&self) -> usize

Number of rows (igraph_matrix_nrow).

Source

pub fn ncol(&self) -> usize

Number of columns (igraph_matrix_ncol).

Source

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

(nrow, ncol).

Source

pub fn is_empty(&self) -> bool

Whether the matrix has no elements.

Source

pub fn as_slice(&self) -> &[igraph_int_t] ⓘ

All the elements, in column-major order.

Source

pub fn as_mut_slice(&mut self) -> &mut [igraph_int_t] ⓘ

All the elements, in column-major order, mutably.

Source

pub fn get(&self, row: usize, col: usize) -> Option<&igraph_int_t>

The element at (row, col), if in bounds.

Source

pub fn column(&self, j: usize) -> &[igraph_int_t] ⓘ

The j-th column, as a slice (columns are contiguous in column-major storage).

§Panics

If j >= ncol.

Source

pub fn row(&self, i: usize) -> Vec<igraph_int_t> ⓘ

A copy of the i-th row.

§Panics

If i >= nrow.

Source

pub fn rows(&self) -> impl Iterator<Item = Vec<igraph_int_t>> + '_

Iterates over copies of the rows.

Source

pub fn columns(&self) -> impl Iterator<Item = &[igraph_int_t]> + '_

Iterates over the columns, as slices.

Source

pub fn to_rows(&self) -> Vec<Vec<igraph_int_t>>

Converts into a row-major Vec of rows.

Source

pub fn transposed(&self) -> Self

Returns the transposed matrix.

Source

pub fn resize(&mut self, nrow: usize, ncol: usize)

Resizes to nrow × ncol (igraph_matrix_resize); igraph does not preserve the content meaningfully, so this wrapper resets every element to zero. Use add_rows, add_cols, remove_row and remove_col to keep the content.

Source§

impl igraph_matrix_int_t

Source

pub fn view( data: &[igraph_int_t], nrow: usize, ncol: usize, ) -> Result<View<'_, Self>>

A read-only matrix view of column-major data, without copying it; the view dereferences to the matrix type, so it can be handed to igraph as a const matrix input (igraph_matrix_view).

§Errors

ErrorKind::InvalidValue if data.len() != nrow * ncol.

Source

pub fn fill(&mut self, value: igraph_int_t)

Sets every element to value (igraph_matrix_fill).

Source

pub fn set_row(&mut self, i: usize, values: &[igraph_int_t]) -> Result<()>

Replaces row i with values (igraph_matrix_set_row).

§Errors

ErrorKind::InvalidValue if i is out of bounds or values.len() != ncol.

Source

pub fn set_col(&mut self, j: usize, values: &[igraph_int_t]) -> Result<()>

Replaces column j with values (igraph_matrix_set_col).

§Errors

ErrorKind::InvalidValue if j is out of bounds or values.len() != nrow.

Source

pub fn select_rows(&self, rows: &[igraph_int_t]) -> Result<Self>

A new matrix made of the given rows, in the given order (repetitions allowed) (igraph_matrix_select_rows).

§Errors

ErrorKind::InvalidValue for out of bounds rows.

Source

pub fn select_cols(&self, cols: &[igraph_int_t]) -> Result<Self>

A new matrix made of the given columns, in the given order (igraph_matrix_select_cols).

§Errors

ErrorKind::InvalidValue for out of bounds columns.

Source

pub fn select_rows_cols( &self, rows: &[igraph_int_t], cols: &[igraph_int_t], ) -> Result<Self>

The submatrix at the intersection of the given rows and columns (igraph_matrix_select_rows_cols).

§Errors

ErrorKind::InvalidValue for out of bounds indices.

Source

pub fn swap_rows(&mut self, i: usize, j: usize) -> Result<()>

Swaps rows i and j (igraph_matrix_swap_rows).

§Errors

ErrorKind::InvalidValue for out of bounds rows.

Source

pub fn swap_cols(&mut self, i: usize, j: usize) -> Result<()>

Swaps columns i and j (igraph_matrix_swap_cols).

§Errors

ErrorKind::InvalidValue for out of bounds columns.

Source

pub fn transpose(&mut self)

Transposes the matrix in place (igraph_matrix_transpose); see also transposed.

Source

pub fn rbind(&mut self, other: &Self) -> Result<()>

Appends the rows of other below this matrix (igraph_matrix_rbind).

§Errors

ErrorKind::InvalidValue if the column counts differ.

Source

pub fn cbind(&mut self, other: &Self) -> Result<()>

Appends the columns of other to the right of this matrix (igraph_matrix_cbind).

§Errors

ErrorKind::InvalidValue if the row counts differ.

Source

pub fn add_rows(&mut self, n: usize)

Appends n rows of zeros (igraph_matrix_add_rows).

Source

pub fn add_cols(&mut self, n: usize)

Appends n columns of zeros (igraph_matrix_add_cols).

Source

pub fn remove_row(&mut self, i: usize) -> Result<()>

Removes row i (igraph_matrix_remove_row).

§Errors

ErrorKind::InvalidValue if out of bounds.

Source

pub fn remove_col(&mut self, j: usize) -> Result<()>

Removes column j (igraph_matrix_remove_col).

§Errors

ErrorKind::InvalidValue if out of bounds.

Source

pub fn is_symmetric(&self) -> bool

Whether the matrix is square and equal to its transpose (igraph_matrix_is_symmetric).

Source

pub fn contains(&self, value: igraph_int_t) -> bool

Whether some element equals value (igraph_matrix_contains).

Source

pub fn search(&self, from: usize, value: igraph_int_t) -> Option<(usize, usize)>

The (row, col) of the first occurrence of value at or after the column-major position from, if any (igraph_matrix_search).

Source

pub fn capacity(&self) -> usize

Number of elements the matrix can hold without reallocating (igraph_matrix_capacity).

Source

pub fn shrink_to_fit(&mut self)

Frees the unused storage (igraph_matrix_resize_min).

Source

pub fn diagonal(&self) -> Vec<igraph_int_t> ⓘ

The main diagonal, m[(i, i)] for i < min(nrow, ncol).

Source

pub fn indexed_iter( &self, ) -> impl Iterator<Item = ((usize, usize), &igraph_int_t)> + '_

Iterates over ((row, col), &value) in column-major order.

Source§

impl igraph_matrix_int_t

Source

pub fn min(&self) -> Option<igraph_int_t>

The smallest element, or None if the matrix is empty (igraph_matrix_min).

Source

pub fn max(&self) -> Option<igraph_int_t>

The largest element, or None if the matrix is empty (igraph_matrix_max).

Source

pub fn which_min(&self) -> Option<(usize, usize)>

(row, col) of the smallest element, or None if empty (igraph_matrix_which_min).

Source

pub fn which_max(&self) -> Option<(usize, usize)>

(row, col) of the largest element, or None if empty (igraph_matrix_which_max).

Source

pub fn minmax(&self) -> Option<(igraph_int_t, igraph_int_t)>

(min, max), or None if empty (as igraph_matrix_minmax).

Source

pub fn maxdifference(&self, other: &Self) -> f64

The largest absolute element-wise difference, comparing the elements in column-major order (igraph_matrix_maxdifference).

Source

pub fn all_l(&self, other: &Self) -> bool

Whether the shapes agree and every element is < the other’s (igraph_matrix_all_l).

Source

pub fn all_g(&self, other: &Self) -> bool

Whether the shapes agree and every element is > the other’s (igraph_matrix_all_g).

Source

pub fn all_le(&self, other: &Self) -> bool

Whether the shapes agree and every element is <= the other’s (igraph_matrix_all_le).

Source

pub fn all_ge(&self, other: &Self) -> bool

Whether the shapes agree and every element is >= the other’s (igraph_matrix_all_ge).

Source§

impl igraph_matrix_int_t

Source

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

Element-wise self += other, wrapping on overflow (Rust counterpart of igraph_matrix_int_add).

§Errors

ErrorKind::InvalidValue if the shapes differ.

Source

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

Element-wise self -= other, wrapping on overflow (Rust counterpart of igraph_matrix_int_sub).

§Errors

ErrorKind::InvalidValue if the shapes differ.

Source

pub fn mul_elements(&mut self, other: &Self) -> Result<()>

Element-wise product, wrapping on overflow (Rust counterpart of igraph_matrix_int_mul_elements).

§Errors

ErrorKind::InvalidValue if the shapes differ.

Source

pub fn scale(&mut self, factor: igraph_int_t)

Multiplies every element by factor, wrapping on overflow (Rust counterpart of igraph_matrix_int_scale).

Source

pub fn add_constant(&mut self, value: igraph_int_t)

Adds value to every element, wrapping on overflow (Rust counterpart of igraph_matrix_int_add_constant).

Source

pub fn div_elements(&mut self, other: &Self) -> Result<()>

Element-wise integer division self[(i,j)] /= other[(i,j)], rounding towards zero (Rust counterpart of igraph_matrix_int_div_elements, whose C version traps on a zero divisor).

§Errors

ErrorKind::InvalidValue if the shapes differ or some divisor is zero (nothing is modified then).

Source

pub fn prod(&self) -> igraph_int_t

Product of all elements (one for an empty matrix), wrapping on overflow (Rust counterpart of igraph_matrix_int_prod).

Source

pub fn sum(&self) -> igraph_int_t

Sum of all elements, wrapping on overflow (Rust counterpart of igraph_matrix_int_sum).

Source

pub fn rowsums(&self) -> Vec<igraph_int_t> ⓘ

The sum of each row (Rust counterpart of igraph_matrix_int_rowsum).

Source

pub fn colsums(&self) -> Vec<igraph_int_t> ⓘ

The sum of each column (Rust counterpart of igraph_matrix_int_colsum).

Trait Implementations§

Source§

impl Clone for igraph_matrix_int_t

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for igraph_matrix_int_t

Source§

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

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

impl Default for igraph_matrix_int_t

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for igraph_matrix_int_t

Source§

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

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

impl Drop for igraph_matrix_int_t

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl From<&igraph_matrix_int_t> for igraph_matrix_t

Source§

fn from(m: &igraph_matrix_int_t) -> Self

Converts an integer matrix to a real one.

Source§

impl From<igraph_matrix_int_t> for Vec<Vec<igraph_int_t>>

Source§

fn from(m: igraph_matrix_int_t) -> Self

Converts to this type from the input type.
Source§

impl Index<(usize, usize)> for igraph_matrix_int_t

Source§

type Output = i64

The returned type after indexing.
Source§

fn index(&self, (i, j): (usize, usize)) -> &igraph_int_t

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<(usize, usize)> for igraph_matrix_int_t

Source§

fn index_mut(&mut self, (i, j): (usize, usize)) -> &mut igraph_int_t

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl PartialEq for igraph_matrix_int_t

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Send for igraph_matrix_int_t

Source§

impl Sync for igraph_matrix_int_t

Auto Trait Implementations§

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