Skip to content

Compare ​

How two values of a partially ordered type compare: -1, 0 or 1, or NaN when they are incomparable.

Compare(a, b)How two values of a partially ordered type compare: -1, 0 or 1, or NaN when they are incomparable.
Typed signatures
TypePackageApplies
(any, any) -> unknownstructuresalways

Domain: Structures

Details
  • The PartialOrder protocol's member: a type conforms by saying how it compares two of its values.
  • Reflexive, antisymmetric and transitive; a LinearOrder never answers NaN.
  • Under dominance, [3,1,1,1][3,1,1,1] and [2,2,2][2,2,2] are incomparable: NaN.
  • Set partitions of one ground set under refinement (finer is lower): NaN unless one refines the other.
  • Permutations of one length under the right weak order, as Sage's permutohedron_lequal (default side="right"): p is below q when every inversion of p, a pair of values a < b with b first, is one of q's. The left order is this one on inverses.

Examples

Basic #

In a linear order: −1-1, 00 or 11

live ↗
InCompare(3,5)\mathrm{Compare}(3, 5)Out−1-1

[3,1][3,1] dominates [2,2][2,2]

live ↗
InCompare(IntegerPartition⁡([3,1]),IntegerPartition⁡([2,2]))\mathrm{Compare}({\operatorname{IntegerPartition}}([3, 1]), {\operatorname{IntegerPartition}}([2, 2]))Out11
Properties #

[3,1,1,1][3,1,1,1] and [2,2,2][2,2,2] are incomparable under dominance: NaN

live ↗
InCompare(IntegerPartition⁡([3,1,1,1]),IntegerPartition⁡([2,2,2]))\mathrm{Compare}({\operatorname{IntegerPartition}}([3, 1, 1, 1]), {\operatorname{IntegerPartition}}([2, 2, 2]))OutNaN⁡\operatorname{NaN}

The all-singletons partition refines every partition of its set

live ↗
InCompare(SetPartition⁡([[1],[2],[3]]),SetPartition⁡([[1,2,3]]))\mathrm{Compare}({\operatorname{SetPartition}}([[1], [2], [3]]), {\operatorname{SetPartition}}([[1, 2, 3]]))Out−1-1

Known value · Sage SetPartition refinement

{{1,2},{3}}\{\{1,2\},\{3\}\} and {{1},{2,3}}\{\{1\},\{2,3\}\} neither refines the other: NaN

live ↗
InCompare(SetPartition⁡([[1,2],[3]]),SetPartition⁡([[1],[2,3]]))\mathrm{Compare}({\operatorname{SetPartition}}([[1, 2], [3]]), {\operatorname{SetPartition}}([[1], [2, 3]]))OutNaN⁡\operatorname{NaN}

Known value · Sage SetPartition refinement

Right weak order, as Sage's permutohedron_lequal: the inversion pairs of values {(2,3)}\{(2,3)\} lie inside {(1,3),(2,3)}\{(1,3),(2,3)\}

live ↗
InCompare(Permutation⁡([1,3,2]),Permutation⁡([3,1,2]))\mathrm{Compare}({\operatorname{Permutation}}([1, 3, 2]), {\operatorname{Permutation}}([3, 1, 2]))Out−1-1

Known value · Sage permutohedron_lequal

213213 and 132132 invert different value pairs: NaN

live ↗
InCompare(Permutation⁡([2,1,3]),Permutation⁡([1,3,2]))\mathrm{Compare}({\operatorname{Permutation}}([2, 1, 3]), {\operatorname{Permutation}}([1, 3, 2]))OutNaN⁡\operatorname{NaN}

Known value · Sage permutohedron_lequal

About
Examples7

See also: Min, Max, GreatestLowerBound