chickadee » generalized-arrays » array-storage-object

array-storage-object arrayprocedure

Gets the underlying storage-object of the array. This is primarily meant if one wants to get the underlying storage in order to pass it to some specialized procedure that can operate on the array contents directly. An example of this could be passing the underlying storage object to the FFI, such as to use BLAS or LAPACK optimized procedures over the underlying array storage.

For example, see the following example (copied from the BLAS egg):

(import generalized-arrays

(define order RowMajor)
(define transa NoTrans)

(define m 4)
(define n 4)

(define alpha 1)
(define beta 0)

(define a
    (vector m n)
    (f64vector 1 2 3 4
               1 1 1 1
               3 4 5 6
               5 6 7 8)))

(define x (f64vector 1 2 1 1))
(define y (f64vector 0 0 0 0))

(dgemv! order transa m n alpha (array-storage-object a) x beta y)

(test "Result of multiplying the array a by the vector x"
      (f64vector 12 5 22 32))

Generally speaking, the above is a contrived example; However, this contrived example demonstrates how one might start to build a more complete (and optimized) mathematics library that can be utilized in conjunction with the provided arrays API.