## generic-number-vectors

### Description

Generic functions for srfi-4 vectors.

### Author

Richard van Roy (pluizer)

### Requirements

fast-generic

### Documentation

`(make-number-vector TYPE N [VALUE NONGC FINALIZE])`procedureReturn a newly-allocated SRFI-4 homogeneous number vector of length N and type TYPE.

If the optional fill VALUE is specified, it specifies the initial value for each slot in the vector. If not, the content of the vector is unspecified but individual elements of the vector are guaranteed to be in the range of values permitted for that type of vector.

The type of the fill value must be compatible with the elements of the vector datatype. It is an error if otherwise -- for example, if an inexact integer is passed to

`make-u8vector`.On Chicken, these procedures have been extended to allow allocating the storage in non-garbage collected memory, as follows:

The optional arguments

`NONGC`and`FINALIZE`define whether the vector should be allocated in a memory area not subject to garbage collection and whether the associated storage should be automatically freed (using finalization) when there are no references from Scheme variables and data.`NONGC`defaults to`#f`(the vector will be located in normal garbage collected memory) and`FINALIZE`defaults to`#t`. Note that the`FINALIZE`argument is only used when`NONGC`is true.

`(number-vector TYPE VALUE ...)`procedureReturn a newly-allocated SRFI-4 homogeneous number vector of the specified type TYPE, composed of the arguments.

`(number-subvector VECTOR FROM TO)`procedureCreates a number vector of the same type as the argument vector with the elements at the positions

`FROM`up to but not including`TO`.

`(number-vector-type VECTOR)`procedureReturns the type of the number VECTOR as a symbol.

`(number-vector-length VECTOR)`procedureReturns the length of the SRFI-4 homogeneous number VECTOR.

`(number-vector-ref VECTOR I)`procedureReturn the value of the

*i*th element of the SRFI-4 homogeneous number vector, where`I`is a nonnegative exact integer less than the length of the vector.

`(number-vector-set! VECTOR I VALUE)`procedureSet the

`i`th element of the SRFI-4 homogeneous number VECTOR to VALUE.`I`is a nonnegative exact integer less than the length of the vector and VALUE must be the same type as the elements of the vector datatype.

`(number-vector->list VECTOR)`procedureReturn a list consisting of the elements of SRFI-4 homogeneous number VECTOR.

`(list->number-vector TYPE LIST)`procedureReturn a newly-allocated SRFI-4 homogeneous number VECTOR of TYPE consisting of the elements of LIST. Each element of LIST must be compatible with the datatype of VECTOR.