Added MACS source
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / vector / gsl_vector_complex_double.h
1 /* vector/gsl_vector_complex_double.h
2  * 
3  * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, 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 #ifndef __GSL_VECTOR_COMPLEX_DOUBLE_H__
21 #define __GSL_VECTOR_COMPLEX_DOUBLE_H__
22
23 #include <stdlib.h>
24 #include <gsl/gsl_types.h>
25 #include <gsl/gsl_errno.h>
26 #include <gsl/gsl_complex.h>
27 #include <gsl/gsl_check_range.h>
28 #include <gsl/gsl_vector_double.h>
29 #include <gsl/gsl_vector_complex.h>
30 #include <gsl/gsl_block_complex_double.h>
31
32 #undef __BEGIN_DECLS
33 #undef __END_DECLS
34 #ifdef __cplusplus
35 # define __BEGIN_DECLS extern "C" {
36 # define __END_DECLS }
37 #else
38 # define __BEGIN_DECLS /* empty */
39 # define __END_DECLS /* empty */
40 #endif
41
42 __BEGIN_DECLS
43
44 typedef struct 
45 {
46   size_t size;
47   size_t stride;
48   double *data;
49   gsl_block_complex *block;
50   int owner;
51 } gsl_vector_complex;
52
53 typedef struct
54 {
55   gsl_vector_complex vector;
56 } _gsl_vector_complex_view;
57
58 typedef _gsl_vector_complex_view gsl_vector_complex_view;
59
60 typedef struct
61 {
62   gsl_vector_complex vector;
63 } _gsl_vector_complex_const_view;
64
65 typedef const _gsl_vector_complex_const_view gsl_vector_complex_const_view;
66
67 /* Allocation */
68
69 gsl_vector_complex *gsl_vector_complex_alloc (const size_t n);
70 gsl_vector_complex *gsl_vector_complex_calloc (const size_t n);
71
72 gsl_vector_complex *
73 gsl_vector_complex_alloc_from_block (gsl_block_complex * b, 
74                                            const size_t offset, 
75                                            const size_t n, 
76                                            const size_t stride);
77
78 gsl_vector_complex *
79 gsl_vector_complex_alloc_from_vector (gsl_vector_complex * v, 
80                                              const size_t offset, 
81                                              const size_t n, 
82                                              const size_t stride);
83
84 void gsl_vector_complex_free (gsl_vector_complex * v);
85
86 /* Views */
87
88 _gsl_vector_complex_view
89 gsl_vector_complex_view_array (double *base,
90                                      size_t n);
91
92 _gsl_vector_complex_view
93 gsl_vector_complex_view_array_with_stride (double *base,
94                                                  size_t stride,
95                                                  size_t n);
96
97 _gsl_vector_complex_const_view
98 gsl_vector_complex_const_view_array (const double *base,
99                                            size_t n);
100
101 _gsl_vector_complex_const_view
102 gsl_vector_complex_const_view_array_with_stride (const double *base,
103                                                        size_t stride,
104                                                        size_t n);
105
106 _gsl_vector_complex_view
107 gsl_vector_complex_subvector (gsl_vector_complex *base,
108                                          size_t i, 
109                                          size_t n);
110
111
112 _gsl_vector_complex_view 
113 gsl_vector_complex_subvector_with_stride (gsl_vector_complex *v, 
114                                                 size_t i, 
115                                                 size_t stride, 
116                                                 size_t n);
117
118 _gsl_vector_complex_const_view
119 gsl_vector_complex_const_subvector (const gsl_vector_complex *base,
120                                                size_t i, 
121                                                size_t n);
122
123
124 _gsl_vector_complex_const_view 
125 gsl_vector_complex_const_subvector_with_stride (const gsl_vector_complex *v, 
126                                                       size_t i, 
127                                                       size_t stride, 
128                                                       size_t n);
129
130 _gsl_vector_view
131 gsl_vector_complex_real (gsl_vector_complex *v);
132
133 _gsl_vector_view 
134 gsl_vector_complex_imag (gsl_vector_complex *v);
135
136 _gsl_vector_const_view
137 gsl_vector_complex_const_real (const gsl_vector_complex *v);
138
139 _gsl_vector_const_view 
140 gsl_vector_complex_const_imag (const gsl_vector_complex *v);
141
142
143 /* Operations */
144
145 gsl_complex 
146 gsl_vector_complex_get (const gsl_vector_complex * v, const size_t i);
147
148 void gsl_vector_complex_set (gsl_vector_complex * v, const size_t i,
149                                    gsl_complex z);
150
151 gsl_complex 
152 *gsl_vector_complex_ptr (gsl_vector_complex * v, const size_t i);
153
154 const gsl_complex 
155 *gsl_vector_complex_const_ptr (const gsl_vector_complex * v, const size_t i);
156
157 void gsl_vector_complex_set_zero (gsl_vector_complex * v);
158 void gsl_vector_complex_set_all (gsl_vector_complex * v,
159                                        gsl_complex z);
160 int gsl_vector_complex_set_basis (gsl_vector_complex * v, size_t i);
161
162 int gsl_vector_complex_fread (FILE * stream,
163                                     gsl_vector_complex * v);
164 int gsl_vector_complex_fwrite (FILE * stream,
165                                      const gsl_vector_complex * v);
166 int gsl_vector_complex_fscanf (FILE * stream,
167                                      gsl_vector_complex * v);
168 int gsl_vector_complex_fprintf (FILE * stream,
169                                       const gsl_vector_complex * v,
170                                       const char *format);
171
172 int gsl_vector_complex_memcpy (gsl_vector_complex * dest, const gsl_vector_complex * src);
173
174 int gsl_vector_complex_reverse (gsl_vector_complex * v);
175
176 int gsl_vector_complex_swap (gsl_vector_complex * v, gsl_vector_complex * w);
177 int gsl_vector_complex_swap_elements (gsl_vector_complex * v, const size_t i, const size_t j);
178
179 int gsl_vector_complex_isnull (const gsl_vector_complex * v);
180 int gsl_vector_complex_ispos (const gsl_vector_complex * v);
181 int gsl_vector_complex_isneg (const gsl_vector_complex * v);
182
183 #ifdef HAVE_INLINE
184
185 extern inline
186 gsl_complex
187 gsl_vector_complex_get (const gsl_vector_complex * v,
188                               const size_t i)
189 {
190 #if GSL_RANGE_CHECK
191   if (i >= v->size)
192     {
193       gsl_complex zero = {{0, 0}};
194       GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero);
195     }
196 #endif
197   return *GSL_COMPLEX_AT (v, i);
198 }
199
200 extern inline
201 void
202 gsl_vector_complex_set (gsl_vector_complex * v,
203                               const size_t i, gsl_complex z)
204 {
205 #if GSL_RANGE_CHECK
206   if (i >= v->size)
207     {
208       GSL_ERROR_VOID ("index out of range", GSL_EINVAL);
209     }
210 #endif
211   *GSL_COMPLEX_AT (v, i) = z;
212 }
213
214 extern inline
215 gsl_complex *
216 gsl_vector_complex_ptr (gsl_vector_complex * v,
217                               const size_t i)
218 {
219 #if GSL_RANGE_CHECK
220   if (i >= v->size)
221     {
222       GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
223     }
224 #endif
225   return GSL_COMPLEX_AT (v, i);
226 }
227
228 extern inline
229 const gsl_complex *
230 gsl_vector_complex_const_ptr (const gsl_vector_complex * v,
231                                     const size_t i)
232 {
233 #if GSL_RANGE_CHECK
234   if (i >= v->size)
235     {
236       GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
237     }
238 #endif
239   return GSL_COMPLEX_AT (v, i);
240 }
241
242
243 #endif /* HAVE_INLINE */
244
245 __END_DECLS
246
247 #endif /* __GSL_VECTOR_COMPLEX_DOUBLE_H__ */