Library of functions operating on Boolean vectors
This library provides functions operating on vectors that have a Boolean vector as input argument.
Extends from Modelica.Icons.Package (Icon for standard packages).
| Name | Description | 
|---|---|
|  allTrue | Returns true, if all elements of the Boolean input vector are true ('and') | 
|  anyTrue | Returns true, if at least on element of the Boolean input vector is true ('or') | 
|  countTrue | Returns the number of true entries in a Boolean vector | 
|  enumerate | Enumerates the true entries in a Boolean vector (0 for false entries) | 
|  firstTrueIndex | Returns the index of the first true element of a Boolean vector | 
|  index | Returns the indices of the true entries of a Boolean vector | 
|  oneTrue | Returns true, if exactly one element of the Boolean input vector is true ("xor") | 
 Modelica.Math.BooleanVectors.allTrue
Modelica.Math.BooleanVectors.allTrueReturns true, if all elements of the Boolean input vector are true ('and')
allTrue(b);
Returns true if all elements of the Boolean input vector b are true. Otherwise the function returns false. If b is an empty vector, i.e., size(b,1)=0, the function returns false.
  Boolean b1[3] = {true, true, true};
  Boolean b2[3] = {false, true, false};
  Boolean r1, r2;
algorithm
  r1 = allTrue(b1);  // r1 = true
  r2 = allTrue(b2);  // r2 = false
anyTrue, countTrue, enumerate, firstTrueIndex, index, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | Boolean vector | 
| Name | Description | 
|---|---|
| result | = true, if all elements of b are true | 
 Modelica.Math.BooleanVectors.anyTrue
Modelica.Math.BooleanVectors.anyTrueReturns true, if at least on element of the Boolean input vector is true ('or')
anyTrue(b);
Returns true if at least one elements of the input Boolean vector b is true. Otherwise the function returns false. If b is an empty vector, i.e., size(b,1)=0, the function returns false.
  Boolean b1[3] = {false, false, false};
  Boolean b2[3] = {false, true, false};
  Boolean r1, r2;
algorithm
  r1 = anyTrue(b1);  // r1 = false
  r2 = anyTrue(b2);  // r2 = true
allTrue, countTrue, enumerate, firstTrueIndex, index, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | 
| Name | Description | 
|---|---|
| result | 
 Modelica.Math.BooleanVectors.countTrue
Modelica.Math.BooleanVectors.countTrueReturns the number of true entries in a Boolean vector
countTrue(b);
This function returns the number of true entries in a Boolean vector b.
countTrue({false, true, false, true}) returns 2.
allTrue, anyTrue, enumerate, firstTrueIndex, index, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | Boolean vector | 
| Name | Description | 
|---|---|
| n | Number of true entries | 
 Modelica.Math.BooleanVectors.enumerate
Modelica.Math.BooleanVectors.enumerateEnumerates the true entries in a Boolean vector (0 for false entries)
enumerate(b);
This function returns an integer vector that consecutively numbers the true entries in a Boolean vector b. The false entries are indicated by 0.
enumerate({false, true, false, true}) returns {0,1,0,2}.
allTrue, anyTrue, countTrue, firstTrueIndex, index, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | Boolean vector | 
| Name | Description | 
|---|---|
| enumerated[size(b, 1)] | Indices of the true entries (increasing order; 0 for false entries) | 
 Modelica.Math.BooleanVectors.firstTrueIndex
Modelica.Math.BooleanVectors.firstTrueIndexReturns the index of the first true element of a Boolean vector
firstTrueIndex(b);
Returns the index of the first true element of the Boolean vector b. If no element is true or b is an empty vector (i.e., size(b,1)=0) the function returns 0.
  Boolean b1[3] = {false, false, false};
  Boolean b2[3] = {false, true, false};
  Boolean b3[4] = {false, true, false, true};
  Integer r1, r2, r3;
algorithm
  r1 = firstTrueIndex(b1);  // r1 = 0
  r2 = firstTrueIndex(b2);  // r2 = 2
  r3 = firstTrueIndex(b3);  // r3 = 2
allTrue, anyTrue, countTrue, enumerate, index, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | 
| Name | Description | 
|---|---|
| index | 
 Modelica.Math.BooleanVectors.index
Modelica.Math.BooleanVectors.indexReturns the indices of the true entries of a Boolean vector
index(b);
This function returns an integer vector that contains indices to the true entries in a Boolean vector b. The number of entries in the integer vector is the number of true entries in b.
index({false, true, false, true}) returns {2,4}.
  allTrue, anyTrue, countTrue, enumerate, firstTrueIndex, and oneTrue.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | Boolean vector | 
| Name | Description | 
|---|---|
| indices[countTrue(b)] | Indices of the true entries | 
 Modelica.Math.BooleanVectors.oneTrue
Modelica.Math.BooleanVectors.oneTrueReturns true, if exactly one element of the Boolean input vector is true ("xor")
oneTrue(b);
Returns true if exactly one element of the input Boolean vector b is true. Otherwise the function returns false. If b is an empty vector, i.e., size(b,1)=0, the function returns false.
  Boolean b1[3] = {false, false, false};
  Boolean b2[3] = {false, true, false};
  Boolean b3[3] = {false, true, true};
  Boolean r1, r2, r3;
algorithm
  r1 = oneTrue(b1);  // r1 = false
  r2 = oneTrue(b2);  // r2 = true
  r3 = oneTrue(b3);  // r3 = false
allTrue, anyTrue, countTrue, enumerate, firstTrueIndex, and index.
Extends from Modelica.Icons.Function (Icon for functions).
| Name | Description | 
|---|---|
| b[:] | 
| Name | Description | 
|---|---|
| result |