srfi-4.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. #ifndef SCM_SRFI_4_H
  2. #define SCM_SRFI_4_H
  3. /* srfi-4.c --- Homogeneous numeric vector datatypes.
  4. *
  5. * Copyright (C) 2001, 2004, 2006, 2008, 2009, 2010, 2011, 2014 Free Software Foundation, Inc.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 3 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include "libguile/__scm.h"
  23. SCM_API SCM scm_make_srfi_4_vector (SCM type, SCM len, SCM fill);
  24. /* Specific procedures.
  25. */
  26. SCM_API SCM scm_u8vector_p (SCM obj);
  27. SCM_API SCM scm_make_u8vector (SCM n, SCM fill);
  28. SCM_API SCM scm_take_u8vector (scm_t_uint8 *data, size_t n);
  29. SCM_API SCM scm_u8vector (SCM l);
  30. SCM_API SCM scm_u8vector_length (SCM uvec);
  31. SCM_API SCM scm_u8vector_ref (SCM uvec, SCM index);
  32. SCM_API SCM scm_u8vector_set_x (SCM uvec, SCM index, SCM value);
  33. SCM_API SCM scm_u8vector_to_list (SCM uvec);
  34. SCM_API SCM scm_list_to_u8vector (SCM l);
  35. SCM_API SCM scm_any_to_u8vector (SCM obj);
  36. SCM_API const scm_t_uint8 *scm_array_handle_u8_elements (scm_t_array_handle *h);
  37. SCM_API scm_t_uint8 *scm_array_handle_u8_writable_elements (scm_t_array_handle *h);
  38. SCM_API const scm_t_uint8 *scm_u8vector_elements (SCM uvec,
  39. scm_t_array_handle *h,
  40. size_t *lenp, ssize_t *incp);
  41. SCM_API scm_t_uint8 *scm_u8vector_writable_elements (SCM uvec,
  42. scm_t_array_handle *h,
  43. size_t *lenp,
  44. ssize_t *incp);
  45. SCM_API SCM scm_s8vector_p (SCM obj);
  46. SCM_API SCM scm_make_s8vector (SCM n, SCM fill);
  47. SCM_API SCM scm_take_s8vector (scm_t_int8 *data, size_t n);
  48. SCM_API SCM scm_s8vector (SCM l);
  49. SCM_API SCM scm_s8vector_length (SCM uvec);
  50. SCM_API SCM scm_s8vector_ref (SCM uvec, SCM index);
  51. SCM_API SCM scm_s8vector_set_x (SCM uvec, SCM index, SCM value);
  52. SCM_API SCM scm_s8vector_to_list (SCM uvec);
  53. SCM_API SCM scm_list_to_s8vector (SCM l);
  54. SCM_API SCM scm_any_to_s8vector (SCM obj);
  55. SCM_API const scm_t_int8 *scm_array_handle_s8_elements (scm_t_array_handle *h);
  56. SCM_API scm_t_int8 *scm_array_handle_s8_writable_elements (scm_t_array_handle *h);
  57. SCM_API const scm_t_int8 *scm_s8vector_elements (SCM uvec,
  58. scm_t_array_handle *h,
  59. size_t *lenp, ssize_t *incp);
  60. SCM_API scm_t_int8 *scm_s8vector_writable_elements (SCM uvec,
  61. scm_t_array_handle *h,
  62. size_t *lenp,
  63. ssize_t *incp);
  64. SCM_API SCM scm_u16vector_p (SCM obj);
  65. SCM_API SCM scm_make_u16vector (SCM n, SCM fill);
  66. SCM_API SCM scm_take_u16vector (scm_t_uint16 *data, size_t n);
  67. SCM_API SCM scm_u16vector (SCM l);
  68. SCM_API SCM scm_u16vector_length (SCM uvec);
  69. SCM_API SCM scm_u16vector_ref (SCM uvec, SCM index);
  70. SCM_API SCM scm_u16vector_set_x (SCM uvec, SCM index, SCM value);
  71. SCM_API SCM scm_u16vector_to_list (SCM uvec);
  72. SCM_API SCM scm_list_to_u16vector (SCM l);
  73. SCM_API SCM scm_any_to_u16vector (SCM obj);
  74. SCM_API const scm_t_uint16 *scm_array_handle_u16_elements (scm_t_array_handle *h);
  75. SCM_API scm_t_uint16 *scm_array_handle_u16_writable_elements (scm_t_array_handle *h);
  76. SCM_API const scm_t_uint16 *scm_u16vector_elements (SCM uvec,
  77. scm_t_array_handle *h,
  78. size_t *lenp,
  79. ssize_t *incp);
  80. SCM_API scm_t_uint16 *scm_u16vector_writable_elements (SCM uvec,
  81. scm_t_array_handle *h,
  82. size_t *lenp,
  83. ssize_t *incp);
  84. SCM_API SCM scm_s16vector_p (SCM obj);
  85. SCM_API SCM scm_make_s16vector (SCM n, SCM fill);
  86. SCM_API SCM scm_take_s16vector (scm_t_int16 *data, size_t n);
  87. SCM_API SCM scm_s16vector (SCM l);
  88. SCM_API SCM scm_s16vector_length (SCM uvec);
  89. SCM_API SCM scm_s16vector_ref (SCM uvec, SCM index);
  90. SCM_API SCM scm_s16vector_set_x (SCM uvec, SCM index, SCM value);
  91. SCM_API SCM scm_s16vector_to_list (SCM uvec);
  92. SCM_API SCM scm_list_to_s16vector (SCM l);
  93. SCM_API SCM scm_any_to_s16vector (SCM obj);
  94. SCM_API const scm_t_int16 *scm_array_handle_s16_elements (scm_t_array_handle *h);
  95. SCM_API scm_t_int16 *scm_array_handle_s16_writable_elements (scm_t_array_handle *h);
  96. SCM_API const scm_t_int16 *scm_s16vector_elements (SCM uvec,
  97. scm_t_array_handle *h,
  98. size_t *lenp, ssize_t *incp);
  99. SCM_API scm_t_int16 *scm_s16vector_writable_elements (SCM uvec,
  100. scm_t_array_handle *h,
  101. size_t *lenp,
  102. ssize_t *incp);
  103. SCM_API SCM scm_u32vector_p (SCM obj);
  104. SCM_API SCM scm_make_u32vector (SCM n, SCM fill);
  105. SCM_API SCM scm_take_u32vector (scm_t_uint32 *data, size_t n);
  106. SCM_API SCM scm_u32vector (SCM l);
  107. SCM_API SCM scm_u32vector_length (SCM uvec);
  108. SCM_API SCM scm_u32vector_ref (SCM uvec, SCM index);
  109. SCM_API SCM scm_u32vector_set_x (SCM uvec, SCM index, SCM value);
  110. SCM_API SCM scm_u32vector_to_list (SCM uvec);
  111. SCM_API SCM scm_list_to_u32vector (SCM l);
  112. SCM_API SCM scm_any_to_u32vector (SCM obj);
  113. SCM_API const scm_t_uint32 *scm_array_handle_u32_elements (scm_t_array_handle *h);
  114. SCM_API scm_t_uint32 *scm_array_handle_u32_writable_elements (scm_t_array_handle *h);
  115. SCM_API const scm_t_uint32 *scm_u32vector_elements (SCM uvec,
  116. scm_t_array_handle *h,
  117. size_t *lenp,
  118. ssize_t *incp);
  119. SCM_API scm_t_uint32 *scm_u32vector_writable_elements (SCM uvec,
  120. scm_t_array_handle *h,
  121. size_t *lenp,
  122. ssize_t *incp);
  123. SCM_API SCM scm_s32vector_p (SCM obj);
  124. SCM_API SCM scm_make_s32vector (SCM n, SCM fill);
  125. SCM_API SCM scm_take_s32vector (scm_t_int32 *data, size_t n);
  126. SCM_API SCM scm_s32vector (SCM l);
  127. SCM_API SCM scm_s32vector_length (SCM uvec);
  128. SCM_API SCM scm_s32vector_ref (SCM uvec, SCM index);
  129. SCM_API SCM scm_s32vector_set_x (SCM uvec, SCM index, SCM value);
  130. SCM_API SCM scm_s32vector_to_list (SCM uvec);
  131. SCM_API SCM scm_list_to_s32vector (SCM l);
  132. SCM_API SCM scm_any_to_s32vector (SCM obj);
  133. SCM_API const scm_t_int32 *scm_array_handle_s32_elements (scm_t_array_handle *h);
  134. SCM_API scm_t_int32 *scm_array_handle_s32_writable_elements (scm_t_array_handle *h);
  135. SCM_API const scm_t_int32 *scm_s32vector_elements (SCM uvec,
  136. scm_t_array_handle *h,
  137. size_t *lenp, ssize_t *incp);
  138. SCM_API scm_t_int32 *scm_s32vector_writable_elements (SCM uvec,
  139. scm_t_array_handle *h,
  140. size_t *lenp,
  141. ssize_t *incp);
  142. SCM_API SCM scm_u64vector_p (SCM obj);
  143. SCM_API SCM scm_make_u64vector (SCM n, SCM fill);
  144. SCM_API SCM scm_u64vector (SCM l);
  145. SCM_API SCM scm_u64vector_length (SCM uvec);
  146. SCM_API SCM scm_u64vector_ref (SCM uvec, SCM index);
  147. SCM_API SCM scm_u64vector_set_x (SCM uvec, SCM index, SCM value);
  148. SCM_API SCM scm_u64vector_to_list (SCM uvec);
  149. SCM_API SCM scm_list_to_u64vector (SCM l);
  150. SCM_API SCM scm_any_to_u64vector (SCM obj);
  151. SCM_API SCM scm_take_u64vector (scm_t_uint64 *data, size_t n);
  152. SCM_API const scm_t_uint64 *scm_array_handle_u64_elements (scm_t_array_handle *h);
  153. SCM_API scm_t_uint64 *scm_array_handle_u64_writable_elements (scm_t_array_handle *h);
  154. SCM_API const scm_t_uint64 *scm_u64vector_elements (SCM uvec,
  155. scm_t_array_handle *h,
  156. size_t *lenp,
  157. ssize_t *incp);
  158. SCM_API scm_t_uint64 *scm_u64vector_writable_elements (SCM uvec,
  159. scm_t_array_handle *h,
  160. size_t *lenp,
  161. ssize_t *incp);
  162. SCM_API SCM scm_s64vector_p (SCM obj);
  163. SCM_API SCM scm_make_s64vector (SCM n, SCM fill);
  164. SCM_API SCM scm_s64vector (SCM l);
  165. SCM_API SCM scm_s64vector_length (SCM uvec);
  166. SCM_API SCM scm_s64vector_ref (SCM uvec, SCM index);
  167. SCM_API SCM scm_s64vector_set_x (SCM uvec, SCM index, SCM value);
  168. SCM_API SCM scm_s64vector_to_list (SCM uvec);
  169. SCM_API SCM scm_list_to_s64vector (SCM l);
  170. SCM_API SCM scm_any_to_s64vector (SCM obj);
  171. SCM_API SCM scm_take_s64vector (scm_t_int64 *data, size_t n);
  172. SCM_API const scm_t_int64 *scm_array_handle_s64_elements (scm_t_array_handle *h);
  173. SCM_API scm_t_int64 *scm_array_handle_s64_writable_elements (scm_t_array_handle *h);
  174. SCM_API const scm_t_int64 *scm_s64vector_elements (SCM uvec,
  175. scm_t_array_handle *h,
  176. size_t *lenp, ssize_t *incp);
  177. SCM_API scm_t_int64 *scm_s64vector_writable_elements (SCM uvec,
  178. scm_t_array_handle *h,
  179. size_t *lenp,
  180. ssize_t *incp);
  181. SCM_API SCM scm_f32vector_p (SCM obj);
  182. SCM_API SCM scm_make_f32vector (SCM n, SCM fill);
  183. SCM_API SCM scm_take_f32vector (float *data, size_t n);
  184. SCM_API SCM scm_f32vector (SCM l);
  185. SCM_API SCM scm_f32vector_length (SCM uvec);
  186. SCM_API SCM scm_f32vector_ref (SCM uvec, SCM index);
  187. SCM_API SCM scm_f32vector_set_x (SCM uvec, SCM index, SCM value);
  188. SCM_API SCM scm_f32vector_to_list (SCM uvec);
  189. SCM_API SCM scm_list_to_f32vector (SCM l);
  190. SCM_API SCM scm_any_to_f32vector (SCM obj);
  191. SCM_API const float *scm_array_handle_f32_elements (scm_t_array_handle *h);
  192. SCM_API float *scm_array_handle_f32_writable_elements (scm_t_array_handle *h);
  193. SCM_API const float *scm_f32vector_elements (SCM uvec,
  194. scm_t_array_handle *h,
  195. size_t *lenp, ssize_t *incp);
  196. SCM_API float *scm_f32vector_writable_elements (SCM uvec,
  197. scm_t_array_handle *h,
  198. size_t *lenp,
  199. ssize_t *incp);
  200. SCM_API SCM scm_f64vector_p (SCM obj);
  201. SCM_API SCM scm_make_f64vector (SCM n, SCM fill);
  202. SCM_API SCM scm_take_f64vector (double *data, size_t n);
  203. SCM_API SCM scm_f64vector (SCM l);
  204. SCM_API SCM scm_f64vector_length (SCM uvec);
  205. SCM_API SCM scm_f64vector_ref (SCM uvec, SCM index);
  206. SCM_API SCM scm_f64vector_set_x (SCM uvec, SCM index, SCM value);
  207. SCM_API SCM scm_f64vector_to_list (SCM uvec);
  208. SCM_API SCM scm_list_to_f64vector (SCM l);
  209. SCM_API SCM scm_any_to_f64vector (SCM obj);
  210. SCM_API const double *scm_array_handle_f64_elements (scm_t_array_handle *h);
  211. SCM_API double *scm_array_handle_f64_writable_elements (scm_t_array_handle *h);
  212. SCM_API const double *scm_f64vector_elements (SCM uvec,
  213. scm_t_array_handle *h,
  214. size_t *lenp, ssize_t *incp);
  215. SCM_API double *scm_f64vector_writable_elements (SCM uvec,
  216. scm_t_array_handle *h,
  217. size_t *lenp,
  218. ssize_t *incp);
  219. SCM_API SCM scm_c32vector_p (SCM obj);
  220. SCM_API SCM scm_make_c32vector (SCM n, SCM fill);
  221. SCM_API SCM scm_take_c32vector (float *data, size_t n);
  222. SCM_API SCM scm_c32vector (SCM l);
  223. SCM_API SCM scm_c32vector_length (SCM uvec);
  224. SCM_API SCM scm_c32vector_ref (SCM uvec, SCM index);
  225. SCM_API SCM scm_c32vector_set_x (SCM uvec, SCM index, SCM value);
  226. SCM_API SCM scm_c32vector_to_list (SCM uvec);
  227. SCM_API SCM scm_list_to_c32vector (SCM l);
  228. SCM_API SCM scm_any_to_c32vector (SCM obj);
  229. SCM_API const float *scm_array_handle_c32_elements (scm_t_array_handle *h);
  230. SCM_API float *scm_array_handle_c32_writable_elements (scm_t_array_handle *h);
  231. SCM_API const float *scm_c32vector_elements (SCM uvec,
  232. scm_t_array_handle *h,
  233. size_t *lenp, ssize_t *incp);
  234. SCM_API float *scm_c32vector_writable_elements (SCM uvec,
  235. scm_t_array_handle *h,
  236. size_t *lenp,
  237. ssize_t *incp);
  238. SCM_API SCM scm_c64vector_p (SCM obj);
  239. SCM_API SCM scm_make_c64vector (SCM n, SCM fill);
  240. SCM_API SCM scm_take_c64vector (double *data, size_t n);
  241. SCM_API SCM scm_c64vector (SCM l);
  242. SCM_API SCM scm_c64vector_length (SCM uvec);
  243. SCM_API SCM scm_c64vector_ref (SCM uvec, SCM index);
  244. SCM_API SCM scm_c64vector_set_x (SCM uvec, SCM index, SCM value);
  245. SCM_API SCM scm_c64vector_to_list (SCM uvec);
  246. SCM_API SCM scm_list_to_c64vector (SCM l);
  247. SCM_API SCM scm_any_to_c64vector (SCM obj);
  248. SCM_API const double *scm_array_handle_c64_elements (scm_t_array_handle *h);
  249. SCM_API double *scm_array_handle_c64_writable_elements (scm_t_array_handle *h);
  250. SCM_API const double *scm_c64vector_elements (SCM uvec,
  251. scm_t_array_handle *h,
  252. size_t *lenp, ssize_t *incp);
  253. SCM_API double *scm_c64vector_writable_elements (SCM uvec,
  254. scm_t_array_handle *h,
  255. size_t *lenp,
  256. ssize_t *incp);
  257. SCM_INTERNAL void scm_init_srfi_4 (void);
  258. #endif /* SCM_SRFI_4_H */