Lemonergy · Studio block

Find nonzero elements

Finds nonzero elements and returns their zero-based indices and valid count.

Implementation ID
native-find-nonzero
Reviewed
2026-10-27

Behavior

indices = {i : uᵢ ≠ 0}; count = number of valid indices. The worked example connects this operation to signals in Lemonergy Studio.

Interface

Find nonzero elements interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Find nonzero elementsStudio blockin0out0out1
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
in0input1Values; real 4 array.
out0output1Indices; u32 4 array.
out1output1Count; u32 scalar.

Parameters

No configurable parameters for this component.

Equations and rules

  • indices = {i : uᵢ ≠ 0}; count = number of valid indices

Worked example

Find nonzero elements — worked example

Values = [0,3,0,-1]. Indices at 0 s = [1,3,0,0]; Count at 0 s = 2.

Open Studio example after release →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
Indices
out0
0[1, 3, 0, 0]11e-08
Count
out1
0211e-08

Explore the recorded outputs

Find nonzero elements recorded example

Find nonzero elements / Indices [1]
Find nonzero elements / Indices [1] against timeRecorded synthetic simulation values. Time in seconds; output in —.0.500.750.2510.51.250.751.51—Time (s)
Find nonzero elements / Indices [1]: 1 — at 0 s

2 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.

Download the recorded samples (JSON) · Open this Studio example after release

Use in a workflow

Find nonzero elements — worked example

Finds nonzero elements and returns their zero-based indices and valid count.

  1. Find nonzero elements: indices = {i : uᵢ ≠ 0}; count = number of valid indices. The worked example connects this operation to signals in Lemonergy Studio.
    • Use the block reference for settings and connections.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • Zero-based fixed-capacity index vector with zero padding and a separate valid-count output.
  • Shapes and element types are explicit. Values must be finite; automatic reshaping and unit conversion are not performed.

Reference basis

This software operation and its numerical conventions are defined by the public contract and worked example; no external research result is claimed.

Implementation sources

This reference follows the public interface and locally verified numerical checks for an upcoming release.

Contract: Lemonergy Studio public contract · Verification record: verification-2026-10-27

  • docs/glossary/native-block-verification.json

This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)