pySimBlocks.blocks.operators.gain¶
- class pySimBlocks.blocks.operators.gain.Gain(name: str, gain: ArrayLike = 1.0, multiplication: str = 'Element wise (K * u)', sample_time: float | None = None)[source]¶
Bases:
BlockStatic gain block.
Applies a gain to the input signal according to one of three multiplication modes: element-wise, left matrix product (K @ u), or right matrix product (u @ K).
- gain¶
Gain coefficient(s) — scalar float, 1D vector, or 2D matrix.
- multiplication¶
Active multiplication mode string.
- direct_feedthrough = True¶
True if outputs depend directly on inputs.
- MULT_ELEMENTWISE = 'Element wise (K * u)'¶
- MULT_LEFT = 'Matrix (K @ u)'¶
- MULT_RIGHT = 'Matrix (u @ K)'¶
- ALLOWED_MULTIPLICATIONS = {'Element wise (K * u)', 'Matrix (K @ u)', 'Matrix (u @ K)'}¶
- initialize(t0: float) None[source]¶
Compute the initial output from the initial input if available.
- Parameters:
t0 – Initial simulation time in seconds.
- output_update(t: float, dt: float) None[source]¶
Apply the gain to the input and write the result to the output port.
- Parameters:
t – Current simulation time in seconds.
dt – Current time step in seconds.
- Raises:
RuntimeError – If input
'in'is not connected.ValueError – If the input is not 2D or dimensions are incompatible with the gain and multiplication mode.