1 /* matrix/gsl_matrix_complex_float.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Gerard Jungman, Brian Gough
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.
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.
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.
20 #ifndef __GSL_MATRIX_COMPLEX_FLOAT_H__
21 #define __GSL_MATRIX_COMPLEX_FLOAT_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_complex_float.h>
33 # define __BEGIN_DECLS extern "C" {
34 # define __END_DECLS }
36 # define __BEGIN_DECLS /* empty */
37 # define __END_DECLS /* empty */
48 gsl_block_complex_float * block;
50 } gsl_matrix_complex_float ;
54 gsl_matrix_complex_float matrix;
55 } _gsl_matrix_complex_float_view;
57 typedef _gsl_matrix_complex_float_view gsl_matrix_complex_float_view;
61 gsl_matrix_complex_float matrix;
62 } _gsl_matrix_complex_float_const_view;
64 typedef const _gsl_matrix_complex_float_const_view gsl_matrix_complex_float_const_view;
69 gsl_matrix_complex_float *
70 gsl_matrix_complex_float_alloc (const size_t n1, const size_t n2);
72 gsl_matrix_complex_float *
73 gsl_matrix_complex_float_calloc (const size_t n1, const size_t n2);
75 gsl_matrix_complex_float *
76 gsl_matrix_complex_float_alloc_from_block (gsl_block_complex_float * b,
78 const size_t n1, const size_t n2, const size_t d2);
80 gsl_matrix_complex_float *
81 gsl_matrix_complex_float_alloc_from_matrix (gsl_matrix_complex_float * b,
82 const size_t k1, const size_t k2,
83 const size_t n1, const size_t n2);
85 gsl_vector_complex_float *
86 gsl_vector_complex_float_alloc_row_from_matrix (gsl_matrix_complex_float * m,
89 gsl_vector_complex_float *
90 gsl_vector_complex_float_alloc_col_from_matrix (gsl_matrix_complex_float * m,
93 void gsl_matrix_complex_float_free (gsl_matrix_complex_float * m);
97 _gsl_matrix_complex_float_view
98 gsl_matrix_complex_float_submatrix (gsl_matrix_complex_float * m,
99 const size_t i, const size_t j,
100 const size_t n1, const size_t n2);
102 _gsl_vector_complex_float_view
103 gsl_matrix_complex_float_row (gsl_matrix_complex_float * m, const size_t i);
105 _gsl_vector_complex_float_view
106 gsl_matrix_complex_float_column (gsl_matrix_complex_float * m, const size_t j);
108 _gsl_vector_complex_float_view
109 gsl_matrix_complex_float_diagonal (gsl_matrix_complex_float * m);
111 _gsl_vector_complex_float_view
112 gsl_matrix_complex_float_subdiagonal (gsl_matrix_complex_float * m, const size_t k);
114 _gsl_vector_complex_float_view
115 gsl_matrix_complex_float_superdiagonal (gsl_matrix_complex_float * m, const size_t k);
117 _gsl_vector_complex_float_view
118 gsl_matrix_complex_float_subrow (gsl_matrix_complex_float * m,
119 const size_t i, const size_t offset,
122 _gsl_vector_complex_float_view
123 gsl_matrix_complex_float_subcolumn (gsl_matrix_complex_float * m,
124 const size_t j, const size_t offset,
127 _gsl_matrix_complex_float_view
128 gsl_matrix_complex_float_view_array (float * base,
132 _gsl_matrix_complex_float_view
133 gsl_matrix_complex_float_view_array_with_tda (float * base,
138 _gsl_matrix_complex_float_view
139 gsl_matrix_complex_float_view_vector (gsl_vector_complex_float * v,
143 _gsl_matrix_complex_float_view
144 gsl_matrix_complex_float_view_vector_with_tda (gsl_vector_complex_float * v,
150 _gsl_matrix_complex_float_const_view
151 gsl_matrix_complex_float_const_submatrix (const gsl_matrix_complex_float * m,
152 const size_t i, const size_t j,
153 const size_t n1, const size_t n2);
155 _gsl_vector_complex_float_const_view
156 gsl_matrix_complex_float_const_row (const gsl_matrix_complex_float * m,
159 _gsl_vector_complex_float_const_view
160 gsl_matrix_complex_float_const_column (const gsl_matrix_complex_float * m,
163 _gsl_vector_complex_float_const_view
164 gsl_matrix_complex_float_const_diagonal (const gsl_matrix_complex_float * m);
166 _gsl_vector_complex_float_const_view
167 gsl_matrix_complex_float_const_subdiagonal (const gsl_matrix_complex_float * m,
170 _gsl_vector_complex_float_const_view
171 gsl_matrix_complex_float_const_superdiagonal (const gsl_matrix_complex_float * m,
174 _gsl_vector_complex_float_const_view
175 gsl_matrix_complex_float_const_subrow (const gsl_matrix_complex_float * m,
176 const size_t i, const size_t offset,
179 _gsl_vector_complex_float_const_view
180 gsl_matrix_complex_float_const_subcolumn (const gsl_matrix_complex_float * m,
181 const size_t j, const size_t offset,
184 _gsl_matrix_complex_float_const_view
185 gsl_matrix_complex_float_const_view_array (const float * base,
189 _gsl_matrix_complex_float_const_view
190 gsl_matrix_complex_float_const_view_array_with_tda (const float * base,
195 _gsl_matrix_complex_float_const_view
196 gsl_matrix_complex_float_const_view_vector (const gsl_vector_complex_float * v,
200 _gsl_matrix_complex_float_const_view
201 gsl_matrix_complex_float_const_view_vector_with_tda (const gsl_vector_complex_float * v,
208 gsl_complex_float gsl_matrix_complex_float_get(const gsl_matrix_complex_float * m, const size_t i, const size_t j);
209 void gsl_matrix_complex_float_set(gsl_matrix_complex_float * m, const size_t i, const size_t j, const gsl_complex_float x);
211 gsl_complex_float * gsl_matrix_complex_float_ptr(gsl_matrix_complex_float * m, const size_t i, const size_t j);
212 const gsl_complex_float * gsl_matrix_complex_float_const_ptr(const gsl_matrix_complex_float * m, const size_t i, const size_t j);
214 void gsl_matrix_complex_float_set_zero (gsl_matrix_complex_float * m);
215 void gsl_matrix_complex_float_set_identity (gsl_matrix_complex_float * m);
216 void gsl_matrix_complex_float_set_all (gsl_matrix_complex_float * m, gsl_complex_float x);
218 int gsl_matrix_complex_float_fread (FILE * stream, gsl_matrix_complex_float * m) ;
219 int gsl_matrix_complex_float_fwrite (FILE * stream, const gsl_matrix_complex_float * m) ;
220 int gsl_matrix_complex_float_fscanf (FILE * stream, gsl_matrix_complex_float * m);
221 int gsl_matrix_complex_float_fprintf (FILE * stream, const gsl_matrix_complex_float * m, const char * format);
223 int gsl_matrix_complex_float_memcpy(gsl_matrix_complex_float * dest, const gsl_matrix_complex_float * src);
224 int gsl_matrix_complex_float_swap(gsl_matrix_complex_float * m1, gsl_matrix_complex_float * m2);
226 int gsl_matrix_complex_float_swap_rows(gsl_matrix_complex_float * m, const size_t i, const size_t j);
227 int gsl_matrix_complex_float_swap_columns(gsl_matrix_complex_float * m, const size_t i, const size_t j);
228 int gsl_matrix_complex_float_swap_rowcol(gsl_matrix_complex_float * m, const size_t i, const size_t j);
230 int gsl_matrix_complex_float_transpose (gsl_matrix_complex_float * m);
231 int gsl_matrix_complex_float_transpose_memcpy (gsl_matrix_complex_float * dest, const gsl_matrix_complex_float * src);
233 int gsl_matrix_complex_float_isnull (const gsl_matrix_complex_float * m);
234 int gsl_matrix_complex_float_ispos (const gsl_matrix_complex_float * m);
235 int gsl_matrix_complex_float_isneg (const gsl_matrix_complex_float * m);
237 int gsl_matrix_complex_float_add (gsl_matrix_complex_float * a, const gsl_matrix_complex_float * b);
238 int gsl_matrix_complex_float_sub (gsl_matrix_complex_float * a, const gsl_matrix_complex_float * b);
239 int gsl_matrix_complex_float_mul_elements (gsl_matrix_complex_float * a, const gsl_matrix_complex_float * b);
240 int gsl_matrix_complex_float_div_elements (gsl_matrix_complex_float * a, const gsl_matrix_complex_float * b);
241 int gsl_matrix_complex_float_scale (gsl_matrix_complex_float * a, const gsl_complex_float x);
242 int gsl_matrix_complex_float_add_constant (gsl_matrix_complex_float * a, const gsl_complex_float x);
243 int gsl_matrix_complex_float_add_diagonal (gsl_matrix_complex_float * a, const gsl_complex_float x);
245 /***********************************************************************/
246 /* The functions below are obsolete */
247 /***********************************************************************/
248 int gsl_matrix_complex_float_get_row(gsl_vector_complex_float * v, const gsl_matrix_complex_float * m, const size_t i);
249 int gsl_matrix_complex_float_get_col(gsl_vector_complex_float * v, const gsl_matrix_complex_float * m, const size_t j);
250 int gsl_matrix_complex_float_set_row(gsl_matrix_complex_float * m, const size_t i, const gsl_vector_complex_float * v);
251 int gsl_matrix_complex_float_set_col(gsl_matrix_complex_float * m, const size_t j, const gsl_vector_complex_float * v);
257 gsl_matrix_complex_float_get(const gsl_matrix_complex_float * m,
258 const size_t i, const size_t j)
261 gsl_complex_float zero = {{0,0}};
265 GSL_ERROR_VAL("first index out of range", GSL_EINVAL, zero) ;
267 else if (j >= m->size2)
269 GSL_ERROR_VAL("second index out of range", GSL_EINVAL, zero) ;
272 return *(gsl_complex_float *)(m->data + 2*(i * m->tda + j)) ;
277 gsl_matrix_complex_float_set(gsl_matrix_complex_float * m,
278 const size_t i, const size_t j, const gsl_complex_float x)
283 GSL_ERROR_VOID("first index out of range", GSL_EINVAL) ;
285 else if (j >= m->size2)
287 GSL_ERROR_VOID("second index out of range", GSL_EINVAL) ;
290 *(gsl_complex_float *)(m->data + 2*(i * m->tda + j)) = x ;
295 gsl_matrix_complex_float_ptr(gsl_matrix_complex_float * m,
296 const size_t i, const size_t j)
301 GSL_ERROR_NULL("first index out of range", GSL_EINVAL) ;
303 else if (j >= m->size2)
305 GSL_ERROR_NULL("second index out of range", GSL_EINVAL) ;
308 return (gsl_complex_float *)(m->data + 2*(i * m->tda + j)) ;
312 const gsl_complex_float *
313 gsl_matrix_complex_float_const_ptr(const gsl_matrix_complex_float * m,
314 const size_t i, const size_t j)
319 GSL_ERROR_NULL("first index out of range", GSL_EINVAL) ;
321 else if (j >= m->size2)
323 GSL_ERROR_NULL("second index out of range", GSL_EINVAL) ;
326 return (const gsl_complex_float *)(m->data + 2*(i * m->tda + j)) ;
329 #endif /* HAVE_INLINE */
333 #endif /* __GSL_MATRIX_COMPLEX_FLOAT_H__ */