Hardcaml_circuits.Sorting_networkSorting networks.
A sorting network arranges a fixed configuration of compare-and-swaps to sort data. The static nature of the network means they can be easily implemented in hardware.
This module implements Bitonic_sort and Odd_even_merge_sort networks.
The network construction abstracts over the actual data to be sorted and the compare-and-swap implementation, allowing various configurations:
Bits or Signals combinatorial networksAn excellent resource explaining the complexity and correctness of these algorithms is:
http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/networks/indexen.htm
The algorithms are analysed using the 0-1 principle which states that a network that sorts any sequence of 0s and 1s also sorts arbitrary data.
module Config : sig ... endmodule Min_or_max : sig ... endmodule Min_max : sig ... endtype 'a compare_and_swap = 'a -> 'a -> 'a Min_max.tval create : Config.t -> 'a compare_and_swap -> 'a list -> 'a list