3 /* srfi-4.c --- Homogeneous numeric vector datatypes.
5 * Copyright (C) 2001, 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
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.
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.
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
24 #include "libguile/__scm.h"
26 /* Specific procedures.
29 SCM_API SCM
scm_u8vector_p (SCM obj
);
30 SCM_API SCM
scm_make_u8vector (SCM n
, SCM fill
);
31 SCM_API SCM
scm_take_u8vector (scm_t_uint8
*data
, size_t n
);
32 SCM_API SCM
scm_u8vector (SCM l
);
33 SCM_API SCM
scm_u8vector_length (SCM uvec
);
34 SCM_API SCM
scm_u8vector_ref (SCM uvec
, SCM index
);
35 SCM_API SCM
scm_u8vector_set_x (SCM uvec
, SCM index
, SCM value
);
36 SCM_API SCM
scm_u8vector_to_list (SCM uvec
);
37 SCM_API SCM
scm_list_to_u8vector (SCM l
);
38 SCM_API SCM
scm_any_to_u8vector (SCM obj
);
39 SCM_API
const scm_t_uint8
*scm_array_handle_u8_elements (scm_t_array_handle
*h
);
40 SCM_API scm_t_uint8
*scm_array_handle_u8_writable_elements (scm_t_array_handle
*h
);
41 SCM_API
const scm_t_uint8
*scm_u8vector_elements (SCM uvec
,
42 scm_t_array_handle
*h
,
43 size_t *lenp
, ssize_t
*incp
);
44 SCM_API scm_t_uint8
*scm_u8vector_writable_elements (SCM uvec
,
45 scm_t_array_handle
*h
,
49 SCM_API SCM
scm_s8vector_p (SCM obj
);
50 SCM_API SCM
scm_make_s8vector (SCM n
, SCM fill
);
51 SCM_API SCM
scm_take_s8vector (scm_t_int8
*data
, size_t n
);
52 SCM_API SCM
scm_s8vector (SCM l
);
53 SCM_API SCM
scm_s8vector_length (SCM uvec
);
54 SCM_API SCM
scm_s8vector_ref (SCM uvec
, SCM index
);
55 SCM_API SCM
scm_s8vector_set_x (SCM uvec
, SCM index
, SCM value
);
56 SCM_API SCM
scm_s8vector_to_list (SCM uvec
);
57 SCM_API SCM
scm_list_to_s8vector (SCM l
);
58 SCM_API SCM
scm_any_to_s8vector (SCM obj
);
59 SCM_API
const scm_t_int8
*scm_array_handle_s8_elements (scm_t_array_handle
*h
);
60 SCM_API scm_t_int8
*scm_array_handle_s8_writable_elements (scm_t_array_handle
*h
);
61 SCM_API
const scm_t_int8
*scm_s8vector_elements (SCM uvec
,
62 scm_t_array_handle
*h
,
63 size_t *lenp
, ssize_t
*incp
);
64 SCM_API scm_t_int8
*scm_s8vector_writable_elements (SCM uvec
,
65 scm_t_array_handle
*h
,
69 SCM_API SCM
scm_u16vector_p (SCM obj
);
70 SCM_API SCM
scm_make_u16vector (SCM n
, SCM fill
);
71 SCM_API SCM
scm_take_u16vector (scm_t_uint16
*data
, size_t n
);
72 SCM_API SCM
scm_u16vector (SCM l
);
73 SCM_API SCM
scm_u16vector_length (SCM uvec
);
74 SCM_API SCM
scm_u16vector_ref (SCM uvec
, SCM index
);
75 SCM_API SCM
scm_u16vector_set_x (SCM uvec
, SCM index
, SCM value
);
76 SCM_API SCM
scm_u16vector_to_list (SCM uvec
);
77 SCM_API SCM
scm_list_to_u16vector (SCM l
);
78 SCM_API SCM
scm_any_to_u16vector (SCM obj
);
79 SCM_API
const scm_t_uint16
*scm_array_handle_u16_elements (scm_t_array_handle
*h
);
80 SCM_API scm_t_uint16
*scm_array_handle_u16_writable_elements (scm_t_array_handle
*h
);
81 SCM_API
const scm_t_uint16
*scm_u16vector_elements (SCM uvec
,
82 scm_t_array_handle
*h
,
85 SCM_API scm_t_uint16
*scm_u16vector_writable_elements (SCM uvec
,
86 scm_t_array_handle
*h
,
90 SCM_API SCM
scm_s16vector_p (SCM obj
);
91 SCM_API SCM
scm_make_s16vector (SCM n
, SCM fill
);
92 SCM_API SCM
scm_take_s16vector (scm_t_int16
*data
, size_t n
);
93 SCM_API SCM
scm_s16vector (SCM l
);
94 SCM_API SCM
scm_s16vector_length (SCM uvec
);
95 SCM_API SCM
scm_s16vector_ref (SCM uvec
, SCM index
);
96 SCM_API SCM
scm_s16vector_set_x (SCM uvec
, SCM index
, SCM value
);
97 SCM_API SCM
scm_s16vector_to_list (SCM uvec
);
98 SCM_API SCM
scm_list_to_s16vector (SCM l
);
99 SCM_API SCM
scm_any_to_s16vector (SCM obj
);
100 SCM_API
const scm_t_int16
*scm_array_handle_s16_elements (scm_t_array_handle
*h
);
101 SCM_API scm_t_int16
*scm_array_handle_s16_writable_elements (scm_t_array_handle
*h
);
102 SCM_API
const scm_t_int16
*scm_s16vector_elements (SCM uvec
,
103 scm_t_array_handle
*h
,
104 size_t *lenp
, ssize_t
*incp
);
105 SCM_API scm_t_int16
*scm_s16vector_writable_elements (SCM uvec
,
106 scm_t_array_handle
*h
,
110 SCM_API SCM
scm_u32vector_p (SCM obj
);
111 SCM_API SCM
scm_make_u32vector (SCM n
, SCM fill
);
112 SCM_API SCM
scm_take_u32vector (scm_t_uint32
*data
, size_t n
);
113 SCM_API SCM
scm_u32vector (SCM l
);
114 SCM_API SCM
scm_u32vector_length (SCM uvec
);
115 SCM_API SCM
scm_u32vector_ref (SCM uvec
, SCM index
);
116 SCM_API SCM
scm_u32vector_set_x (SCM uvec
, SCM index
, SCM value
);
117 SCM_API SCM
scm_u32vector_to_list (SCM uvec
);
118 SCM_API SCM
scm_list_to_u32vector (SCM l
);
119 SCM_API SCM
scm_any_to_u32vector (SCM obj
);
120 SCM_API
const scm_t_uint32
*scm_array_handle_u32_elements (scm_t_array_handle
*h
);
121 SCM_API scm_t_uint32
*scm_array_handle_u32_writable_elements (scm_t_array_handle
*h
);
122 SCM_API
const scm_t_uint32
*scm_u32vector_elements (SCM uvec
,
123 scm_t_array_handle
*h
,
126 SCM_API scm_t_uint32
*scm_u32vector_writable_elements (SCM uvec
,
127 scm_t_array_handle
*h
,
131 SCM_API SCM
scm_s32vector_p (SCM obj
);
132 SCM_API SCM
scm_make_s32vector (SCM n
, SCM fill
);
133 SCM_API SCM
scm_take_s32vector (scm_t_int32
*data
, size_t n
);
134 SCM_API SCM
scm_s32vector (SCM l
);
135 SCM_API SCM
scm_s32vector_length (SCM uvec
);
136 SCM_API SCM
scm_s32vector_ref (SCM uvec
, SCM index
);
137 SCM_API SCM
scm_s32vector_set_x (SCM uvec
, SCM index
, SCM value
);
138 SCM_API SCM
scm_s32vector_to_list (SCM uvec
);
139 SCM_API SCM
scm_list_to_s32vector (SCM l
);
140 SCM_API SCM
scm_any_to_s32vector (SCM obj
);
141 SCM_API
const scm_t_int32
*scm_array_handle_s32_elements (scm_t_array_handle
*h
);
142 SCM_API scm_t_int32
*scm_array_handle_s32_writable_elements (scm_t_array_handle
*h
);
143 SCM_API
const scm_t_int32
*scm_s32vector_elements (SCM uvec
,
144 scm_t_array_handle
*h
,
145 size_t *lenp
, ssize_t
*incp
);
146 SCM_API scm_t_int32
*scm_s32vector_writable_elements (SCM uvec
,
147 scm_t_array_handle
*h
,
151 SCM_API SCM
scm_u64vector_p (SCM obj
);
152 SCM_API SCM
scm_make_u64vector (SCM n
, SCM fill
);
153 SCM_API SCM
scm_u64vector (SCM l
);
154 SCM_API SCM
scm_u64vector_length (SCM uvec
);
155 SCM_API SCM
scm_u64vector_ref (SCM uvec
, SCM index
);
156 SCM_API SCM
scm_u64vector_set_x (SCM uvec
, SCM index
, SCM value
);
157 SCM_API SCM
scm_u64vector_to_list (SCM uvec
);
158 SCM_API SCM
scm_list_to_u64vector (SCM l
);
159 SCM_API SCM
scm_any_to_u64vector (SCM obj
);
161 #if SCM_HAVE_T_UINT64
162 SCM_API SCM
scm_take_u64vector (scm_t_uint64
*data
, size_t n
);
163 SCM_API
const scm_t_uint64
*scm_array_handle_u64_elements (scm_t_array_handle
*h
);
164 SCM_API scm_t_uint64
*scm_array_handle_u64_writable_elements (scm_t_array_handle
*h
);
165 SCM_API
const scm_t_uint64
*scm_u64vector_elements (SCM uvec
,
166 scm_t_array_handle
*h
,
169 SCM_API scm_t_uint64
*scm_u64vector_writable_elements (SCM uvec
,
170 scm_t_array_handle
*h
,
175 SCM_API SCM
scm_s64vector_p (SCM obj
);
176 SCM_API SCM
scm_make_s64vector (SCM n
, SCM fill
);
177 SCM_API SCM
scm_s64vector (SCM l
);
178 SCM_API SCM
scm_s64vector_length (SCM uvec
);
179 SCM_API SCM
scm_s64vector_ref (SCM uvec
, SCM index
);
180 SCM_API SCM
scm_s64vector_set_x (SCM uvec
, SCM index
, SCM value
);
181 SCM_API SCM
scm_s64vector_to_list (SCM uvec
);
182 SCM_API SCM
scm_list_to_s64vector (SCM l
);
183 SCM_API SCM
scm_any_to_s64vector (SCM obj
);
186 SCM_API SCM
scm_take_s64vector (scm_t_int64
*data
, size_t n
);
187 SCM_API
const scm_t_int64
*scm_array_handle_s64_elements (scm_t_array_handle
*h
);
188 SCM_API scm_t_int64
*scm_array_handle_s64_writable_elements (scm_t_array_handle
*h
);
189 SCM_API
const scm_t_int64
*scm_s64vector_elements (SCM uvec
,
190 scm_t_array_handle
*h
,
191 size_t *lenp
, ssize_t
*incp
);
192 SCM_API scm_t_int64
*scm_s64vector_writable_elements (SCM uvec
,
193 scm_t_array_handle
*h
,
198 SCM_API SCM
scm_f32vector_p (SCM obj
);
199 SCM_API SCM
scm_make_f32vector (SCM n
, SCM fill
);
200 SCM_API SCM
scm_take_f32vector (float *data
, size_t n
);
201 SCM_API SCM
scm_f32vector (SCM l
);
202 SCM_API SCM
scm_f32vector_length (SCM uvec
);
203 SCM_API SCM
scm_f32vector_ref (SCM uvec
, SCM index
);
204 SCM_API SCM
scm_f32vector_set_x (SCM uvec
, SCM index
, SCM value
);
205 SCM_API SCM
scm_f32vector_to_list (SCM uvec
);
206 SCM_API SCM
scm_list_to_f32vector (SCM l
);
207 SCM_API SCM
scm_any_to_f32vector (SCM obj
);
208 SCM_API
const float *scm_array_handle_f32_elements (scm_t_array_handle
*h
);
209 SCM_API
float *scm_array_handle_f32_writable_elements (scm_t_array_handle
*h
);
210 SCM_API
const float *scm_f32vector_elements (SCM uvec
,
211 scm_t_array_handle
*h
,
212 size_t *lenp
, ssize_t
*incp
);
213 SCM_API
float *scm_f32vector_writable_elements (SCM uvec
,
214 scm_t_array_handle
*h
,
218 SCM_API SCM
scm_f64vector_p (SCM obj
);
219 SCM_API SCM
scm_make_f64vector (SCM n
, SCM fill
);
220 SCM_API SCM
scm_take_f64vector (double *data
, size_t n
);
221 SCM_API SCM
scm_f64vector (SCM l
);
222 SCM_API SCM
scm_f64vector_length (SCM uvec
);
223 SCM_API SCM
scm_f64vector_ref (SCM uvec
, SCM index
);
224 SCM_API SCM
scm_f64vector_set_x (SCM uvec
, SCM index
, SCM value
);
225 SCM_API SCM
scm_f64vector_to_list (SCM uvec
);
226 SCM_API SCM
scm_list_to_f64vector (SCM l
);
227 SCM_API SCM
scm_any_to_f64vector (SCM obj
);
228 SCM_API
const double *scm_array_handle_f64_elements (scm_t_array_handle
*h
);
229 SCM_API
double *scm_array_handle_f64_writable_elements (scm_t_array_handle
*h
);
230 SCM_API
const double *scm_f64vector_elements (SCM uvec
,
231 scm_t_array_handle
*h
,
232 size_t *lenp
, ssize_t
*incp
);
233 SCM_API
double *scm_f64vector_writable_elements (SCM uvec
,
234 scm_t_array_handle
*h
,
238 SCM_API SCM
scm_c32vector_p (SCM obj
);
239 SCM_API SCM
scm_make_c32vector (SCM n
, SCM fill
);
240 SCM_API SCM
scm_take_c32vector (float *data
, size_t n
);
241 SCM_API SCM
scm_c32vector (SCM l
);
242 SCM_API SCM
scm_c32vector_length (SCM uvec
);
243 SCM_API SCM
scm_c32vector_ref (SCM uvec
, SCM index
);
244 SCM_API SCM
scm_c32vector_set_x (SCM uvec
, SCM index
, SCM value
);
245 SCM_API SCM
scm_c32vector_to_list (SCM uvec
);
246 SCM_API SCM
scm_list_to_c32vector (SCM l
);
247 SCM_API SCM
scm_any_to_c32vector (SCM obj
);
248 SCM_API
const float *scm_array_handle_c32_elements (scm_t_array_handle
*h
);
249 SCM_API
float *scm_array_handle_c32_writable_elements (scm_t_array_handle
*h
);
250 SCM_API
const float *scm_c32vector_elements (SCM uvec
,
251 scm_t_array_handle
*h
,
252 size_t *lenp
, ssize_t
*incp
);
253 SCM_API
float *scm_c32vector_writable_elements (SCM uvec
,
254 scm_t_array_handle
*h
,
258 SCM_API SCM
scm_c64vector_p (SCM obj
);
259 SCM_API SCM
scm_make_c64vector (SCM n
, SCM fill
);
260 SCM_API SCM
scm_take_c64vector (double *data
, size_t n
);
261 SCM_API SCM
scm_c64vector (SCM l
);
262 SCM_API SCM
scm_c64vector_length (SCM uvec
);
263 SCM_API SCM
scm_c64vector_ref (SCM uvec
, SCM index
);
264 SCM_API SCM
scm_c64vector_set_x (SCM uvec
, SCM index
, SCM value
);
265 SCM_API SCM
scm_c64vector_to_list (SCM uvec
);
266 SCM_API SCM
scm_list_to_c64vector (SCM l
);
267 SCM_API SCM
scm_any_to_c64vector (SCM obj
);
268 SCM_API
const double *scm_array_handle_c64_elements (scm_t_array_handle
*h
);
269 SCM_API
double *scm_array_handle_c64_writable_elements (scm_t_array_handle
*h
);
270 SCM_API
const double *scm_c64vector_elements (SCM uvec
,
271 scm_t_array_handle
*h
,
272 size_t *lenp
, ssize_t
*incp
);
273 SCM_API
double *scm_c64vector_writable_elements (SCM uvec
,
274 scm_t_array_handle
*h
,
278 SCM_INTERNAL SCM
scm_i_generalized_vector_type (SCM vec
);
279 SCM_INTERNAL
const char *scm_i_uniform_vector_tag (SCM uvec
);
280 SCM_INTERNAL scm_i_t_array_ref
scm_i_uniform_vector_ref_proc (SCM uvec
);
281 SCM_INTERNAL scm_i_t_array_set
scm_i_uniform_vector_set_proc (SCM uvec
);
283 #if SCM_ENABLE_DEPRECATED
285 /* Deprecated because we want people to use the scm_t_array_handle
289 SCM_DEPRECATED
size_t scm_uniform_element_size (SCM obj
);
293 SCM_INTERNAL
void scm_init_srfi_4 (void);
295 #endif /* SCM_SRFI_4_H */