Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / sort / test.c
1 /* sort/test.c
2  * 
3  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Thomas Walter, Brian Gough
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or (at
8  * your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #include <config.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <gsl/gsl_math.h>
24 #include <gsl/gsl_errno.h>
25 #include <gsl/gsl_test.h>
26 #include <gsl/gsl_heapsort.h>
27 #include <gsl/gsl_sort.h>
28 #include <gsl/gsl_sort_vector.h>
29 #include <gsl/gsl_ieee_utils.h>
30
31 size_t urand (size_t);
32
33 #include "test_heapsort.c"
34
35 #define BASE_LONG_DOUBLE
36 #include "templates_on.h"
37 #include "test_source.c"
38 #include "templates_off.h"
39 #undef  BASE_LONG_DOUBLE
40
41 #define BASE_DOUBLE
42 #include "templates_on.h"
43 #include "test_source.c"
44 #include "templates_off.h"
45 #undef  BASE_DOUBLE
46
47 #define BASE_FLOAT
48 #include "templates_on.h"
49 #include "test_source.c"
50 #include "templates_off.h"
51 #undef  BASE_FLOAT
52
53 #define BASE_ULONG
54 #include "templates_on.h"
55 #include "test_source.c"
56 #include "templates_off.h"
57 #undef  BASE_ULONG
58
59 #define BASE_LONG
60 #include "templates_on.h"
61 #include "test_source.c"
62 #include "templates_off.h"
63 #undef  BASE_LONG
64
65 #define BASE_UINT
66 #include "templates_on.h"
67 #include "test_source.c"
68 #include "templates_off.h"
69 #undef  BASE_UINT
70
71 #define BASE_INT
72 #include "templates_on.h"
73 #include "test_source.c"
74 #include "templates_off.h"
75 #undef  BASE_INT
76
77 #define BASE_USHORT
78 #include "templates_on.h"
79 #include "test_source.c"
80 #include "templates_off.h"
81 #undef  BASE_USHORT
82
83 #define BASE_SHORT
84 #include "templates_on.h"
85 #include "test_source.c"
86 #include "templates_off.h"
87 #undef  BASE_SHORT
88
89 #define BASE_UCHAR
90 #include "templates_on.h"
91 #include "test_source.c"
92 #include "templates_off.h"
93 #undef  BASE_UCHAR
94
95 #define BASE_CHAR
96 #include "templates_on.h"
97 #include "test_source.c"
98 #include "templates_off.h"
99 #undef  BASE_CHAR
100
101 int
102 main (void)
103 {
104   size_t i, s;
105
106   gsl_ieee_env_setup ();
107
108   /* Test for lengths of 1 ... 31, then 32, 64, 128, 256, ... */
109
110   for (i = 1; i < 1024; i = (i < 32) ? i + 1 : 2 * i)
111     test_heapsort (i);
112
113   for (i = 1; i < 1024; i = (i < 32) ? i + 1 : 2 * i)
114     {
115       for (s = 1; s < 4; s++)
116         {
117           test_sort_vector (i, s);
118           test_sort_vector_float (i, s);
119           test_sort_vector_long_double (i, s);
120           test_sort_vector_ulong (i, s);
121           test_sort_vector_long (i, s);
122           test_sort_vector_uint (i, s);
123           test_sort_vector_int (i, s);
124           test_sort_vector_ushort (i, s);
125           test_sort_vector_short (i, s);
126           test_sort_vector_uchar (i, s);
127           test_sort_vector_char (i, s);
128         }
129     }
130
131   exit (gsl_test_summary ());
132 }
133
134 size_t 
135 urand (size_t N)
136 {
137   static unsigned long int x = 1;
138   x = (1103515245 * x + 12345) & 0x7fffffffUL;
139   return (size_t) ((x / 2147483648.0) * N);
140 }