Skip to content

Commit f6188a0

Browse files
committed
Test that Mono(Reversed(X)) = Mono(X)
1 parent d0529d9 commit f6188a0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/Original-research.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ The following relations have yet to be analyzed:
236236
- $Osc \preceq Mono$
237237
- $Loc \preceq Mono$
238238

239+
Another interesting property of $Mono$ is that it returns the same amount of disorder for a sequence $X$ and for a sequence corresponding to $X$ with the order of all elements reversed, a property that is only shared with $Osc$ in the library.
240+
239241

240242
[better-sorting-networks]: https://etd.ohiolink.edu/!etd.send_file?accession=kent1239814529
241243
[cycle-sort]: https://en.wikipedia.org/wiki/Cycle_sort

tests/probes/mono.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/*
2-
* Copyright (c) 2018-2022 Morwenn
2+
* Copyright (c) 2018-2025 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
5+
#include <algorithm>
56
#include <forward_list>
67
#include <vector>
78
#include <catch2/catch_test_macros.hpp>
9+
#include <rapidcheck.h>
10+
#include <rapidcheck/catch.h>
811
#include <cpp-sort/probes/mono.h>
912
#include <cpp-sort/utility/size.h>
1013
#include <testing-tools/internal_compare.h>
@@ -52,4 +55,10 @@ TEST_CASE( "measure of disorder: mono", "[probe][mono]" )
5255
const std::forward_list<int> li2 = { 1, 1, 2, 8, 3, 3, 2, 1, 1, 5, 6 };
5356
CHECK( mono(li2) == 2 );
5457
}
58+
59+
rc::prop("Mono(Reversed(X)) = Mono(X)", [](std::vector<int> sequence) {
60+
auto mono_x = mono(sequence);
61+
std::reverse(sequence.begin(), sequence.end());
62+
return mono(sequence) == mono_x;
63+
});
5564
}

0 commit comments

Comments
 (0)