functionisEqual
Determine if two Real vectors are numerically identical
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
Vectors.isEqual(v1, v2); Vectors.isEqual(v1, v2, eps=0);
Description
The function call "Vectors.isEqual(v1, v2)" returns true,
if the two Real vectors v1 and v2 have the same dimensions and
the same elements. Otherwise the function
returns false. Two elements e1 and e2 of the two vectors
are checked on equality by the test "abs(e1-e2) ≤ eps", where "eps"
can be provided as third argument of the function. Default is "eps = 0".
Example
Real v1[3] = {1, 2, 3};
Real v2[4] = {1, 2, 3, 4};
Real v3[3] = {1, 2, 3.0001};
Boolean result;
algorithm
result := Vectors.isEqual(v1,v2); // = false
result := Vectors.isEqual(v1,v3); // = false
result := Vectors.isEqual(v1,v1); // = true
result := Vectors.isEqual(v1,v3,0.1); // = true
See also
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:] | v1 | First vector | |
| Real[:] | v2 | Second vector (may have different length as v1) | |
| Real | eps | 0 | Two elements e1 and e2 of the two vectors are identical if abs(e1-e2) <= eps |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | result | = true, if vectors have the same length and the same elements |