functionisEqual
Compare whether two Real matrices are identical
Extends from Modelica.Icons.Function (Icon for functions).
Information
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.isEqualInputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:,:] | M1 | First matrix | |
| Real[:,:] | M2 | Second matrix (may have different size as M1) | |
| Real | eps | 0 | Two elements e1 and e2 of the two matrices are identical if abs(e1-e2) <= eps |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | result | = true, if matrices have the same size and the same elements |