sn-count-cuts sn-count-markov sn-cut \
sn-info sn-markov sn-merge sn-normalize \
sn-oddevenmerge sn-oddevensort sn-pairwisesort \
- sn-shmoo sn-show sn-svg sn-tex sn-tex-cut
+ sn-shmoo sn-show sn-svg sn-tex sn-tex-cut sn-transpositionsort
libsortnetwork_la_SOURCES = sn_network.c sn_network.h \
sn_stage.c sn_stage.h \
sn_tex_cut_SOURCES = sn-tex-cut.c
sn_tex_cut_LDADD = libsortnetwork.la
+sn_transpositionsort_SOURCES = sn-transpositionsort.c
+sn_transpositionsort_LDADD = libsortnetwork.la
+
if BUILD_WITH_LIBPOPULATION
bin_PROGRAMS += sn-evolution sn-evolution2 sn-evolution-cut sn-evolution-merge
--- /dev/null
+/**
+ * libsortnetwork - src/sn-transpositionsort.c
+ * Copyright (C) 2011 Florian Forster
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Florian octo Forster <ff at octo.it>
+ **/
+
+#ifndef _ISOC99_SOURCE
+# define _ISOC99_SOURCE
+#endif
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "sn_network.h"
+
+int main (int argc, char **argv)
+{
+ sn_network_t *n;
+ int inputs_num;
+ int i;
+
+ if (argc != 2)
+ {
+ printf ("Usage: %s <num inputs>\n", argv[0]);
+ exit (EXIT_FAILURE);
+ }
+
+ inputs_num = atoi (argv[1]);
+ if (inputs_num < 2)
+ {
+ fprintf (stderr, "Invalid number of inputs: %i\n", inputs_num);
+ exit (EXIT_FAILURE);
+ }
+
+ n = sn_network_create (inputs_num);
+ if (n == NULL)
+ {
+ printf ("n == NULL!\n");
+ exit (EXIT_FAILURE);
+ }
+
+ for (i = 0; i < inputs_num; i++)
+ {
+ int j;
+
+ for (j = 1 + (i % 2); j < inputs_num; j += 2)
+ {
+ sn_comparator_t *c = sn_comparator_create (j - 1, j);
+ sn_network_comparator_add (n, c);
+ sn_comparator_destroy (c);
+ }
+ }
+
+ sn_network_compress (n);
+ sn_network_write (n, stdout);
+ sn_network_destroy (n);
+
+ return (0);
+} /* int main */
+
+/* vim: set shiftwidth=2 softtabstop=2 : */