pub struct BlockMatrix { /* private fields */ }Expand description
A mutable block-COO Y-bus/Jacobian accumulator: one 2×2 block per (bus,
bus) slot instead of network::YBus’s one Complex<f64> per (unknown,
unknown) slot. Duplicate (i, j) entries are summed once finalized,
matching YBus’s accumulation semantics.
Implementations§
Source§impl BlockMatrix
impl BlockMatrix
pub fn new(n: usize) -> Self
pub fn add(&mut self, i: usize, j: usize, block: Block2)
pub fn n(&self) -> usize
Sourcepub fn finish(self) -> BlockAdjacency
pub fn finish(self) -> BlockAdjacency
Consolidates duplicate (i, j) entries (summing them) and returns a
row-major and column-major adjacency list: row(i) gives all
(j, block) pairs with a nonzero block in row i (including the
diagonal), col(j) gives all (i, block) pairs with a nonzero block
in column j — both sorted by the other index. Kept as two separate
views (not just one, transposed on demand) because the real
power-flow Jacobian is not value-symmetric (block(i, j) != block(j, i) in general, even though the sparsity pattern is
structurally symmetric) — BlockLu::refactor genuinely needs
column j’s own values, not row j’s reused under a symmetry
assumption that doesn’t hold for this matrix.
Sort-based, not hash-based: newton_raphson_block calls this once
per iteration (the Jacobian’s numeric values change every iteration
even though its sparsity pattern doesn’t), so this runs thousands of
times per solve on realistic networks — profiling with perf showed
a HashMap-based merge costing ~25% of total block-backend runtime
at 2,605 nodes. Sorting by (i, j) avoids hashing entirely and
leaves each row already grouped in ascending-j order, so no
separate per-row sort is needed afterwards either; iterating that
same ascending-i order while building cols likewise leaves each
column already grouped in ascending-i order for free.
Auto Trait Implementations§
impl Freeze for BlockMatrix
impl RefUnwindSafe for BlockMatrix
impl Send for BlockMatrix
impl Sync for BlockMatrix
impl Unpin for BlockMatrix
impl UnsafeUnpin for BlockMatrix
impl UnwindSafe for BlockMatrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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