pySimBlocks.blocks.operators.product

class pySimBlocks.blocks.operators.product.Product(name: str, operations: str | None = None, multiplication: str = 'Element-wise (*)', sample_time: float | None = None)[source]

Bases: Block

Multi-input product block.

Computes a product or division of multiple 2D input signals. The number of inputs is len(operations) + 1. Two multiplication modes are supported:

  • Element-wise: applies * and / component-wise with scalar (1,1) broadcasting only.

  • Matrix: applies @ sequentially; division is not supported.

Input shapes are frozen per port after their first use.

operations

String of '*' and '/' operators, one per adjacent pair of inputs.

multiplication

Active multiplication mode string.

num_inputs

Total number of input ports.

direct_feedthrough = True

True if outputs depend directly on inputs.

initialize(t0: float) None[source]

Compute the initial output if all inputs are available.

Parameters:

t0 – Initial simulation time in seconds.

output_update(t: float, dt: float) None[source]

Compute the product and write the result to the output port.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.

Raises:
  • RuntimeError – If any input port is not connected.

  • ValueError – If input shapes are inconsistent or incompatible with the multiplication mode.

state_update(t: float, dt: float) None[source]

No-op: Product is a stateless block.

Parameters:
  • t – Current simulation time in seconds.

  • dt – Current time step in seconds.