pub struct RealFactorization { /* private fields */ }Expand description
A real sparse system whose sparsity pattern and values are both fixed across repeated solves, so the whole factorization — not merely the symbolic half — is computed once and reused.
This is the real-arithmetic twin of ComplexSparseSystem, and it exists
for the same reason that type does: the DC (Bθ) susceptance matrix
(linear::btheta) depends only on the topology, so a DC solve, a PTDF
column and a LODF column are all just different right-hand sides against
one factorization.
RealSparseSystem cannot serve that. Its contract — the one
LinearSolver codifies — is
“pattern fixed, values change every call”, so it numerically refactorizes
on every factor_and_solve. That is exactly right for Newton-Raphson,
whose Jacobian really does change every iteration, and exactly wrong for
PTDF, which would pay a fresh factorization once per bus.
Implementations§
Source§impl RealFactorization
impl RealFactorization
Sourcepub fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>
pub fn new(n: usize, entries: &[(usize, usize, f64)]) -> Option<Self>
Factorizes once. Returns None if the matrix is singular or malformed.
pub fn n(&self) -> usize
Sourcepub fn solve(&self, rhs: &[f64]) -> Option<Vec<f64>>
pub fn solve(&self, rhs: &[f64]) -> Option<Vec<f64>>
Solves A x = b against the cached factorization.
Singularity is checked on the result rather than reported by faer,
which returns NaN-poisoned values instead of an error — the same
contract solve_complex documents.
Sourcepub fn solve_transpose(&self, rhs: &[f64]) -> Option<Vec<f64>>
pub fn solve_transpose(&self, rhs: &[f64]) -> Option<Vec<f64>>
Solves Aᵀ x = b against the same cached factorization.
No second factorization is involved: an LU = PAQ decomposition solves
the transposed system by running the same triangular factors in the
opposite order, which is what faer’s solve_transpose_in_place does.
This is what makes an adjoint sensitivity affordable. A forward
sensitivity answers “how does everything respond to this variable” in
one solve against A; the adjoint answers “how does this quantity
respond to everything” in one solve against Aᵀ. Both directions are
useful and neither is derivable from the other cheaply, so
ac_sensitivity offers both — see linear::sensitivity’s
ptdf_column/ptdf_row pair for the same duality on the DC side.
Auto Trait Implementations§
impl Freeze for RealFactorization
impl RefUnwindSafe for RealFactorization
impl Send for RealFactorization
impl Sync for RealFactorization
impl Unpin for RealFactorization
impl UnsafeUnpin for RealFactorization
impl UnwindSafe for RealFactorization
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