Skip to main content

BlockPartition

Struct BlockPartition 

Source
pub struct BlockPartition {
    pub row_blocks: Vec<usize>,
    pub col_blocks: Vec<usize>,
}
Expand description

Block boundaries of a partitioned matrix: row_blocks and col_blocks are boundary lists starting at 0 and ending at m, n (invariants (B1)–(B3)).

use xingo_sparse::BlockPartition;
// [A | I] with A 3 × 5: one row block, structural then logical columns.
let p = BlockPartition::from_sizes(&[3], &[5, 3]).unwrap();
assert_eq!((p.n_rows(), p.n_cols()), (3, 8));
assert_eq!(p.col_block(1), 5..8);
assert_eq!(p.col_block_of(6), 1); // a logical column
// The augmented system [−D Aᵀ; A δI] of the same A: order 5 + 3.
let k = BlockPartition::new(vec![0, 5, 8], vec![0, 5, 8]).unwrap();
assert_eq!(k.row_block(1).start, 5); // the dual of constraint i is row 5 + i

Fields§

§row_blocks: Vec<usize>

Row boundaries [0 = r_0 < r_1 < … < r_p = m].

§col_blocks: Vec<usize>

Column boundaries [0 = c_0 < c_1 < … < c_q = n].

Implementations§

Source§

impl BlockPartition

Source

pub fn new( row_blocks: Vec<usize>, col_blocks: Vec<usize>, ) -> Result<Self, SparseError>

A partition from its boundary lists, validated ((B1)–(B3)).

Source

pub fn from_sizes( row_sizes: &[usize], col_sizes: &[usize], ) -> Result<Self, SparseError>

A partition from the sizes of its blocks (prefix sums): [A | I] with A of m × n is from_sizes(&[m], &[n, m]). An error if a size is 0 (blocks are never empty) or a dimension exceeds u32::MAX.

Source

pub fn check_invariants(&self) -> Result<(), SparseError>

Checks (B1)–(B3).

Source

pub fn n_rows(&self) -> usize

Number of rows m (the last row boundary).

Source

pub fn n_cols(&self) -> usize

Number of columns n (the last column boundary).

Source

pub fn n_row_blocks(&self) -> usize

Number of row blocks p.

Source

pub fn n_col_blocks(&self) -> usize

Number of column blocks q.

Source

pub fn row_block(&self, k: usize) -> Range<usize> ⓘ

The rows r_k..r_{k+1} of row block k.

§Panics

If k ≥ p.

Source

pub fn col_block(&self, l: usize) -> Range<usize> ⓘ

The columns c_l..c_{l+1} of column block l.

§Panics

If l ≥ q.

Source

pub fn row_block_of(&self, i: usize) -> usize

The row block containing row i (Algorithm B).

§Panics

If i ≥ m.

Source

pub fn col_block_of(&self, j: usize) -> usize

The column block containing column j (Algorithm B).

§Panics

If j ≥ n.

Trait Implementations§

Source§

impl Clone for BlockPartition

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 BlockPartition

Source§

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

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

impl Eq for BlockPartition

Source§

impl PartialEq for BlockPartition

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BlockPartition

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

Source§

fn by_ref(&self) -> &T

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> Imply<T> for U
where T: ?Sized, U: ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.