Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / fft / compare_source.c
1 /* fft/compare_source.c
2  * 
3  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 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 "compare.h"
21
22 int
23 FUNCTION(compare_complex,results) (const char *name_a, const BASE a[],
24                                    const char *name_b, const BASE b[],
25                                    size_t stride, size_t n,
26                                    const double allowed_ticks)
27 {
28   size_t i;
29   double ticks, max_ticks = 0;
30   double dr, di;
31   const char *flag;
32
33   for (i = 0; i < n; i++)
34     {
35       dr = b[2*stride*i] - a[2*stride*i];
36       di = b[2*stride*i+1] - a[2*stride*i+1];
37       ticks = (fabs (dr) + fabs (di)) / BASE_EPSILON;
38       if (ticks > max_ticks)
39         {
40           max_ticks = ticks;
41         }
42     }
43
44   if (max_ticks < allowed_ticks)
45     {
46       return 0;
47     }
48
49   printf ("\n%s vs %s : max_ticks = %f\n", name_a, name_b, max_ticks);
50
51   for (i = 0; i < n; i++)
52     {
53       dr = b[2*stride*i] - a[2*stride*i];
54       di = b[2*stride*i+1] - a[2*stride*i+1];
55       ticks = (fabs (dr) + fabs (di)) / BASE_EPSILON;
56
57       if (ticks > 1000)
58         {
59           flag = "***";
60         }
61       else
62         {
63           flag = "";
64         }
65
66       printf ("%15s: %d  %.16f %.16f %s\n", name_a, (int)i,
67               a[2*stride*i], a[2*stride*i+1], flag);
68       printf ("%15s: %d  %.16f %.16f %e %s\n", name_b, (int)i,
69               b[2*stride*i], b[2*stride*i+1], ticks, flag);
70     }
71
72   return -1;
73 }
74
75
76 int
77 FUNCTION(compare_real,results) (const char *name_a, const BASE a[],
78                                 const char *name_b, const BASE b[],
79                                 size_t stride, size_t n,
80                                 const double allowed_ticks)
81 {
82   size_t i;
83   double ticks, max_ticks = 0;
84   double dr;
85   const char *flag;
86
87   for (i = 0; i < n; i++)
88     {
89       dr = b[stride*i] - a[stride*i];
90       ticks = fabs (dr) / BASE_EPSILON;
91       if (ticks > max_ticks)
92         {
93           max_ticks = ticks;
94         }
95     }
96
97   if (max_ticks < allowed_ticks)
98     {
99       return 0;
100     }
101
102   printf ("\n%s vs %s : max_ticks = %f\n", name_a, name_b, max_ticks);
103
104   for (i = 0; i < n; i++)
105     {
106       dr = b[stride*i] - a[stride*i];
107       ticks = fabs (dr) / BASE_EPSILON;
108
109       if (ticks > 1000)
110         {
111           flag = "***";
112         }
113       else
114         {
115           flag = "";
116         }
117
118       printf ("%15s: %d  %.16f %s\n", name_a, (int)i, 
119               a[stride*i], flag);
120       printf ("%15s: %d  %.16f %e %s\n", name_b, (int)i, 
121               b[stride*i], ticks, flag);
122     }
123
124   return -1;
125 }