pub struct ResolvedLoadFactors { /* private fields */ }Expand description
Pre-resolved per-block load scaling factors.
O(1) lookup by (bus_index, stage_index, block_index) into dense 3D storage
(n_buses * n_stages * max_blocks); 1.0 for absent entries (no scaling).
§Examples
use cobre_core::resolved::ResolvedLoadFactors;
let empty = ResolvedLoadFactors::empty();
assert!((empty.factor(0, 0, 0) - 1.0).abs() < f64::EPSILON);Implementations§
Source§impl ResolvedLoadFactors
impl ResolvedLoadFactors
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty load factors table; all lookups return 1.0.
The default when no load_factors.json exists.
§Examples
use cobre_core::resolved::ResolvedLoadFactors;
let t = ResolvedLoadFactors::empty();
assert!((t.factor(5, 3, 2) - 1.0).abs() < f64::EPSILON);Sourcepub fn new(n_buses: usize, n_stages: usize, max_blocks: usize) -> Self
pub fn new(n_buses: usize, n_stages: usize, max_blocks: usize) -> Self
Create a new load factors table with the given dimensions.
All entries are initialized to 1.0 (no scaling). Use set to
populate individual entries.
Sourcepub fn set(
&mut self,
bus_idx: usize,
stage_idx: usize,
block_idx: usize,
value: f64,
)
pub fn set( &mut self, bus_idx: usize, stage_idx: usize, block_idx: usize, value: f64, )
Set the load factor for a specific (bus_idx, stage_idx, block_idx) triple.
§Panics
Panics if any index is out of bounds.
Sourcepub fn factor(&self, bus_idx: usize, stage_idx: usize, block_idx: usize) -> f64
pub fn factor(&self, bus_idx: usize, stage_idx: usize, block_idx: usize) -> f64
Look up the load factor for a (bus_idx, stage_idx, block_idx) triple.
Returns 1.0 when the table is empty or the flat index lands past Vec::len.
The 1.0 fallback only holds for indices past Vec::len; a per-dimension
overflow that stays within Vec::len (e.g. block_idx >= max_blocks with a
small bus_idx) aliases a neighbouring cell. Callers pass only in-range
dimensions — do not rely on the fallback for arbitrary out-of-range triples.
Trait Implementations§
Source§impl Clone for ResolvedLoadFactors
impl Clone for ResolvedLoadFactors
Source§fn clone(&self) -> ResolvedLoadFactors
fn clone(&self) -> ResolvedLoadFactors
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more