feat(components): add ThermoState generators and Eurovent backend demo
This commit is contained in:
@@ -67,6 +67,26 @@ impl JacobianMatrix {
|
||||
JacobianMatrix(matrix)
|
||||
}
|
||||
|
||||
/// Updates an existing Jacobian matrix from sparse entries in-place.
|
||||
///
|
||||
/// The matrix is first zeroed out, then filled with the new entries.
|
||||
/// This avoids re-allocating memory during iterations, satisfying the
|
||||
/// zero-allocation architecture constraint.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `entries` - Slice of `(row, col, value)` tuples
|
||||
pub fn update_from_builder(&mut self, entries: &[(usize, usize, f64)]) {
|
||||
self.0.fill(0.0);
|
||||
let n_rows = self.0.nrows();
|
||||
let n_cols = self.0.ncols();
|
||||
for &(row, col, value) in entries {
|
||||
if row < n_rows && col < n_cols {
|
||||
self.0[(row, col)] += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a zero Jacobian matrix with the given dimensions.
|
||||
pub fn zeros(n_rows: usize, n_cols: usize) -> Self {
|
||||
JacobianMatrix(DMatrix::zeros(n_rows, n_cols))
|
||||
|
||||
Reference in New Issue
Block a user