@@ -265,6 +265,35 @@ TEMPLATE_TEST_CASE( "test M(XY) = M(X) + M(Y) if X <= Y for some probes M", "[pr
265
265
});
266
266
}
267
267
268
+ TEMPLATE_TEST_CASE ( " test M(2, 1, 4, 3, 6, 5, ...) <= |X| * M(2, 1) / 2 for most probes M" , " [probe]" ,
269
+ decltype (cppsort::probe::dis),
270
+ decltype(cppsort::probe::enc),
271
+ decltype(cppsort::probe::exc),
272
+ decltype(cppsort::probe::ham),
273
+ decltype(cppsort::probe::inv),
274
+ decltype(cppsort::probe::max),
275
+ decltype(cppsort::probe::rem),
276
+ decltype(cppsort::probe::runs),
277
+ decltype(cppsort::probe::spear),
278
+ decltype(cppsort::probe::sus) )
279
+ {
280
+ // From *Sorting and Measures of Disorder* by Estivill-Castro:
281
+ // property derived from Mannila's criteria 2 & 4
282
+ // The following probes don't satisfy it: Block, Mono, Osc
283
+
284
+ int size = 1000 ;
285
+ std::vector<int > sequence (size, 0 );
286
+ std::iota (sequence.begin (), sequence.end (), 0 );
287
+ for (int i = 0 ; i < size; i += 2 ) {
288
+ std::swap (sequence[i], sequence[i + 1 ]);
289
+ }
290
+
291
+ int inversion[2 ] = {2 , 1 };
292
+
293
+ std::decay_t <TestType> measure;
294
+ CHECK ( measure (sequence) <= size * measure (inversion) / 2 );
295
+ }
296
+
268
297
TEMPLATE_TEST_CASE ( " test M(aX) <= |X| + M(X) for most probes M" , " [probe]" ,
269
298
decltype (cppsort::probe::block),
270
299
decltype(cppsort::probe::dis),
0 commit comments