card function
Requirements.LogicalFunctions.card
· source
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
| Date | Description |
|---|---|
| Sept. 14, 2026 | Reduction 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
| Name | Type | Description |
|---|---|---|
b[…] input | Boolean | Boolean vector |
Outputs
| Name | Type | Description |
|---|---|---|
result output | Integer | Number of true entries |
