gsl_vector_complex_float.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* vector/gsl_vector_complex_float.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. #ifndef __GSL_VECTOR_COMPLEX_FLOAT_H__
  20. #define __GSL_VECTOR_COMPLEX_FLOAT_H__
  21. #include <stdlib.h>
  22. #include "gsl_types.h"
  23. #include "gsl_errno.h"
  24. #include "gsl_complex.h"
  25. #include "gsl_check_range.h"
  26. #include "gsl_vector_float.h"
  27. #include "gsl_vector_complex.h"
  28. #include "gsl_block_complex_float.h"
  29. #undef __BEGIN_DECLS
  30. #undef __END_DECLS
  31. #ifdef __cplusplus
  32. # define __BEGIN_DECLS extern "C" {
  33. # define __END_DECLS }
  34. #else
  35. # define __BEGIN_DECLS /* empty */
  36. # define __END_DECLS /* empty */
  37. #endif
  38. __BEGIN_DECLS
  39. typedef struct
  40. {
  41. size_t size;
  42. size_t stride;
  43. float *data;
  44. gsl_block_complex_float *block;
  45. int owner;
  46. } gsl_vector_complex_float;
  47. typedef struct
  48. {
  49. gsl_vector_complex_float vector;
  50. } _gsl_vector_complex_float_view;
  51. typedef _gsl_vector_complex_float_view gsl_vector_complex_float_view;
  52. typedef struct
  53. {
  54. gsl_vector_complex_float vector;
  55. } _gsl_vector_complex_float_const_view;
  56. typedef const _gsl_vector_complex_float_const_view gsl_vector_complex_float_const_view;
  57. /* Allocation */
  58. gsl_vector_complex_float *gsl_vector_complex_float_alloc (const size_t n);
  59. gsl_vector_complex_float *gsl_vector_complex_float_calloc (const size_t n);
  60. gsl_vector_complex_float *
  61. gsl_vector_complex_float_alloc_from_block (gsl_block_complex_float * b,
  62. const size_t offset,
  63. const size_t n,
  64. const size_t stride);
  65. gsl_vector_complex_float *
  66. gsl_vector_complex_float_alloc_from_vector (gsl_vector_complex_float * v,
  67. const size_t offset,
  68. const size_t n,
  69. const size_t stride);
  70. void gsl_vector_complex_float_free (gsl_vector_complex_float * v);
  71. /* Views */
  72. _gsl_vector_complex_float_view
  73. gsl_vector_complex_float_view_array (float *base,
  74. size_t n);
  75. _gsl_vector_complex_float_view
  76. gsl_vector_complex_float_view_array_with_stride (float *base,
  77. size_t stride,
  78. size_t n);
  79. _gsl_vector_complex_float_const_view
  80. gsl_vector_complex_float_const_view_array (const float *base,
  81. size_t n);
  82. _gsl_vector_complex_float_const_view
  83. gsl_vector_complex_float_const_view_array_with_stride (const float *base,
  84. size_t stride,
  85. size_t n);
  86. _gsl_vector_complex_float_view
  87. gsl_vector_complex_float_subvector (gsl_vector_complex_float *base,
  88. size_t i,
  89. size_t n);
  90. _gsl_vector_complex_float_view
  91. gsl_vector_complex_float_subvector_with_stride (gsl_vector_complex_float *v,
  92. size_t i,
  93. size_t stride,
  94. size_t n);
  95. _gsl_vector_complex_float_const_view
  96. gsl_vector_complex_float_const_subvector (const gsl_vector_complex_float *base,
  97. size_t i,
  98. size_t n);
  99. _gsl_vector_complex_float_const_view
  100. gsl_vector_complex_float_const_subvector_with_stride (const gsl_vector_complex_float *v,
  101. size_t i,
  102. size_t stride,
  103. size_t n);
  104. _gsl_vector_float_view
  105. gsl_vector_complex_float_real (gsl_vector_complex_float *v);
  106. _gsl_vector_float_view
  107. gsl_vector_complex_float_imag (gsl_vector_complex_float *v);
  108. _gsl_vector_float_const_view
  109. gsl_vector_complex_float_const_real (const gsl_vector_complex_float *v);
  110. _gsl_vector_float_const_view
  111. gsl_vector_complex_float_const_imag (const gsl_vector_complex_float *v);
  112. /* Operations */
  113. gsl_complex_float
  114. gsl_vector_complex_float_get (const gsl_vector_complex_float * v, const size_t i);
  115. void gsl_vector_complex_float_set (gsl_vector_complex_float * v, const size_t i,
  116. gsl_complex_float z);
  117. gsl_complex_float
  118. *gsl_vector_complex_float_ptr (gsl_vector_complex_float * v, const size_t i);
  119. const gsl_complex_float
  120. *gsl_vector_complex_float_const_ptr (const gsl_vector_complex_float * v, const size_t i);
  121. void gsl_vector_complex_float_set_zero (gsl_vector_complex_float * v);
  122. void gsl_vector_complex_float_set_all (gsl_vector_complex_float * v,
  123. gsl_complex_float z);
  124. int gsl_vector_complex_float_set_basis (gsl_vector_complex_float * v, size_t i);
  125. int gsl_vector_complex_float_fread (FILE * stream,
  126. gsl_vector_complex_float * v);
  127. int gsl_vector_complex_float_fwrite (FILE * stream,
  128. const gsl_vector_complex_float * v);
  129. int gsl_vector_complex_float_fscanf (FILE * stream,
  130. gsl_vector_complex_float * v);
  131. int gsl_vector_complex_float_fprintf (FILE * stream,
  132. const gsl_vector_complex_float * v,
  133. const char *format);
  134. int gsl_vector_complex_float_memcpy (gsl_vector_complex_float * dest, const gsl_vector_complex_float * src);
  135. int gsl_vector_complex_float_reverse (gsl_vector_complex_float * v);
  136. int gsl_vector_complex_float_swap (gsl_vector_complex_float * v, gsl_vector_complex_float * w);
  137. int gsl_vector_complex_float_swap_elements (gsl_vector_complex_float * v, const size_t i, const size_t j);
  138. int gsl_vector_complex_float_isnull (const gsl_vector_complex_float * v);
  139. int gsl_vector_complex_float_ispos (const gsl_vector_complex_float * v);
  140. int gsl_vector_complex_float_isneg (const gsl_vector_complex_float * v);
  141. int gsl_vector_complex_float_isnonneg (const gsl_vector_complex_float * v);
  142. #ifdef HAVE_INLINE
  143. extern inline
  144. gsl_complex_float
  145. gsl_vector_complex_float_get (const gsl_vector_complex_float * v,
  146. const size_t i)
  147. {
  148. #if GSL_RANGE_CHECK
  149. if (i >= v->size)
  150. {
  151. gsl_complex_float zero = {{0, 0}};
  152. GSL_ERROR_VAL ("index out of range", GSL_EINVAL, zero);
  153. }
  154. #endif
  155. return *GSL_COMPLEX_FLOAT_AT (v, i);
  156. }
  157. extern inline
  158. void
  159. gsl_vector_complex_float_set (gsl_vector_complex_float * v,
  160. const size_t i, gsl_complex_float z)
  161. {
  162. #if GSL_RANGE_CHECK
  163. if (i >= v->size)
  164. {
  165. GSL_ERROR_VOID ("index out of range", GSL_EINVAL);
  166. }
  167. #endif
  168. *GSL_COMPLEX_FLOAT_AT (v, i) = z;
  169. }
  170. extern inline
  171. gsl_complex_float *
  172. gsl_vector_complex_float_ptr (gsl_vector_complex_float * v,
  173. const size_t i)
  174. {
  175. #if GSL_RANGE_CHECK
  176. if (i >= v->size)
  177. {
  178. GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
  179. }
  180. #endif
  181. return GSL_COMPLEX_FLOAT_AT (v, i);
  182. }
  183. extern inline
  184. const gsl_complex_float *
  185. gsl_vector_complex_float_const_ptr (const gsl_vector_complex_float * v,
  186. const size_t i)
  187. {
  188. #if GSL_RANGE_CHECK
  189. if (i >= v->size)
  190. {
  191. GSL_ERROR_NULL ("index out of range", GSL_EINVAL);
  192. }
  193. #endif
  194. return GSL_COMPLEX_FLOAT_AT (v, i);
  195. }
  196. #endif /* HAVE_INLINE */
  197. __END_DECLS
  198. #endif /* __GSL_VECTOR_COMPLEX_FLOAT_H__ */