blockTrueArrayConditional

Output a Boolean array with a given number of true elements and a priority order

Information

This block outputs a Boolean array with true at the output positions given by the first u entries of the priority-ordered index array uIdx. The number of true elements equals u when at least u valid and distinct entries are present in uIdx, and is less otherwise.

Parameters

TypeNameDefaultDescription
IntegerninSize of input array
IntegernoutninSize of output array
Boolean[nin,nin]filTru{j <= i for j in 1:nin, i in 1:nin}Lower triangular true matrix

Connectors

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Interfaces.IntegerInputuNumber of true elements
Buildings.Controls.OBC.CDL.Interfaces.IntegerInput[nin]uIdxArray of indices by order of priority to be true
Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput[nout]y1Array with true at the first u priority-ordered indices

Components

TypeNameDefaultDescription
Buildings.Controls.OBC.CDL.Integers.Equal[nout,nin]equOutInpTrue if output position index equals input index value
Buildings.Controls.OBC.CDL.Routing.IntegerVectorReplicatorrepUIdxReplicate input index array to nout rows for comparison with output position indices
Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nout,nin]conOutPosOutput position indices 1..nout replicated nin times across columns
FirstTrueIndex[nout]idxFirOccPosition of first occurrence in uIdx for each output-range value
Buildings.Controls.OBC.CDL.Routing.IntegerVectorReplicatorrepFirOccReplicate first-occurrence positions to nin elements for input-position matching
Buildings.Controls.OBC.CDL.Integers.Sources.Constant[nin,nout]conInpPosInput position indices 1..nin replicated nout times across columns
Buildings.Controls.OBC.CDL.Integers.Equal[nin,nout]equFirInpTrue if first-occurrence position matches input position index
Buildings.Controls.OBC.CDL.Logical.MultiOr[nin]mulIsUnqTrue at input position j if j is the first (unique) occurrence of its value in uIdx
Buildings.Controls.OBC.CDL.Routing.BooleanVectorReplicatorrepIsValReplicate element validity flag to matrix for element-wise AND with lower-triangular mask
Buildings.Controls.OBC.CDL.Logical.Sources.Constant[nin,nin]conLowTriConstant lower-triangular true matrix for masking preceding elements
Buildings.Controls.OBC.CDL.Logical.And[nin,nin]andValPreTrue at [i,j] if element j is valid and j precedes or equals i
CountTrue[nin]couValPreCount of valid preceding elements
Buildings.Controls.OBC.CDL.Integers.LessEqual[nin]leqUTrue if element rank is at most u (element is within the first u valid entries)
Buildings.Controls.OBC.CDL.Routing.IntegerScalarReplicatorrepUReplicate maximum selection count u to all elements for rank comparison
Buildings.Controls.OBC.CDL.Conversions.BooleanToInteger[nin]intSelConvert selection flag to integer for masking
Buildings.Controls.OBC.CDL.Integers.Multiply[nin]mulSelSelected indices: uIdx at selected positions, 0 elsewhere
Buildings.Controls.OBC.CDL.Integers.Equal[nout,nin]equOutSelTrue if output position index equals selected index value
Buildings.Controls.OBC.CDL.Routing.IntegerVectorReplicatorrepSelIdxReplicate selected indices to nout rows for comparison with output position indices
Buildings.Controls.OBC.CDL.Logical.MultiOr[nout]mulIsOutTrue at output position i if any selected input index equals i

Revisions

  • June 10, 2026, by Antoine Gautier:
    Refactored using CDL Elementary Blocks.
  • March 29, 2024, by Antoine Gautier:
    First implementation.