Uniform vectors are vectors whose elements are of the same numeric type.
The are defined by SRFI-4.
However, the type names (such as <s8vector>) are a Kawa extension.
The type of uniform vectors where each element can contain a signed 8-bit integer. Represented using an array of
<byte>.
The type of uniform vectors where each element can contain an unsigned 8-bit integer. Represented using an array of
<byte>, but each element is treated as if unsigned.
The type of uniform vectors where each element can contain a signed 16-bit integer. Represented using an array of
<short>.
The type of uniform vectors where each element can contain an unsigned 16-bit integer. Represented using an array of
<short>, but each element is treated as if unsigned.
The type of uniform vectors where each element can contain a signed 32-bit integer. Represented using an array of
<int>.
The type of uniform vectors where each element can contain an unsigned 32-bit integer. Represented using an array of
<int>, but each element is treated as if unsigned.
The type of uniform vectors where each element can contain a signed 64-bit integer. Represented using an array of
<long>.
The type of uniform vectors where each element can contain an unsigned 64-bit integer. Represented using an array of
<long>, but each element is treated as if unsigned.
The type of uniform vectors where each element can contain a 32-bit floating-point real. Represented using an array of
<float>.
The type of uniform vectors where each element can contain a 64-bit floating-point real. Represented using an array of
<double>.
Return true iff
valueis a uniform vector of the specified type.
Function: make-s8vector n [value]
Function: make-u8vector n [value]
Function: make-s16vector n [value]
Function: make-u16vector n [value]
Function: make-s32vector n [value]
Function: make-u32vector n [value]
Function: make-s64vector n [value]
Function: make-u64vector n [value]
Function: make-f32vector n [value]
Function: make-f64vector n [value]
Create a new uniform vector of the specified type, having room for
nelements. Initialize each element tovalueif it is specified; zero otherwise.
Create a new uniform vector of the specified type, whose length is the number of
values specified, and initialize it using thosevalues.
Return the length (in number of elements) of the uniform vector
v.
Return the element at index
iof the uniform vectorv.
Function: s16vector-set! v i x
Function: u16vector-set! v i x
Function: s32vector-set! v i x
Function: u32vector-set! v i x
Function: s64vector-set! v i x
Function: u64vector-set! v i x
Function: f32vector-set! v i x
Function: f64vector-set! v i x
Set the element at index
iof uniform vectorvto the valuex, which must be a number coercible to the appropriate type.
Convert the uniform vetor
vto a list containing the elments ofv.
Create a uniform vector of the appropriate type, initializing it with the elements of the list
l. The elements oflmust be numbers coercible the new vector's element type.
Each uniform array type is implemented as an underlying Java array,
and a length field.
The underlying type is
byte[] for <u8vector> or <s8vector>;
short[] for <u16vector> or <u16vector>;
int[] for <u32vector> or <s32vector>;
long[] for <u64vector> or <s64vector>;
<float[] for <f32vector>; and
<double[] for <f32vector>.
The length field allows a uniform array to only use the
initial part of the underlying array.  (This can be used
to support Common Lisp's fill pointer feature.)
This also allows resizing a uniform vector.  There is no
Scheme function for this, but you can use the setSize method:
(invoke some-vector 'setSize 200)
If you have a Java array, you can create a uniform vector sharing with the Java array:
(define arr :: <byte[]> ((primitive-array-new <byte>) 10)) (define vec :: <u8vector> (make <u8vector> arr))
At this point vec uses arr for its underlying storage,
so changes to one affect the other.
It vec is re-sized so it needs a larger underlying array,
then it will no longer use arr.