.Modelica.Math.Vectors.isEqual

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

Vectors.find, Matrices.isEqual, Strings.isEqual

Interface

function isEqual
  extends Modelica.Icons.Function;
  input Real v1[:] "First vector";
  input Real v2[:] "Second vector (may have different length as v1)";
  input Real eps(min = 0) = 0 "Two elements e1 and e2 of the two vectors are identical if abs(e1-e2) <= eps";
  output Boolean result "= true, if vectors have the same length and the same elements";
end isEqual;

Generated at 2020-06-05T07:38:22Z by OpenModelica 1.16.0~dev-420-gc007a39