source: project/chicken/trunk/manual/Unit srfi-4 @ 13670

Last change on this file since 13670 was 5945, checked in by felix winkelmann, 13 years ago

renamed some tools in misc/; apply hack fix on x86-64 (again); re-added manual

File size: 5.3 KB
Line 
1[[tags: manual]]
2[[toc:]]
3
4== Unit srfi-4
5
6Homogeneous numeric vectors, see the documentation for [[http://srfi.schemers.org/srfi-4/srfi-4.html|SRFI-4]]
764-bit integer vectors ({{u64vector}} and {{s64vector}} are not supported.
8
9The basic constructor procedures for number vectors are extended to allow allocating the storage in non garbage
10collected memory:
11
12=== make-XXXvector
13
14 [procedure] (make-XXXvector SIZE [INIT NONGC FINALIZE])
15
16Creates a SRFI-4 homogenous number vector of length {{SIZE}}. If {{INIT}} is given, it specifies the initial
17value for each slot in the vector. The optional arguments {{NONGC}} and {{FINALIZE}} define whether the
18vector should be allocated in a memory area not subject to garbage collection and whether the associated storage
19should be automatically freed (using finalization) when there are no references from Scheme variables and data.
20{{NONGC}} defaults to {{#f}} (the vector will be located in normal garbage collected memory) and
21{{FINALIZE}} defaults to  {{#t}}. Note that the {{FINALIZE}} argument is only used when {{NONGC}}
22is true.
23
24
25Additionally, the following procedures are provided:
26
27=== u8vector->blob
28=== s8vector->blob
29=== u16vector->blob
30=== s16vector->blob
31=== u32vector->blob
32=== s32vector->blob
33=== f32vector->blob
34=== f64vector->blob
35=== u8vector->blob/shared
36=== s8vector->blob/shared
37=== u16vector->blob/shared
38=== s16vector->blob/shared
39=== u32vector->blob/shared
40=== s32vector->blob/shared
41=== f32vector->blob/shared
42=== f64vector->blob/shared
43
44 [procedure] (u8vector->blob U8VECTOR)
45 [procedure] (s8vector->blob S8VECTOR)
46 [procedure] (u16vector->blob U16VECTOR)
47 [procedure] (s16vector->blob S16VECTOR)
48 [procedure] (u32vector->blob U32VECTOR)
49 [procedure] (s32vector->blob S32VECTOR)
50 [procedure] (f32vector->blob F32VECTOR)
51 [procedure] (f64vector->blob F64VECTOR)
52 [procedure] (u8vector->blob/shared U8VECTOR)
53 [procedure] (s8vector->blob/shared S8VECTOR)
54 [procedure] (u16vector->blob/shared U16VECTOR)
55 [procedure] (s16vector->blob/shared S16VECTOR)
56 [procedure] (u32vector->blob/shared U32VECTOR)
57 [procedure] (s32vector->blob/shared S32VECTOR)
58 [procedure] (f32vector->blob/shared F32VECTOR)
59 [procedure] (f64vector->blob/shared F64VECTOR)
60
61Each of these procedures return the contents of the given vector as a
62'packed' blob. The byte order in that vector is platform-dependent
63(for example little-endian on an '''Intel''' processor). The {{/shared}}
64variants return a blob that shares memory with the contents of the vector.
65
66
67=== blob->u8vector
68=== blob->s8vector
69=== blob->u16vector
70=== blob->s16vector
71=== blob->u32vector
72=== blob->s32vector
73=== blob->f32vector
74=== blob->f64vector
75=== blob->u8vector/shared
76=== blob->s8vector/shared
77=== blob->u16vector/shared
78=== blob->s16vector/shared
79=== blob->u32vector/shared
80=== blob->s32vector/shared
81=== blob->f32vector/shared
82=== blob->f64vector/shared
83
84 [procedure] (blob->u8vector BLOB)
85 [procedure] (blob->s8vector BLOB)
86 [procedure] (blob->u16vector BLOB)
87 [procedure] (blob->s16vector BLOB)
88 [procedure] (blob->u32vector BLOB)
89 [procedure] (blob->s32vector BLOB)
90 [procedure] (blob->f32vector BLOB)
91 [procedure] (blob->f64vector BLOB)
92 [procedure] (blob->u8vector/shared BLOB)
93 [procedure] (blob->s8vector/shared BLOB)
94 [procedure] (blob->u16vector/shared BLOB)
95 [procedure] (blob->s16vector/shared BLOB)
96 [procedure] (blob->u32vector/shared BLOB)
97 [procedure] (blob->s32vector/shared BLOB)
98 [procedure] (blob->f32vector/shared BLOB)
99 [procedure] (blob->f64vector/shared BLOB)
100
101Each of these procedures return a vector where the argument
102{{BLOB}} is taken as a 'packed' representation of the contents
103of the vector. The {{/shared}} variants return a vector that
104shares memory with the contents of the blob.
105
106
107=== subu8vector
108=== subu16vector
109=== subu32vector
110=== subs8vector
111=== subs16vector
112=== subs32vector
113=== subf32vector
114=== subf64vector
115
116 [procedure] (subu8vector U8VECTOR FROM TO)
117 [procedure] (subu16vector U16VECTOR FROM TO)
118 [procedure] (subu32vector U32VECTOR FROM TO)
119 [procedure] (subs8vector S8VECTOR FROM TO)
120 [procedure] (subs16vector S16VECTOR FROM TO)
121 [procedure] (subs32vector S32VECTOR FROM TO)
122 [procedure] (subf32vector F32VECTOR FROM TO)
123 [procedure] (subf64vector F64VECTOR FROM TO)
124
125Creates a number vector of the same type as the argument vector with the elements at the positions {{FROM}} up to but
126not including {{TO}}.
127
128SRFI-17 Setters for {{XXXvector-ref}} are defined.
129
130
131=== read-u8vector
132
133 [procedure] (read-u8vector LENGTH [PORT])
134
135Reads {{LENGTH}} bytes from the {{PORT}} and returns a fresh
136{{u8vector}} or less if end-of-file is encountered. {{PORT}} defaults to the
137value of {{(current-input-port)}}.
138If {{LENGTH}} is {{#f}}, the vector will be filled completely until end-of-file is reached.
139
140
141=== read-u8vector!
142
143 [procedure] (read-u8vector! LENGTH U8VECTOR [PORT [START]])
144
145Reads {{LENGTH}} bytes from the {{PORT}} writing the read input into
146{{U8VECTOR}} beginning at {{START}} (or 0 if not given). {{PORT}} defaults
147to the value of {{(current-input-port)}}.
148If {{LENGTH}} is {{#f}}, the vector will be filled completely until end-of-file is reached.
149This procedure returns the number of bytes read.
150
151
152=== write-u8vector
153
154 [procedure] (write-u8vector U8VECTOR [PORT [START [END]]])
155
156Writes the bytes {{U8VECTOR}} between the indices {{START}} (inclusive) and {{END}} (exclusive) to {{PORT}}.
157{{PORT}} defaults to the value of {{(current-output-port)}}.
158
159
160Previous: [[Unit srfi-1]]
161
162Next: [[Unit srfi-13]]
Note: See TracBrowser for help on using the repository browser.