isEqual

Compare whether two Real matrices are identical

Information

This information is part of the Modelica Standard Library maintained by the Modelica Association.

Syntax

Matrices.isEqual(M1, M2);
Matrices.isEqual(M1, M2, eps=0);

Description

The function call "Matrices.isEqual(M1, M2)" returns true, if the two Real matrices M1 and M2 have the same dimensions and the same elements. Otherwise the function returns false. Two elements e1 and e2 of the two matrices 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 A1[2,2] = [1,2; 3,4];
  Real A2[3,2] = [1,2; 3,4; 5,6];
  Real A3[2,2] = [1,2, 3,4.0001];
  Boolean result;
algorithm
  result := Matrices.isEqual(M1,M2);     // = false
  result := Matrices.isEqual(M1,M3);     // = false
  result := Matrices.isEqual(M1,M1);     // = true
  result := Matrices.isEqual(M1,M3,0.1); // = true

See also

Vectors.isEqual, Strings.isEqual

Syntax

result = isEqual(M1, M2, eps)

Inputs (3)

M1

Type: Real[:,:]

Description: First matrix

M2

Type: Real[:,:]

Description: Second matrix (may have different size as M1)

eps

Default Value: 0

Type: Real

Description: Two elements e1 and e2 of the two matrices are identical if abs(e1-e2) <= eps

Outputs (1)

result

Type: Boolean

Description: = true, if matrices have the same size and the same elements