card function

Requirements.LogicalFunctions.card  · source

Icon of card

Returns the number of elements of a Boolean vector that are true

Extends Modelica.Icons.Function

Syntax

card(b);

Description

The function returns the number of true-elements of Boolean vector b (0, if no element is true; size(b,1), if all elements are true). It is used, for example, by oneTrue. For vectors of Property values use cardSatisfied, cardViolated, cardUndecided or cardUndefined.

Example

The property is demonstrated with the following example calling the function as:

nTrueElements = card( b )
simulation result

Revisions

DateDescription
Sept. 14, 2026Reduction written over the indices 1:size(.,1) instead of over the elements; the same count, and it compiles in Modelon Impact, which fails to scalarize the element form (H. Tummescheit, Model Based Innovation LLC)

Inputs

NameTypeDescription
b[…] inputBooleanBoolean vector

Outputs

NameTypeDescription
result outputIntegerNumber of true entries