Next: , Previous: , Up: Internal Routines   [Contents][Index]

15.5.172 equivalence

equivalence(e1, e2)

Returns equivalence classes. In arrays e1 and e2 (which are transformed to type long) the user specifies which elements of a given set belong to the same equivalence class: elements e1(i) and e2(i) are in the same equivalence class for all i. The result of this function is an array with the same dimensional structure as e1 in which each element contains the lowest element number in the class that the current element is in.

For example, if e1 = [2,4,6,3] and e2 = [3,5,7,6], then equivalence(e1, e2) returns [2,4,2,2], indicating that elements 2, 3, 6, and 7 belong to one equivalence class (with element 2 having the smallest element number) and elements 4 and 5 to another (with element 4 the smallest).