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